PRACTICE / UNDERSTAND / REPEAT

Data Structures & Algorithms MCQ Practice

Trace arrays, searching, sorting, stacks, trees, graphs, and algorithm complexity.

240 questionsAnswers explainedFree · no login

Put your knowledge to the test.

A random set of up to 10 questions from Data Structures & Algorithms. Your answers stay on this page.

Choose a topic

Try a few questions

Open a topic above to explore the complete question bank.

01 / Heaps · MCQQuestion link ↗

What ordering does a min-heap guarantee?

Choose one answer
Answer & explanation

Answer: Each parent is no greater than its children

The local heap property exposes the minimum at the root without fully sorting the remaining elements.

02 / Heaps · MCQQuestion link ↗

What is the usual worst-case time to peek at the minimum of a nonempty binary min-heap?

Choose one answer
Answer & explanation

Answer: O(1)

The minimum is stored at the root and can be read directly.

03 / Heaps · MCQQuestion link ↗

What is the usual worst-case time for inserting into a binary heap?

Choose one answer
Answer & explanation

Answer: O(log n)

The new element may move up through the tree’s logarithmic height.

04 / Heaps · MCQQuestion link ↗

What is the usual worst-case time for extracting the root from a binary heap?

Choose one answer
Answer & explanation

Answer: O(log n)

After replacing the root, sifting down restores the heap property along at most one root-to-leaf path.

05 / Heaps · MCQQuestion link ↗

What is the time complexity of bottom-up heap construction from an unsorted array?

Choose one answer
Answer & explanation

Answer: O(n)

Most nodes are near leaves and require little repair, making bottom-up heapification linear.

06 / Heaps · MCQQuestion link ↗

Which heap is useful for retaining the largest k values from a stream?

Choose one answer
Answer & explanation

Answer: A min-heap of at most k retained values

The smallest retained candidate is quickly removed when a larger candidate arrives.