sorTIng – important questions for Boards 2027
CBSE Class 12 Computer Science
What is sorting? Give two examples of different orders in which a collection may be sorted. (2 marks)
Answer
Sorting is the process of ordering or arranging a given collection of elements in a particular order. A collection of numbers may be sorted in ascending order, while words may be sorted alphabetically.
Explain why sorting can make searching easier, using the dictionary example. Discuss why the time taken to sort (overhead) may still be worthwhile, and describe two other examples from everyday life where items are sorted. (5 marks)
Answer
Sorting arranges a collection in a particular order, making items easier to locate and use. 1. In an alphabetical dictionary, a word can be found by searching its ordered position. In an unordered dictionary, every page might need to be checked until the word is found. 2. Sorting a large number of items takes time, called overhead, but that extra time is worthwhile compared with the time required to find an element in an unsorted list. 3. Examination-hall seats are arranged according to candidates’ roll numbers, helping candidates identify their assigned seats. 4. A list of students may be arranged by height or weight, making comparisons and locating students with a particular measurement easier. Thus, sorting organizes information and reduces the effort needed to search or use it.
How does bubble sort use adjacent comparisons and swaps to sort a list? (2 marks)
Answer
Bubble sort repeatedly compares adjacent elements, swapping a pair when it is unordered. Each pass moves the largest remaining element towards its correct position at the end of the list, increasing the sorted portion.
Define a pass in bubble sort. For a list of n elements, state the number of passes made by the standard algorithm and explain what happens to the largest remaining element during each pass. (5 marks)
Answer
Bubble sort repeatedly compares adjacent elements and swaps them when they are unordered. 1. A pass is one iteration through the elements of a list. During a pass, the required pairs of adjacent elements are compared. 2. For a list containing n elements, the standard bubble sort algorithm makes n – 1 passes to sort the list. 3. When arranging the list in ascending order, each comparison moves a larger element towards the end whenever the adjacent pair is unordered. By the end of a pass, the largest element among those still unsorted reaches its correct position. 4. That element is not considered in the remaining passes, so the portion still requiring sorting becomes smaller after each pass. Thus, successive passes place the largest remaining elements in their final positions until the list is sorted.
How does selection sort divide a list into sorted and unsorted portions at the start of the sorting process? (2 marks)
Answer
Initially, selection sort divides the list into two portions: an empty left list of sorted elements and a right list containing all n unsorted elements. During ascending sorting, each selected smallest element joins the sorted portion.
Describe how one pass of bubble sort proceeds to sort a list in ascending order, including how adjacent elements are compared and when they are swapped. Explain how the pass reduces the unsorted portion and how the algorithm can stop early. (5 marks)
Answer locked. Unlock all answers on SmartKalike
Explain how insertion sort divides a list and places each unsorted element into the sorted portion. (2 marks)
Answer locked. Unlock all answers on SmartKalike
For ascending insertion sort, explain how the next unsorted element is compared with the sorted portion from right to left, and how larger elements are shifted to make space for it. (5 marks)
Answer locked. Unlock all answers on SmartKalike
What is the time complexity of an algorithm? State what complexity analysis helps explain as input size grows. (2 marks)
Answer locked. Unlock all answers on SmartKalike
Describe how the insertion-sort process continues pass by pass until the list is ascending. Include the roles of index 1 and temp, the shifting of larger preceding items, and the insertion of temp into its position. (5 marks)
Answer locked. Unlock all answers on SmartKalike
5 more probable questions in this chapter, every one with a full answer.
Unlock all answers on SmartKalike