How many loops are required to implement gnome sorting algorithm?

Thanh Thảo

New member
How many loops are required to implement gnome sorting algorithm?
A. Single loop
B. 2 nested loops
C. 3 nested loops
D. It does not require any loop
 
Answer: a
Explanation: In this sorting algorithm the variable representing the index number is not incremented in case the adjacent pair of elements are out of place. In such a case its value is decremented instead. Thus it is able to implement sorting using a single loop.
 

Tìm kiếm

Back
Top