GATE DA 2026 — Question 58

Programming, Data Structures and Algorithmsbasic sorting algorithms: selection sort, bubble sort and insertion sortNAT2 marksMedium

Consider the given Python program.
python
1def fun(L, i=0):
2    if i >= len(L)-1:
3        return 0
4    if L[i] > L[i+1]:
5        L[i+1], L[i] = L[i], L[i+1]
6        return 1+fun(L, i+1)
7    else:
8        return fun(L, i+1)
9data = [5, 3, 4, 1, 2]
10count = 0
11for _ in range(len(data)):
12    count += fun(data)
13print(count)
14
The output of the program is __________ . (Answer in integer)
Practise the full 2026 paper
Challenge a friend: WhatsApp Telegram
From RENYXERAThis week's 10-question challengeSame 10 past-GATE questions for everyone this week — see where you stand.
Practise more on basic sorting algorithms: selection sort, bubble sort and insertion sortTimed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group