Vidyalelo
Data Structure · Q117

Sorting Algorithms

Programming · Data Structure · question 117

Q117

The following function represents which sorting? void Sorting(int a[], int n) bool swap = true; int first = 0; int last = n - 1; while (swap) swap = false; for (int i = first; i a[i + 1]) swap(a[i], a[i + 1]); swap = true; if (!swap) break; swap = false; --last; for (int i = last - 1; i >= first; i--) if (a[i] > a[i + 1]) swap(a[i], a[i + 1]); swap = true; ++first;

A.
Bubble sort
B.
Selection sort
C.
Bidirectional bubble sort
Answer
D.
Odd-even sort

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board