1.

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 loopI had been asked this question in quiz.The query is from Sorting topic in chapter Sorting of Data Structures & Algorithms II

Answer»

Right answer is (a) Single loop

The best I can explain: 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.



Discussion

No Comment Found

Related InterviewSolutions