1.

In School Assembly, try to arrange all the students in your class according to the increasing order of their heights separately for male/female students. Smallest one will be in front and tallest one at the last position. Write sequential steps for doing this, in two different methods.

Answer»

Arranging elements from smallest to largest (ascending) or largest to smallest(descending) is called sorting. 

There are two sorting methods 

1. Bubble sort: 

It is a simple sorting method. In this sorting considering two adjacent elements if it is out of order, the elements are interchanged. After the first iteration the largest(in the case of ascending sorting) or smallest(in the case of descending sorting) will be the end of the array. This process continues.

 2. Selection sort:

In selection sort the array is divided into two parts, the sorted part and unsorted part. First smallest element in the unsorted part is searched and exchanged with the first element. Now there is 2 parts sorted part and unsorted part. This process continues.



Discussion

No Comment Found

Related InterviewSolutions