CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
3
You visited us 3 times! Enjoying our articles? Unlock Full Access!
Question

Consider a new sorting algorithm similar to the bubble sort algorithm, called Rumble Sort. Given an array as input, Rumble Sort attempts to sort the array and produces a sorted array as output. Here' s the pseudocode for RumbleSort (L).

Rumblesort(L):
let sorted = false
while not sorted:
sorted = true
for i = 0; i < len (L) - 2; i + + ;
if L(i) > L [i + 2];
sorted = false
reverse the given list from L(i) to L [i + 2] (unclusive).

Consider running RumblesSort on the following inputs.
(i) [5 6 8 4 3]
(ii) [5 6 4 8 3]
(iii) [3 4 8 6 5]
(iv) [5 4 8 6 3 ]

For how many of the inputs, does RumbleSort produce the correct sorted array?

A
3
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
1
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
2
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
4
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Join BYJU'S Learning Program
CrossIcon