ALGORITHMS FINAL TEST 2026
QUESTIONS WITH CORRECT ANSWERS
GRADED A+
◍ string literal..
Answer: Text enclosed in quotes is known as a_________ Text in
______________ may have letters, numbers, spaces, or symbols like "@" or
"#".Strings are immutable. Once created, they can not be changed. To
update a string variable, an entire new string must be assigned to the
variable.In-place modification of string variables is not allowed.
◍ linked list.
Answer: ordered nodes w ref to next node
◍ How does an operating system manage multiple programs?.
Answer: Runs a little of each program in turn
◍ Add(int index, Object x).
Answer: Which command will insert object x at position index in a list?
◍ Graph Components.
Answer: -Vertices (nodes)-Edges -"Connectedness"-Vertices in a graph can
represent airports, with edges representing available flights-Adjacent -Two
nodes are directly connected by an edge-Path -Sequence of edges leading
from source to target-Path Length -Total number of edges in a path-Distance
-Number of edges on the shortest path of 2 vertices-Edge weights
-Associates a weight (cost, time, etc.) with each edge -Often represents the
length of a travel rout, either in total distance or expected time-Directed
Edges -Sequence of directed edges leading from a source to a destination
, vertex-Cycle -a path that starts and ends at the same vertex. A directed
graph is cyclic if the graph contains a cycle, and acyclic if the graph does
not contain a cycle
◍ Append to non-empty list.
Answer: If the list's head pointer is not null (not empty), the algorithm points
the tail node's next pointer and the list's tail pointer to the new node.
◍ len().
Answer: A Python function to find the length of a string (and any other
sequence type).
◍ Pop().
Answer: Which command will retrieve an item from the top of the stack?
◍ instance object.
Answer: When created by the class object, this is initialized via the __init__
method.
◍ Greedy Algorithm.
Answer: solves a problem by assuming that the optimal choice at a given
moment during the algorithm will also be the optimal choice overall.
◍ A binary tree is perfect if:.
Answer: if all internal nodes have 2 children and all leaf nodes are at the
same level.
◍ edge.
Answer: part of a graph that represents a connection between to vertices in a
graph
◍ Record.
Answer: Scenario: Employee Database-A record can represent an employee
with fields such as name, employee ID, department, and salary.*Similar to
an object*No methods
◍ empty LinkedList.
Answer: An _______ has two data members, but both are set to None, thus
, the list has no nodes.
◍ Probing Sequence.
Answer: The sequence of keys iterated through when attempting to obtain
the desired table index.
◍ Heap - right_child_index.
Answer: right_child_index = 2 * node_index + 2
◍ What is the runtime complexity for the expression 305 + O(325*N)?.
Answer: O(N)
◍ hash table.
Answer: a data structure that stores unordered items by mapping (or
hashing) each item to a location in an array (or vector).
◍ Hash Table.
Answer: Scenario: Dictionary-A hash table can be used to implement a
dictionary, where words are keys and definitions are values. The hash
function can map each word to its corresponding definition.*stores
unordered items by mapping (or hashing) each item to a location in an
array*each element is a "bucket"*Items use a key to compute bucket
value*Very fast
◍ class attribute.
Answer: Defined within the scope of a class, this attribute is shared amongst
all of the instances of that class
◍ treap.
Answer: uses a main key that maintains a binary search tree ordering
property, and a secondary key generated randomly (often called "priority")
during insertions that maintains a heap property.
◍ Array based list.
Answer: A list ADT implemented using an array. An array-based list
supports the common list ADT operations, such as append, prepend, insert
after, remove, and search.