Computer Science EngineeringVery hard
After one complete left-to-right bubble sort pass over [5, 1, 4, 2, 8], the array is
- A. 1 4 2 5 8
- B. 1 5 4 2 8
- C. 1 2 4 5 8
- D. 1 4 2 8 5
Correct answer: A. 1 4 2 5 8
5 is swapped past 1, 4 and 2, then compared with 8 and stays, leaving 1 4 2 5 8.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- The maximum number of swaps performed by selection sort on n elements is
- Appending n elements one at a time to a dynamic array that doubles its capacity when full costs, per append, an amortized
- With open addressing and uniform hashing, the expected number of probes in an unsuccessful search is at most 1/(1-alpha). What is this…
- A connected undirected graph has 9 vertices and 12 edges. Its cyclomatic number (number of independent cycles) is
- How much extra space does reversing a singly linked list in place (iteratively) require?
- A queue starts empty. Operations: enqueue 1, enqueue 2, enqueue 3, dequeue, enqueue 4, dequeue, enqueue 5. Which element is now at the…