Binary search requires which of the following preconditions?
When inserting a value equal to an existing node, the implementation above places it to which side (as written)?
In a 0-based array representation of a binary heap, the left child index for node i is:
Which property is true for merge sort?
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.
Which algorithm guarantees O(n log n) worst-case time?