Data Structures — One Question at a Time

Data Structures — One Question at a Time

Practise 150 Data Structures multiple-choice questions covering arrays, stacks, queues, linked lists, sorting, searching, hashing, trees and graph algorithms. Work through one question at a time, check the correct answer with an explanation, and select Next Question to continue. This is self-paced practice without automatic scoring.

Before you practise: Read Data Structures study material and examples. You can also browse all 1,576 interactive MCQs.

Practice Set 1 · Question 1 of 150

Question 1. Which notation describes an asymptotic upper bound?

  1. An exact runtime in seconds
  2. Memory address
  3. Big O
  4. Big Omega only
Show Answer and Explanation

Correct answer: C. Big O

Big O provides an upper bound on asymptotic growth.

Next Question →

Practice Set 1 · Question 2 of 150

Question 2. What is the worst-case time of linear search in an array of n elements?

  1. O(n)
  2. O(n²)
  3. O(1)
  4. O(log n)
Show Answer and Explanation

Correct answer: A. O(n)

If the target is last or absent, all n elements are checked.

Next Question →

Practice Set 1 · Question 3 of 150

Question 3. What order does a stack follow?

  1. Ascending key
  2. Random
  3. FIFO
  4. LIFO
Show Answer and Explanation

Correct answer: D. LIFO

The most recently pushed item is the first popped.

Next Question →

Practice Set 1 · Question 4 of 150

Question 4. Push 4, push 7, then pop. Which value is returned?

  1. 4
  2. 7
  3. 11
  4. No value
Show Answer and Explanation

Correct answer: B. 7

7 is at the top of the stack.

Next Question →

Practice Set 1 · Question 5 of 150

Question 5. Which structure naturally holds active recursive function calls?

  1. File index
  2. Stack
  3. Binary search tree
  4. Graph adjacency list
Show Answer and Explanation

Correct answer: B. Stack

Call frames are managed as a stack in common runtime implementations.

Next Question →

Practice Set 1 · Question 6 of 150

Question 6. What order does a conventional queue follow?

  1. Descending numeric
  2. LIFO
  3. Priority sorted
  4. FIFO
Show Answer and Explanation

Correct answer: D. FIFO

The first item added is the first removed.

Next Question →

Practice Set 1 · Question 7 of 150

Question 7. Enqueue A, B and C; dequeue twice. Which item remains at the front?

  1. C
  2. None
  3. A
  4. B
Show Answer and Explanation

Correct answer: A. C

A and B leave in order, so C is next.

Next Question →

Practice Set 1 · Question 8 of 150

Question 8. What determines removal order in a priority queue?

  1. Only string length
  2. Fixed index 0
  3. Item priority
  4. Only insertion time
Show Answer and Explanation

Correct answer: C. Item priority

A priority queue serves according to priority (with tie behaviour dependent on implementation).

Next Question →

Practice Set 1 · Question 9 of 150

Question 9. What does a singly linked list node typically contain?

  1. Only an array index
  2. CPU instructions only
  3. Entire memory
  4. Value and reference to the next node
Show Answer and Explanation

Correct answer: D. Value and reference to the next node

A node stores an item and a link to the next node.

Next Question →

Practice Set 1 · Question 10 of 150

Question 10. Given a head pointer, what is the cost of inserting at the front of a singly linked list?

  1. O(log n)
  2. O(1)
  3. O(n²)
  4. O(n)
Show Answer and Explanation

Correct answer: B. O(1)

Only a constant number of pointer updates is required.

Continue to Practice Set 2

Practice Set 2 · Question 11 of 150

Question 11. Which linked-list property generally differs from a contiguous array?

  1. Lists cannot be traversed
  2. Lists always permit O(1) random indexed access
  3. Nodes need not be stored adjacently
  4. Only arrays store values
Show Answer and Explanation

Correct answer: C. Nodes need not be stored adjacently

Links connect nodes that may occupy separate memory locations.

Next Question →

Practice Set 2 · Question 12 of 150

Question 12. What is the worst-case time of insertion sort on n elements?

  1. O(n²)
  2. O(1)
  3. O(log n)
  4. O(n)
Show Answer and Explanation

Correct answer: A. O(n²)

A reverse-ordered input can require a quadratic number of shifts/comparisons.

Next Question →

Practice Set 2 · Question 13 of 150

Question 13. What is typical worst-case time for merge sort?

  1. O(n log n)
  2. O(n²)
  3. O(1)
  4. O(2ⁿ)
Show Answer and Explanation

Correct answer: A. O(n log n)

Divide-and-conquer merging gives O(n log n) time.

Next Question →

Practice Set 2 · Question 14 of 150

Question 14. Which simple sorting algorithm repeatedly selects the smallest remaining value?

  1. Counting sort
  2. Merge sort
  3. Selection sort
  4. Quick sort
Show Answer and Explanation

Correct answer: C. Selection sort

Selection sort selects the minimum from the unsorted portion each pass.

Next Question →

Practice Set 2 · Question 15 of 150

Question 15. When can ordinary binary search be applied correctly?

  1. On an arbitrary unsorted array
  2. On sorted, indexable data
  3. Only on graphs
  4. Only on strings of length one
Show Answer and Explanation

Correct answer: B. On sorted, indexable data

Binary search depends on sorted order to eliminate half the candidates.

Next Question →

Practice Set 2 · Question 16 of 150

Question 16. Binary search on 16 sorted elements needs at most how many comparisons for a successful or unsuccessful search under a standard midpoint algorithm?

  1. 16
  2. 2
  3. 4
  4. 5
Show Answer and Explanation

Correct answer: D. 5

An unsuccessful search can examine up to five midpoints as an interval of length 16 shrinks to zero.

Next Question →

Practice Set 2 · Question 17 of 150

Question 17. A hash-table collision occurs when what happens?

  1. A tree has one child
  2. Two arrays differ in length
  3. Two keys map to the same bucket or slot
  4. A value is negative
Show Answer and Explanation

Correct answer: C. Two keys map to the same bucket or slot

Collisions arise from distinct keys sharing a computed location.

Next Question →

Practice Set 2 · Question 18 of 150

Question 18. Which collision-resolution method stores multiple items in buckets using a list or similar collection?

  1. Binary search
  2. Merge sort
  3. Depth-first search
  4. Separate chaining
Show Answer and Explanation

Correct answer: D. Separate chaining

Chaining stores colliding entries in a bucket-associated structure.

Next Question →

Practice Set 2 · Question 19 of 150

Question 19. In a binary tree, how many children can a node have at most?

  1. 1
  2. 2
  3. 3
  4. Unlimited
Show Answer and Explanation

Correct answer: B. 2

Each binary-tree node has at most a left child and a right child.

Next Question →

Practice Set 2 · Question 20 of 150

Question 20. For a binary search tree with distinct keys, which traversal outputs keys in increasing order?

  1. Inorder
  2. Preorder
  3. Postorder
  4. Level order
Show Answer and Explanation

Correct answer: A. Inorder

Visiting left subtree, root and right subtree yields ascending keys.

Continue to Practice Set 3

Practice Set 3 · Question 21 of 150

Question 21. What is the height of a single-node tree when height is measured in edges?

  1. Undefined
  2. 0
  3. 1
  4. 2
Show Answer and Explanation

Correct answer: B. 0

There are no edges along the longest root-to-leaf path.

Next Question →

Practice Set 3 · Question 22 of 150

Question 22. Which graph search normally uses a queue to discover vertices by increasing distance in an unweighted graph?

  1. BFS
  2. Quick sort
  3. Heap sort
  4. DFS
Show Answer and Explanation

Correct answer: A. BFS

Breadth-first search explores neighbours layer by layer using a queue.

Next Question →

Practice Set 3 · Question 23 of 150

Question 23. Which search is naturally implemented using a stack or recursion?

  1. Breadth-first search only
  2. Binary search
  3. Selection sort
  4. Depth-first search
Show Answer and Explanation

Correct answer: D. Depth-first search

DFS follows a branch deeply and backtracks, often through recursion or an explicit stack.

Next Question →

Practice Set 3 · Question 24 of 150

Question 24. What does an adjacency matrix entry at (i,j) usually record for a simple unweighted graph?

  1. The sorting order
  2. The processor speed
  3. Whether an edge connects vertices i and j
  4. The graph diameter automatically
Show Answer and Explanation

Correct answer: C. Whether an edge connects vertices i and j

The matrix stores edge incidence, usually 1 for an edge and 0 otherwise.

Next Question →

Practice Set 3 · Question 25 of 150

Question 25. In a connected, unweighted graph, what does BFS find from a given source?

  1. Always the minimum spanning tree
  2. The maximum weighted path
  3. All Hamiltonian cycles
  4. A path with the fewest edges to each reachable vertex
Show Answer and Explanation

Correct answer: D. A path with the fewest edges to each reachable vertex

BFS distances count edges and are shortest in unweighted graphs.

Next Question →

Practice Set 3 · Question 26 of 150

Question 26. A loop increments i by 1 from 0 to n−1; what is its iteration count?

  1. log n
  2. n²
  3. n
  4. n/2
Show Answer and Explanation

Correct answer: C. n

The loop executes once for each of n indices.

Next Question →

Practice Set 3 · Question 27 of 150

Question 27. Starting with i = 1, a loop doubles i while i < n, with n ≥ 2. How does its iteration count grow?

  1. O(log n)
  2. O(2ⁿ)
  3. O(n²)
  4. O(n)
Show Answer and Explanation

Correct answer: A. O(log n)

The number of iterations is the smallest k with 2^k ≥ n, namely ⌈log₂ n⌉, and therefore is Θ(log n).

Next Question →

Practice Set 3 · Question 28 of 150

Question 28. What is the auxiliary space of an iterative in-place selection sort?

  1. O(n²)
  2. O(1)
  3. O(log n)
  4. O(n)
Show Answer and Explanation

Correct answer: B. O(1)

Only a constant number of temporary variables is needed.

Next Question →

Practice Set 3 · Question 29 of 150

Question 29. A stack receives push(2), push(3), pop(), push(4). What does pop() return next?

  1. 4
  2. Nothing
  3. 2
  4. 3
Show Answer and Explanation

Correct answer: A. 4

After removing 3, 4 becomes the new top.

Next Question →

Practice Set 3 · Question 30 of 150

Question 30. A circular queue with fixed capacity is useful primarily for what?

  1. Sorting arbitrary keys
  2. Traversing trees only
  3. Compressing images
  4. Reusing freed array slots efficiently
Show Answer and Explanation

Correct answer: D. Reusing freed array slots efficiently

Circular indexing allows wraparound and reuse of available storage.

Continue to Practice Set 4

Practice Set 4 · Question 31 of 150

Question 31. Which structure is commonly used to evaluate postfix expressions?

  1. Binary tree only
  2. Hash table
  3. Stack
  4. Priority queue only
Show Answer and Explanation

Correct answer: C. Stack

Operands are pushed and operators consume the top stack values.

Next Question →

Practice Set 4 · Question 32 of 150

Question 32. What is a deque?

  1. A search tree
  2. A double-ended queue
  3. A directed acyclic graph
  4. A fixed-size heap only
Show Answer and Explanation

Correct answer: B. A double-ended queue

A deque supports insertion and removal at both ends.

Next Question →

Practice Set 4 · Question 33 of 150

Question 33. For a singly linked list without a tail pointer, how long can appending take?

  1. O(1) always
  2. O(log n)
  3. O(n)
  4. O(n²)
Show Answer and Explanation

Correct answer: C. O(n)

Without a tail pointer, reaching the last node requires traversal.

Next Question →

Practice Set 4 · Question 34 of 150

Question 34. Which pointer update inserts node N immediately after P in a singly linked list?

  1. N.next=P.next; P.next=N
  2. P=N.next; N=P.next
  3. P.next=null always
  4. N.next=N
Show Answer and Explanation

Correct answer: A. N.next=P.next; P.next=N

Preserve the old successor before linking P to N.

Next Question →

Practice Set 4 · Question 35 of 150

Question 35. What extra reference does a doubly linked list node commonly have?

  1. Root of a heap
  2. Binary search pivot
  3. Array capacity
  4. Previous node
Show Answer and Explanation

Correct answer: D. Previous node

Doubly linked nodes usually store both next and previous references.

Next Question →

Practice Set 4 · Question 36 of 150

Question 36. Which algorithm is stable in its standard merge-based implementation?

  1. In-place quicksort in general
  2. Merge sort
  3. Selection sort by arbitrary swapping
  4. Heap sort
Show Answer and Explanation

Correct answer: B. Merge sort

A conventional merge implementation preserves the order of equal keys.

Next Question →

Practice Set 4 · Question 37 of 150

Question 37. For a reverse-sorted list, how many comparisons does basic selection sort perform asymptotically?

  1. O(n)
  2. O(n²)
  3. O(1)
  4. O(log n)
Show Answer and Explanation

Correct answer: B. O(n²)

Basic selection sort scans the unsorted suffix regardless of initial order.

Next Question →

Practice Set 4 · Question 38 of 150

Question 38. Why can quicksort reach O(n²) time?

  1. Using recursion at all
  2. Stable equal keys
  3. Choosing the middle index
  4. Highly unbalanced partitions
Show Answer and Explanation

Correct answer: D. Highly unbalanced partitions

A sequence of near-empty partitions yields a quadratic sum of work.

Next Question →

Practice Set 4 · Question 39 of 150

Question 39. Which sorting method is non-comparison-based for bounded integer keys?

  1. Counting sort
  2. Insertion sort
  3. Merge sort
  4. Heap sort
Show Answer and Explanation

Correct answer: A. Counting sort

Counting sort uses key frequencies rather than pairwise ordering comparisons.

Next Question →

Practice Set 4 · Question 40 of 150

Question 40. What is a load factor for a typical chained hash table?

  1. Number of comparisons in merge sort
  2. Size of the largest key
  3. Number of entries divided by number of buckets
  4. Height of its root
Show Answer and Explanation

Correct answer: C. Number of entries divided by number of buckets

Load factor α = n/m measures average entries per bucket.

Continue to Practice Set 5

Practice Set 5 · Question 41 of 150

Question 41. In linear probing, where is the next collision candidate usually sought?

  1. A linked list at the same bucket
  2. A binary tree root
  3. A sorted array
  4. A nearby slot in a fixed probe sequence
Show Answer and Explanation

Correct answer: D. A nearby slot in a fixed probe sequence

Open addressing examines alternate slots according to a probe sequence.

Next Question →

Practice Set 5 · Question 42 of 150

Question 42. What are the nodes with no children called?

  1. Parents
  2. Leaves
  3. Ancestors
  4. Roots only
Show Answer and Explanation

Correct answer: B. Leaves

A leaf has no child nodes.

Next Question →

Practice Set 5 · Question 43 of 150

Question 43. In a complete binary tree, where is the last level filled?

  1. In arbitrary order
  2. With exactly one node
  3. From left to right
  4. From right to left
Show Answer and Explanation

Correct answer: C. From left to right

All levels except possibly the last are full; the last is filled left to right.

Next Question →

Practice Set 5 · Question 44 of 150

Question 44. Which heap property defines a min-heap?

  1. Every parent key is ≤ its children
  2. Every left child is smaller than every right child
  3. All nodes are equal
  4. The tree is a search tree
Show Answer and Explanation

Correct answer: A. Every parent key is ≤ its children

A min-heap keeps each parent no greater than its children.

Next Question →

Practice Set 5 · Question 45 of 150

Question 45. What is the worst-case height of an unbalanced BST with n nodes?

  1. O(n)
  2. O(n²)
  3. O(1)
  4. O(log n) always
Show Answer and Explanation

Correct answer: A. O(n)

Sorted insertions can create a chain of n nodes.

Next Question →

Practice Set 5 · Question 46 of 150

Question 46. For an undirected graph with 5 vertices and 4 edges, what is the sum of all vertex degrees?

  1. 4
  2. 5
  3. 8
  4. 20
Show Answer and Explanation

Correct answer: C. 8

The handshaking lemma gives total degree 2m = 8.

Next Question →

Practice Set 5 · Question 47 of 150

Question 47. What is a topological ordering defined for?

  1. Only complete graphs
  2. Directed acyclic graphs
  3. Every undirected cycle
  4. Any weighted graph
Show Answer and Explanation

Correct answer: B. Directed acyclic graphs

A DAG admits a vertex ordering respecting every directed edge.

Next Question →

Practice Set 5 · Question 48 of 150

Question 48. Which representation uses O(V²) space for V vertices?

  1. Adjacency list in all cases
  2. Edge list in all cases
  3. Queue
  4. Adjacency matrix
Show Answer and Explanation

Correct answer: D. Adjacency matrix

A V×V adjacency matrix has V² entries.

Next Question →

Practice Set 5 · Question 49 of 150

Question 49. For unweighted shortest paths from a source, which algorithm is appropriate?

  1. Selection sort
  2. Binary search
  3. Breadth-first search
  4. Depth-first search always
Show Answer and Explanation

Correct answer: C. Breadth-first search

BFS visits vertices by increasing distance in edge count.

Next Question →

Practice Set 5 · Question 50 of 150

Question 50. Dijkstra’s algorithm requires what edge-weight condition for its standard correctness guarantee?

  1. Exactly one edge
  2. All weights negative
  3. No cycles of any kind
  4. Nonnegative edge weights
Show Answer and Explanation

Correct answer: D. Nonnegative edge weights

The standard algorithm assumes all edge weights are nonnegative.

Continue to Practice Set 6

Practice Set 6 · Question 51 of 150

Question 51. Which traversal follows a path deeply before backtracking?

  1. Insertion sort
  2. DFS
  3. BFS
  4. Heapification
Show Answer and Explanation

Correct answer: B. DFS

Depth-first search explores descendants before returning to alternatives.

Next Question →

Practice Set 6 · Question 52 of 150

Question 52. For T(n)=2T(n/2)+n with T(1)=Θ(1), what is T(n) for powers of 2?

  1. Θ(n log n)
  2. Θ(n²)
  3. Θ(n)
  4. Θ(log n)
Show Answer and Explanation

Correct answer: A. Θ(n log n)

The merge-sort recurrence has log n levels, each with Θ(n) work.

Next Question →

Practice Set 6 · Question 53 of 150

Question 53. For T(n)=T(n−1)+1, T(1)=1, what is asymptotic growth?

  1. Θ(log n)
  2. Θ(n)
  3. Θ(n²)
  4. Θ(1)
Show Answer and Explanation

Correct answer: B. Θ(n)

The recurrence adds one unit for each decrease from n to 1.

Next Question →

Practice Set 6 · Question 54 of 150

Question 54. A recursive function calls itself once with n−1 until n=0. What is maximum call-stack depth?

  1. Θ(n)
  2. Θ(n²)
  3. Θ(1)
  4. Θ(log n)
Show Answer and Explanation

Correct answer: A. Θ(n)

There are n+1 active levels before the base case.

Next Question →

Practice Set 6 · Question 55 of 150

Question 55. Starting at i = 1, a loop doubles i while i < n for integer n ≥ 2 and performs constant work each time. What is its runtime?

  1. Θ(n²)
  2. Θ(2ⁿ)
  3. Θ(n)
  4. Θ(log n)
Show Answer and Explanation

Correct answer: D. Θ(log n)

The loop makes ⌈log₂ n⌉ iterations, each doing constant work, so the runtime is Θ(log n).

Next Question →

Practice Set 6 · Question 56 of 150

Question 56. Evaluate the postfix expression 5 2 + 3 *.

  1. 10
  2. 11
  3. 21
  4. 30
Show Answer and Explanation

Correct answer: C. 21

First 5+2=7; then 7×3=21.

Next Question →

Practice Set 6 · Question 57 of 150

Question 57. Which structure is best suited to managing undo operations when only the latest change is undone?

  1. Priority queue
  2. Hash set
  3. Binary heap
  4. Stack
Show Answer and Explanation

Correct answer: D. Stack

The latest action is reversed first, a last-in-first-out pattern.

Next Question →

Practice Set 6 · Question 58 of 150

Question 58. A queue initially contains [A,B,C] front to back. After dequeue and enqueue D, what is the order?

  1. [C,D,B]
  2. [D,B,C]
  3. [B,C,D]
  4. [A,C,D]
Show Answer and Explanation

Correct answer: C. [B,C,D]

Dequeue removes A; enqueue adds D at the back.

Next Question →

Practice Set 6 · Question 59 of 150

Question 59. If a queue is implemented by a circular array, what does wrapping mean?

  1. After last array index, the next index is zero
  2. The queue becomes sorted
  3. Every enqueue copies all elements
  4. The first slot is never reused
Show Answer and Explanation

Correct answer: A. After last array index, the next index is zero

Circular indexing uses the array modulo its capacity.

Next Question →

Practice Set 6 · Question 60 of 150

Question 60. With only a head pointer, deleting the first node of a nonempty singly linked list takes what time?

  1. O(n²)
  2. O(1)
  3. O(log n)
  4. O(n)
Show Answer and Explanation

Correct answer: B. O(1)

The head can be advanced to its successor in constant time.

Continue to Practice Set 7

Practice Set 7 · Question 61 of 150

Question 61. Which condition identifies the final node in a conventional null-terminated singly linked list?

  1. Its next reference is null
  2. Its value is zero
  3. It has two children
  4. Its array index equals n
Show Answer and Explanation

Correct answer: A. Its next reference is null

The last node has no successor link.

Next Question →

Practice Set 7 · Question 62 of 150

Question 62. What is the worst-case comparison count for linear search on a list of 8 items?

  1. 3
  2. 4
  3. 7
  4. 8
Show Answer and Explanation

Correct answer: D. 8

The searched-for item may be last or absent, requiring eight comparisons.

Next Question →

Practice Set 7 · Question 63 of 150

Question 63. How many comparisons does selection sort make on 5 elements using the standard minimum-selection procedure?

  1. 4
  2. 5
  3. 10
  4. 20
Show Answer and Explanation

Correct answer: C. 10

The passes compare 4+3+2+1=10 pairs regardless of original order.

Next Question →

Practice Set 7 · Question 64 of 150

Question 64. Which common sorting algorithm is stable when implemented by merging equal keys from the left half first?

  1. Selection sort with arbitrary swaps
  2. Merge sort
  3. Heap sort
  4. Typical in-place quicksort
Show Answer and Explanation

Correct answer: B. Merge sort

Keeping left-half equal keys first preserves their original relative order.

Next Question →

Practice Set 7 · Question 65 of 150

Question 65. Which data are needed for an ordinary binary search on an array?

  1. Only distinct values
  2. Only powers of two
  3. Sorted values
  4. Only positive numbers
Show Answer and Explanation

Correct answer: C. Sorted values

Binary search requires ordering; duplicate values are permitted.

Next Question →

Practice Set 7 · Question 66 of 150

Question 66. In separate chaining, what does a hash table typically store at each bucket?

  1. A collection of colliding entries
  2. A binary search pivot only
  3. A graph root
  4. A running total of keys
Show Answer and Explanation

Correct answer: A. A collection of colliding entries

Each bucket can hold multiple items whose keys map there.

Next Question →

Practice Set 7 · Question 67 of 150

Question 67. If a table has 12 entries across 8 buckets, what is its load factor?

  1. 4
  2. 20
  3. 0.67
  4. 1.5
Show Answer and Explanation

Correct answer: D. 1.5

Load factor is n/m = 12/8 = 1.5 for separate chaining.

Next Question →

Practice Set 7 · Question 68 of 150

Question 68. What happens when open-addressing insertion probes a slot already occupied by another key?

  1. It switches into a binary tree
  2. It follows the probing sequence to another slot
  3. It always overwrites the key
  4. It must terminate the program
Show Answer and Explanation

Correct answer: B. It follows the probing sequence to another slot

Open addressing resolves collisions by examining alternate locations.

Next Question →

Practice Set 7 · Question 69 of 150

Question 69. A tree has one root and exactly three edges along its longest root-to-leaf path. What is its height in edges?

  1. 2
  2. 3
  3. 4
  4. 8
Show Answer and Explanation

Correct answer: B. 3

Height counts edges on the longest downward path, giving 3.

Next Question →

Practice Set 7 · Question 70 of 150

Question 70. In a min-heap, which position contains a minimum element?

  1. The last leaf
  2. Always the right child
  3. An arbitrary internal node
  4. The root
Show Answer and Explanation

Correct answer: D. The root

Each parent has a key no greater than its children, so the root is minimal.

Continue to Practice Set 8

Practice Set 8 · Question 71 of 150

Question 71. What is the worst-case complexity of searching for a key in a skewed, unbalanced BST with n nodes?

  1. O(n)
  2. O(n log n)
  3. O(1)
  4. O(log n)
Show Answer and Explanation

Correct answer: A. O(n)

A skewed BST can form a chain with n nodes.

Next Question →

Practice Set 8 · Question 72 of 150

Question 72. What order does postorder traversal use for a binary tree?

  1. Root-left-right
  2. Left-root-right
  3. Left-right-root
  4. Right-root-left
Show Answer and Explanation

Correct answer: C. Left-right-root

Postorder processes left subtree, then right subtree, then root.

Next Question →

Practice Set 8 · Question 73 of 150

Question 73. In an undirected simple graph with 6 vertices each of degree 2, how many edges are there?

  1. 8
  2. 12
  3. 4
  4. 6
Show Answer and Explanation

Correct answer: D. 6

The sum of degrees is 12; dividing by two gives six edges.

Next Question →

Practice Set 8 · Question 74 of 150

Question 74. For a directed graph with a cycle, what is true about a topological ordering of all its vertices?

  1. It always exists
  2. It cannot exist
  3. It must start at the cycle
  4. It always uses BFS
Show Answer and Explanation

Correct answer: B. It cannot exist

A topological ordering exists exactly for directed acyclic graphs.

Next Question →

Practice Set 8 · Question 75 of 150

Question 75. Which shortest-path method works for unweighted graphs using a queue?

  1. Selection sort
  2. Binary search
  3. BFS
  4. DFS for all cases
Show Answer and Explanation

Correct answer: C. BFS

BFS discovers vertices at increasing edge-distance.

Next Question →

Practice Set 8 · Question 76 of 150

Question 76. For a dense graph with V vertices, which representation directly tests whether edge (u,v) exists in O(1) time?

  1. Adjacency matrix
  2. Unsorted edge list
  3. Singly linked list of all vertices
  4. Only a queue
Show Answer and Explanation

Correct answer: A. Adjacency matrix

A matrix entry indexed by u and v provides constant-time lookup.

Next Question →

Practice Set 8 · Question 77 of 150

Question 77. What is the sum of outdegrees in any finite directed graph?

  1. Number of edges
  2. Twice number of edges
  3. Number of vertices squared
  4. Always zero
Show Answer and Explanation

Correct answer: A. Number of edges

Each directed edge contributes one to its source’s outdegree.

Next Question →

Practice Set 8 · Question 78 of 150

Question 78. How many comparisons are needed to find the maximum of n≥1 elements by linear scanning?

  1. n²
  2. log₂n
  3. n−1
  4. n
Show Answer and Explanation

Correct answer: C. n−1

After choosing the first item, compare the remaining n−1 items.

Next Question →

Practice Set 8 · Question 79 of 150

Question 79. Which recurrence represents binary search with constant work per step?

  1. T(n)=T(n−1)+n
  2. T(n)=T(n/2)+O(1)
  3. T(n)=2T(n/2)+n
  4. T(n)=nT(n−1)
Show Answer and Explanation

Correct answer: B. T(n)=T(n/2)+O(1)

Each step narrows the search to approximately half the elements.

Next Question →

Practice Set 8 · Question 80 of 150

Question 80. Two sequential loops each visit n elements and do constant work. What is their combined runtime?

  1. Θ(log n)
  2. Θ(2ⁿ)
  3. Θ(n²)
  4. Θ(n)
Show Answer and Explanation

Correct answer: D. Θ(n)

Their running times add to n+n=2n, which is Θ(n).

Continue to Practice Set 9

Practice Set 9 · Question 81 of 150

Question 81. A binary-search procedure on a sorted array starts left=0, right=7. What initial midpoint does (left+right)//2 give?

  1. 7
  2. 8
  3. 3
  4. 4
Show Answer and Explanation

Correct answer: C. 3

Integer division of 7 by 2 yields index 3.

Next Question →

Practice Set 9 · Question 82 of 150

Question 82. Starting with an empty stack, push 1, push 2, pop, push 5. What is at the top?

  1. Empty
  2. 1
  3. 2
  4. 5
Show Answer and Explanation

Correct answer: D. 5

After removing 2, pushing 5 makes it the top element.

Next Question →

Practice Set 9 · Question 83 of 150

Question 83. What structure is used by BFS to process discovered vertices in arrival order?

  1. Heap sort
  2. Queue
  3. Stack only
  4. Binary search tree
Show Answer and Explanation

Correct answer: B. Queue

A FIFO queue processes vertices layer by layer.

Next Question →

Practice Set 9 · Question 84 of 150

Question 84. What is a standard use of a stack in parsing?

  1. Matching nested parentheses
  2. Choosing shortest weighted paths
  3. Sorting using a hash function
  4. Storing every graph edge
Show Answer and Explanation

Correct answer: A. Matching nested parentheses

Opening delimiters are pushed and checked against closing delimiters.

Next Question →

Practice Set 9 · Question 85 of 150

Question 85. In a nonempty singly linked list with a head pointer, removing the head is what time complexity?

  1. O(log n)
  2. O(1)
  3. O(n²)
  4. O(n)
Show Answer and Explanation

Correct answer: B. O(1)

Update the head to the successor in constant time.

Next Question →

Practice Set 9 · Question 86 of 150

Question 86. What extra pointer is typically stored by doubly linked nodes?

  1. Previous pointer
  2. Heap pointer
  3. Hash seed
  4. Root pointer
Show Answer and Explanation

Correct answer: A. Previous pointer

Nodes reference both next and previous neighbours.

Next Question →

Practice Set 9 · Question 87 of 150

Question 87. After applying one standard left-to-right pass of bubble sort to [5, 2, 4, 1], what is the array?

  1. [1, 2, 4, 5]
  2. [2, 4, 1, 5]
  3. [5, 4, 2, 1]
  4. [2, 5, 1, 4]
Show Answer and Explanation

Correct answer: B. [2, 4, 1, 5]

Compare adjacent pairs and swap if out of order: [2,5,4,1], then [2,4,5,1], then [2,4,1,5]. The largest element reaches the final position.

Next Question →

Practice Set 9 · Question 88 of 150

Question 88. Which algorithm has Θ(n log n) worst-case time under a standard merge sort implementation?

  1. Bubble sort
  2. Insertion sort
  3. Merge sort
  4. Selection sort
Show Answer and Explanation

Correct answer: C. Merge sort

Merge sort recursively divides and merges, producing n log n work.

Next Question →

Practice Set 9 · Question 89 of 150

Question 89. What input commonly triggers Θ(n²) work for standard insertion sort?

  1. All values equal with strict comparison
  2. A single element
  3. Already ascending
  4. Reverse sorted
Show Answer and Explanation

Correct answer: D. Reverse sorted

Each new element must shift past nearly all previously seen values.

Next Question →

Practice Set 9 · Question 90 of 150

Question 90. A chained hash table has 18 keys and 12 buckets. What is its load factor?

  1. 30
  2. 0.67
  3. 1.5
  4. 6
Show Answer and Explanation

Correct answer: C. 1.5

Load factor is keys divided by buckets: 18/12=1.5.

Continue to Practice Set 10

Practice Set 10 · Question 91 of 150

Question 91. What is a collision in hashing?

  1. Two distinct keys map to the same bucket
  2. A key has length zero
  3. A tree has one child
  4. Two values are sorted
Show Answer and Explanation

Correct answer: A. Two distinct keys map to the same bucket

A hash function can map different keys to one bucket.

Next Question →

Practice Set 10 · Question 92 of 150

Question 92. In a BST with distinct integer keys, what order does inorder traversal produce?

  1. Descending
  2. Increasing
  3. Insertion order
  4. Unspecified random
Show Answer and Explanation

Correct answer: B. Increasing

The left-root-right traversal follows the BST key ordering.

Next Question →

Practice Set 10 · Question 93 of 150

Question 93. For a min-heap, where is one smallest key always located?

  1. Root
  2. Rightmost leaf
  3. Any internal node
  4. Last array cell
Show Answer and Explanation

Correct answer: A. Root

The heap-order property places a minimum at the root.

Next Question →

Practice Set 10 · Question 94 of 150

Question 94. An undirected graph has 7 edges. What is the sum of its vertex degrees?

  1. 21
  2. 49
  3. 7
  4. 14
Show Answer and Explanation

Correct answer: D. 14

Each edge contributes two to the sum of degrees.

Next Question →

Practice Set 10 · Question 95 of 150

Question 95. Which algorithmic technique underlies topological sorting using indegree counts?

  1. Backtracking over all permutations
  2. Dijkstra relaxation
  3. Kahn’s algorithm
  4. Binary search
Show Answer and Explanation

Correct answer: C. Kahn’s algorithm

Kahn’s algorithm repeatedly selects vertices with indegree zero, removes their outgoing edges, and produces a topological order when the graph is acyclic.

Next Question →

Practice Set 10 · Question 96 of 150

Question 96. Which algorithm gives shortest paths by number of edges in an unweighted graph?

  1. DFS always
  2. BFS
  3. Selection sort
  4. Linear search
Show Answer and Explanation

Correct answer: B. BFS

Breadth-first search explores vertices by distance layers.

Next Question →

Practice Set 10 · Question 97 of 150

Question 97. In a dense graph with V vertices, what space does a conventional adjacency matrix use?

  1. O(V)
  2. O(E) only
  3. O(V²)
  4. O(log V)
Show Answer and Explanation

Correct answer: C. O(V²)

Its V by V entries require quadratic storage.

Next Question →

Practice Set 10 · Question 98 of 150

Question 98. Which algorithm processes keys digit by digit, commonly relying on stable passes?

  1. Radix sort
  2. Selection sort
  3. BFS
  4. Binary search
Show Answer and Explanation

Correct answer: A. Radix sort

Radix sort sorts keys by individual digits or positions.

Next Question →

Practice Set 10 · Question 99 of 150

Question 99. What is a practical limitation of counting sort?

  1. It must compare every pair of keys
  2. It cannot handle repeated keys
  3. It must use recursion
  4. A very large key range may use excessive memory
Show Answer and Explanation

Correct answer: D. A very large key range may use excessive memory

Counting sort uses an array sized to the key range.

Next Question →

Practice Set 10 · Question 100 of 150

Question 100. What does stable sorting preserve?

  1. Array capacity
  2. Relative order of records having equal keys
  3. The original order of all records
  4. Always the smallest element’s position
Show Answer and Explanation

Correct answer: B. Relative order of records having equal keys

Equal-key elements keep their original relative ordering.

Continue to Practice Set 11

Practice Set 11 · Question 101 of 150

Question 101. Which algorithm computes shortest paths from a source in graphs with nonnegative edge weights?

  1. Topological sort alone
  2. Dijkstra’s algorithm
  3. Prim’s algorithm
  4. DFS alone
Show Answer and Explanation

Correct answer: B. Dijkstra’s algorithm

Dijkstra’s greedy relaxation is correct for nonnegative weights.

Next Question →

Practice Set 11 · Question 102 of 150

Question 102. A directed acyclic graph has edges A→C and B→C. Which sequence is a valid topological order?

  1. C, A, B
  2. A, C, B
  3. B, C, A
  4. B, A, C
Show Answer and Explanation

Correct answer: D. B, A, C

Both A and B must occur before C. The order B, A, C respects both directed edges.

Next Question →

Practice Set 11 · Question 103 of 150

Question 103. Which common graph representation is typically more memory-efficient for sparse graphs?

  1. Adjacency lists
  2. Dense adjacency matrices
  3. A V×V matrix with 1s
  4. A full pairwise distance matrix
Show Answer and Explanation

Correct answer: A. Adjacency lists

Adjacency lists store vertices and actual edges, taking O(V+E) space.

Next Question →

Practice Set 11 · Question 104 of 150

Question 104. What does a topological sorting algorithm do when it detects a directed cycle?

  1. Delete every edge automatically
  2. Convert the graph into an undirected one
  3. Report that a full topological ordering is impossible
  4. Output any permutation as valid
Show Answer and Explanation

Correct answer: C. Report that a full topological ordering is impossible

Every directed cycle creates contradictory precedence requirements.

Next Question →

Practice Set 11 · Question 105 of 150

Question 105. Which balancing scheme uses red and black node colours to constrain BST height?

  1. Unbalanced BST
  2. Trie with no ordering
  3. Binary heap
  4. Red-black trees
Show Answer and Explanation

Correct answer: D. Red-black trees

Red-black invariants keep the height logarithmic.

Next Question →

Practice Set 11 · Question 106 of 150

Question 106. What is the worst-case search complexity of an AVL tree with n nodes?

  1. O(n)
  2. O(log n)
  3. O(1)
  4. O(n²)
Show Answer and Explanation

Correct answer: B. O(log n)

Height-balancing maintains logarithmic tree height.

Next Question →

Practice Set 11 · Question 107 of 150

Question 107. What is the main purpose of garbage collection?

  1. Find shortest paths
  2. Encrypt stack frames
  3. Reclaim memory that is no longer reachable or needed
  4. Sort keys into ascending order
Show Answer and Explanation

Correct answer: C. Reclaim memory that is no longer reachable or needed

Garbage collectors reclaim unused managed allocations according to their reachability/liveness model.

Next Question →

Practice Set 11 · Question 108 of 150

Question 108. What is a trie particularly suited for?

  1. Prefix-based string lookup
  2. General integer multiplication
  3. Matrix inversion only
  4. Heap extraction
Show Answer and Explanation

Correct answer: A. Prefix-based string lookup

Trie edges commonly encode successive symbols of keys, supporting prefix queries.

Next Question →

Practice Set 11 · Question 109 of 150

Question 109. Why do cache-friendly contiguous arrays often outperform linked lists in sequential scans?

  1. Spatial locality reduces memory-access overhead
  2. Arrays always require fewer comparisons
  3. Lists cannot contain integers
  4. Arrays have no bounds
Show Answer and Explanation

Correct answer: A. Spatial locality reduces memory-access overhead

Nearby array elements tend to benefit from cache locality.

Next Question →

Practice Set 11 · Question 110 of 150

Question 110. What property makes an array suitable for constant-time indexed access?

  1. Each element has a next pointer
  2. It is always sorted
  3. Every element is a tree node
  4. Contiguous storage with direct address calculation
Show Answer and Explanation

Correct answer: D. Contiguous storage with direct address calculation

Array indexing computes an element address from its index under the standard array model.

Next Question →

Practice Set 12 · Question 111 of 150

Question 111. When is a dynamic array likely to reallocate its storage?

  1. When an insertion exceeds current capacity
  2. Every time an element is read
  3. Only when all elements are equal
  4. Whenever binary search is used
Show Answer and Explanation

Correct answer: A. When an insertion exceeds current capacity

Growing past capacity may require allocating a larger contiguous block.

Next Question →

Practice Set 12 · Question 112 of 150

Question 112. What is amortized analysis used to describe?

  1. The number of graph vertices only
  2. Average cost per operation over a sequence of operations
  3. Only worst-case input size
  4. Memory addresses of stack frames
Show Answer and Explanation

Correct answer: B. Average cost per operation over a sequence of operations

Amortized bounds spread occasional costly steps across many operations.

Next Question →

Practice Set 12 · Question 113 of 150

Question 113. What is a circular linked list?

  1. An always sorted array
  2. A graph without vertices
  3. A linked list whose final node links back into the list
  4. A list with no links
Show Answer and Explanation

Correct answer: C. A linked list whose final node links back into the list

In a circular list the final link returns to a node, commonly the head.

Next Question →

Practice Set 12 · Question 114 of 150

Question 114. Why can linked lists be less cache-friendly than arrays?

  1. They always have fewer nodes
  2. They cannot store values
  3. They require a sorted key
  4. Successive nodes may be scattered in memory
Show Answer and Explanation

Correct answer: D. Successive nodes may be scattered in memory

Noncontiguous nodes often cause poorer spatial locality.

Next Question →

Practice Set 12 · Question 115 of 150

Question 115. What is stack underflow?

  1. Attempting to remove an item from an empty stack
  2. Adding an item to a nonfull stack
  3. A successful search
  4. An extra hash collision
Show Answer and Explanation

Correct answer: A. Attempting to remove an item from an empty stack

A pop on an empty stack cannot return a valid stored item.

Next Question →

Practice Set 12 · Question 116 of 150

Question 116. What is queue overflow in a bounded queue?

  1. A successful enqueue
  2. Attempting to insert when the queue is full
  3. Removing the last available item
  4. Moving the front pointer
Show Answer and Explanation

Correct answer: B. Attempting to insert when the queue is full

A capacity-limited queue needs to handle an enqueue with no free slot.

Next Question →

Practice Set 12 · Question 117 of 150

Question 117. What does a queue’s front operation usually do?

  1. Remove every element
  2. Reverse all entries
  3. Inspect the next item without removing it
  4. Sort the entire queue
Show Answer and Explanation

Correct answer: C. Inspect the next item without removing it

Front or peek returns the item scheduled to leave next.

Next Question →

Practice Set 12 · Question 118 of 150

Question 118. Which data structure is naturally used by an event scheduler based on event times?

  1. Unordered stack
  2. Unsorted singly linked list only
  3. Fixed integer variable
  4. Priority queue
Show Answer and Explanation

Correct answer: D. Priority queue

A priority queue efficiently selects the event with the earliest scheduled time.

Next Question →

Practice Set 12 · Question 119 of 150

Question 119. What is the primary requirement of a balanced binary search tree?

  1. Its height remains controlled relative to the number of nodes
  2. Every node has exactly two children
  3. All keys are equal
  4. It contains no references
Show Answer and Explanation

Correct answer: A. Its height remains controlled relative to the number of nodes

Balancing avoids the linear-height degeneration of ordinary BSTs.

Next Question →

Practice Set 12 · Question 120 of 150

Question 120. What does an AVL rotation maintain?

  1. The tree is converted to a hash table
  2. Binary search ordering while restoring height balance
  3. All key values become equal
  4. Every node becomes a root
Show Answer and Explanation

Correct answer: B. Binary search ordering while restoring height balance

AVL rotations locally restructure links without changing sorted key order.

Next Question →

Practice Set 13 · Question 121 of 150

Question 121. What is a graph’s adjacency list?

  1. Only the vertex degrees
  2. A sorted array of weights only
  3. For each vertex, a collection of its neighbors
  4. A matrix of every possible path
Show Answer and Explanation

Correct answer: C. For each vertex, a collection of its neighbors

Adjacency lists store edges by listing neighbors at each vertex.

Next Question →

Practice Set 13 · Question 122 of 150

Question 122. What is a connected component of an undirected graph?

  1. One directed edge only
  2. A graph’s maximum weight
  3. A sorting pass
  4. A maximal set of mutually reachable vertices
Show Answer and Explanation

Correct answer: D. A maximal set of mutually reachable vertices

Every pair of vertices within a connected component is joined by a path.

Next Question →

Practice Set 13 · Question 123 of 150

Question 123. How can DFS be used to detect a cycle in an undirected graph?

  1. Find an edge to a visited vertex other than the current parent
  2. Check only the number of vertices
  3. Require every degree to be one
  4. Always return true for trees
Show Answer and Explanation

Correct answer: A. Find an edge to a visited vertex other than the current parent

During undirected DFS, such a non-parent visited neighbor indicates a cycle.

Next Question →

Practice Set 13 · Question 124 of 150

Question 124. What is a spanning tree of a connected undirected graph?

  1. A shortest path only
  2. A connected acyclic subgraph containing all vertices
  3. The set of all edges
  4. A graph containing only one vertex
Show Answer and Explanation

Correct answer: B. A connected acyclic subgraph containing all vertices

A spanning tree connects every vertex using exactly V−1 edges.

Next Question →

Practice Set 13 · Question 125 of 150

Question 125. Which classical algorithm constructs a minimum spanning tree using edge weights in increasing order?

  1. Insertion sort alone
  2. Fibonacci recursion
  3. Kruskal’s algorithm
  4. Binary search
Show Answer and Explanation

Correct answer: C. Kruskal’s algorithm

Kruskal processes candidate edges by weight while avoiding cycles.

Next Question →

Practice Set 13 · Question 126 of 150

Question 126. Which data structure is commonly used by Kruskal’s algorithm to track components?

  1. A postfix stack only
  2. A hash string only
  3. An array of source filenames
  4. Disjoint-set union
Show Answer and Explanation

Correct answer: D. Disjoint-set union

Union-find efficiently determines whether two endpoints are already connected.

Next Question →

Practice Set 13 · Question 127 of 150

Question 127. What is path compression in a disjoint-set forest?

  1. Making nodes point closer to the representative during find
  2. Deleting every root
  3. Sorting values in every component
  4. Reversing all graph edges
Show Answer and Explanation

Correct answer: A. Making nodes point closer to the representative during find

Path compression flattens parent links and improves future find operations.

Next Question →

Practice Set 13 · Question 128 of 150

Question 128. Why is a min-heap often used with Dijkstra’s algorithm?

  1. To convert edges into a tree before search
  2. To extract a vertex with the smallest tentative distance
  3. To detect all negative cycles automatically
  4. To guarantee all weights are integers
Show Answer and Explanation

Correct answer: B. To extract a vertex with the smallest tentative distance

A priority queue supports efficient selection of the smallest tentative distance.

Next Question →

Practice Set 13 · Question 129 of 150

Question 129. Which graph algorithm can handle negative edge weights and detect reachable negative cycles?

  1. Standard Dijkstra without modification
  2. Selection sort
  3. Bellman-Ford
  4. Ordinary BFS
Show Answer and Explanation

Correct answer: C. Bellman-Ford

Bellman-Ford relaxes edges repeatedly and checks for reachable negative cycles.

Next Question →

Practice Set 13 · Question 130 of 150

Question 130. When can a shortest path be undefined due to negative weights?

  1. When the graph has more than ten vertices
  2. Whenever there is a queue
  3. When every edge weight is positive
  4. When a reachable negative cycle can lead to the destination
Show Answer and Explanation

Correct answer: D. When a reachable negative cycle can lead to the destination

Repeated traversal of a relevant negative cycle can reduce path cost without bound.

Next Question →

Practice Set 14 · Question 131 of 150

Question 131. What is a hash function used for in a hash table?

  1. Map keys to hash values or bucket locations
  2. Guarantee unique output for every key
  3. Balance a binary tree
  4. Find shortest graph paths
Show Answer and Explanation

Correct answer: A. Map keys to hash values or bucket locations

A hash function determines where to seek a key, with collisions handled separately.

Next Question →

Practice Set 14 · Question 132 of 150

Question 132. Why does a high load factor often slow a chained hash table?

  1. Every value is deleted
  2. More entries tend to occupy each bucket
  3. All keys become invalid
  4. The number of buckets doubles automatically
Show Answer and Explanation

Correct answer: B. More entries tend to occupy each bucket

Longer chains can increase expected search work.

Next Question →

Practice Set 14 · Question 133 of 150

Question 133. What does rehashing usually involve?

  1. Deleting all stored values
  2. Sorting every key lexicographically
  3. Reassigning entries into a new bucket arrangement
  4. Converting every entry to a tree node
Show Answer and Explanation

Correct answer: C. Reassigning entries into a new bucket arrangement

After changing capacity or hashing parameters, keys are redistributed into buckets.

Next Question →

Practice Set 14 · Question 134 of 150

Question 134. What is the worst-case time of a hash-table lookup without favorable distribution assumptions?

  1. Always O(1)
  2. Always O(log log n)
  3. O(2^n) exactly
  4. O(n)
Show Answer and Explanation

Correct answer: D. O(n)

Pathological collisions can force examination of many entries.

Next Question →

Practice Set 14 · Question 135 of 150

Question 135. Which sorting algorithm repeatedly swaps adjacent out-of-order items?

  1. Bubble sort
  2. Merge sort
  3. Counting sort
  4. Radix sort
Show Answer and Explanation

Correct answer: A. Bubble sort

Bubble sort scans neighboring pairs and swaps them when needed.

Next Question →

Practice Set 14 · Question 136 of 150

Question 136. Which sorting algorithm partitions data around a pivot?

  1. Selection sort
  2. Quicksort
  3. Insertion sort
  4. Counting sort
Show Answer and Explanation

Correct answer: B. Quicksort

Quicksort recursively orders elements relative to a pivot.

Next Question →

Practice Set 14 · Question 137 of 150

Question 137. Why is stable sorting useful for records with multiple keys?

  1. It always runs in O(n)
  2. It cannot reorder any element
  3. It preserves earlier ordering among equal keys
  4. It guarantees the smallest memory use
Show Answer and Explanation

Correct answer: C. It preserves earlier ordering among equal keys

Stability enables sorting by secondary and then primary keys.

Next Question →

Practice Set 14 · Question 138 of 150

Question 138. What does breadth-first traversal of a rooted tree visit first?

  1. Only leaves
  2. The rightmost path exclusively
  3. Nodes by key size in every tree
  4. Nodes at smaller depths
Show Answer and Explanation

Correct answer: D. Nodes at smaller depths

BFS visits the root and then successive depth levels.

Next Question →

Practice Set 14 · Question 139 of 150

Question 139. Which tree traversal visits the root before either subtree?

  1. Preorder
  2. Inorder
  3. Postorder
  4. Reverse inorder only
Show Answer and Explanation

Correct answer: A. Preorder

Preorder processes root, then left and right subtrees.

Next Question →

Practice Set 14 · Question 140 of 150

Question 140. What is a binary tree’s height in edges?

  1. The sum of node keys
  2. The maximum number of edges on a root-to-leaf path
  3. The number of leaves
  4. The root’s degree only
Show Answer and Explanation

Correct answer: B. The maximum number of edges on a root-to-leaf path

Height measures the longest downward path from the root.

Next Question →

Practice Set 15 · Question 141 of 150

Question 141. What is the maximum number of nodes at level d in a binary tree if the root is level 0?

  1. 2d+1
  2. d²
  3. 2^d
  4. d+1
Show Answer and Explanation

Correct answer: C. 2^d

Each binary level can double the number of nodes, giving at most 2^d.

Next Question →

Practice Set 15 · Question 142 of 150

Question 142. How many edges does a tree with 12 vertices contain?

  1. 12
  2. 13
  3. 24
  4. 11
Show Answer and Explanation

Correct answer: D. 11

Every finite tree with V vertices has V−1 edges.

Next Question →

Practice Set 15 · Question 143 of 150

Question 143. What is a trie node commonly associated with?

  1. A prefix of stored keys
  2. A weighted graph’s diameter
  3. Only a heap maximum
  4. A sorting pivot
Show Answer and Explanation

Correct answer: A. A prefix of stored keys

Paths from the root encode successive symbols and their prefixes.

Next Question →

Practice Set 15 · Question 144 of 150

Question 144. What is a suffix of a string?

  1. The length of an array
  2. A contiguous portion ending at the string’s last character
  3. Any unordered subset of characters
  4. A prefix only
Show Answer and Explanation

Correct answer: B. A contiguous portion ending at the string’s last character

A suffix begins at some position and continues to the end of the string.

Next Question →

Practice Set 15 · Question 145 of 150

Question 145. Which abstract data type supports insert, delete and find-min operations?

  1. Fixed Boolean
  2. Recursion stack only
  3. Min-priority queue
  4. Read-only array
Show Answer and Explanation

Correct answer: C. Min-priority queue

A min-priority queue maintains items to retrieve and remove the minimum.

Next Question →

Practice Set 15 · Question 146 of 150

Question 146. How many vertex-degree units does an undirected edge contribute overall?

  1. 1
  2. 0
  3. 4
  4. 2
Show Answer and Explanation

Correct answer: D. 2

Each undirected edge contributes one to each endpoint degree, counting loops twice.

Next Question →

Practice Set 15 · Question 147 of 150

Question 147. Which condition is necessary for an undirected graph to have an Euler circuit?

  1. Every vertex with a nonzero degree lies in one component and every vertex has even degree
  2. Exactly three vertices have odd degree
  3. Every edge has a unique weight
  4. It has no cycle
Show Answer and Explanation

Correct answer: A. Every vertex with a nonzero degree lies in one component and every vertex has even degree

A connected edge-containing component with all even degrees admits an Euler circuit.

Next Question →

Practice Set 15 · Question 148 of 150

Question 148. What is the time complexity of BFS using adjacency lists for a graph with V vertices and E edges?

  1. O(2^V)
  2. O(V+E)
  3. O(V²E)
  4. O(1)
Show Answer and Explanation

Correct answer: B. O(V+E)

BFS processes vertices and scans their adjacency lists, totaling O(V+E).

Next Question →

Practice Set 15 · Question 149 of 150

Question 149. Why are dynamic programming tables useful?

  1. They eliminate all space use
  2. They guarantee constant-time algorithms
  3. They store solutions of subproblems to avoid repeated computation
  4. They require every problem to be a graph
Show Answer and Explanation

Correct answer: C. They store solutions of subproblems to avoid repeated computation

Memoization or tabulation reuses results of overlapping subproblems.

Next Question →

Practice Set 15 · Question 150 of 150

Question 150. What is memoization?

  1. Deleting cached values immediately
  2. Sorting a graph’s adjacency matrix
  3. Repeatedly computing the same result without storage
  4. Caching results of previously solved subproblems
Show Answer and Explanation

Correct answer: D. Caching results of previously solved subproblems

Memoization trades storage for avoiding redundant computation.

Restart from Question 1

Return to the full course materials and worked examples