Sorting questions

Q33

GATE CS 2025 CS-1Searching Sorting and HashingNAT1 mark
The pseudocode of a function fun() is given below:
fun(int A[0,\dots,n-1]){
 for i=0 to n-2
 for j=0 to n-i-2
 if (A[j]>A[j+1])
 then swap A[j] and A[j+1]
}
Let A[0,…,29]A[0, \dots, 29] be an array storing 30 distinct integers in descending order. The number of swap operations that will be performed, if the function fun() is called with A[0,…,29]A[0, \dots, 29] as argument, is __________. (Answer in integer)
Show answer without attempting

Answer: 435

0/10 correct0 marks

Related topics in Searching Sorting and Hashing