ExamVeda
Login
Home
This question belongs to Data Structure Sorting Algorithms
Sorting Algorithms
?

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 < last;i++)
                { 
			if (a[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; 
	} 
}

Answer & Solution
Correct Answer: Option C
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.