Data Structures & AlgorithmsHardWipro · Accenture pattern
Among insertion sort, merge sort, heap sort, quick sort, bubble sort and selection sort (standard array versions), how many are BOTH stable and in-place (O(1) extra space)?
- A. Four
- B. Three
- C. Two
- D. One
Correct answer: C. Two
Insertion sort and bubble sort are both. Merge sort is stable but needs O(n) extra space; heap sort and quick sort are in-place but not stable; selection sort's long-distance swap breaks stability.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- LSD radix sort (base 10, stable counting sort per digit) is applied to [170, 45, 75, 90, 802, 24, 2, 66]. What is the array after the…
- What does this function return for a = [1, 3, 3, 3, 5, 7] with x = 3 and with x = 4? python def g(a, x): lo, hi = 0, len(a) - 1 while lo <…
- while (lo <= hi) binary search runs on a sorted array of 31 elements for a key LARGER than every element. How many times does the loop…
- A dynamic array starts with capacity 1 and doubles its capacity (copying all current elements) whenever an insert finds it full. How many…
- A stack-based checker is run on four strings. Which one is balanced?
- A circular queue in an array of size 6 uses front (index of the first item) and rear (index of the next free slot), both starting at 0…