Quick Quiz — Binary Search

Binary search requires which of the following preconditions?

Interactive: Binary Search Visualization

Quick Quiz — BST

When inserting a value equal to an existing node, the implementation above places it to which side (as written)?

Interactive: Binary Search Tree

Quick Quiz — Heap

In a 0-based array representation of a binary heap, the left child index for node i is:

Interactive: Heap Sort Visualization

Quick Quiz — Merge Sort

Which property is true for merge sort?

Interactive: Merge Sort Visualization

Algorithm Comparison

Algorithm Time Complexity Space Complexity Stable
Linear Search O(n) O(1) N/A
Binary Search O(log n) O(1) N/A
Heap Sort O(n log n) O(1) No
Merge Sort O(n log n) O(n) Yes

Heapsort is in-place, merge sort needs extra space but is stable.

Closing Quiz

Which algorithm guarantees O(n log n) worst-case time?

Summary

  • Binary search provides O(log n) search in sorted arrays
  • Binary search trees maintain sorted order with dynamic operations
  • Heap sort builds on heap data structure for efficient sorting
  • Merge sort uses divide-and-conquer strategy with guaranteed O(n log n)
  • All implementations shown without classes, using functions and structs