Searching and sorting: practice questions
Class 12 Computer Science. Ten questions with step-by-step answers, for CBSE and ICSE. Try each one before you open its answer.
Key ideas
- Binary search and bubble sort.
- These are the multi-step questions examiners like to set. Read each one twice, write down what you know, then plan before you calculate.
- These go beyond the syllabus. Each one has a neat idea that makes it short; brute force is slow.
Read each question twice and say the answer out loud before you check it. For code or binary questions, work it out on paper step by step, the way a computer would.
Ten questions
1.Worst-case comparisons for binary search in 16 sorted items?
Show the answer
Think: How many halvings to reach 1?
Work: It halves each time: log₂n + 1.
Answer: 5
2.Bubble sort on 4 items: how many passes in the worst case?
Show the answer
Think: The last item is placed automatically.
Work: Each pass fixes one item at the end.
Answer: 3
3.Worst-case comparisons for binary search in 128 sorted items?
Show the answer
Think: How many halvings to reach 1?
Work: It halves each time: log₂n + 1.
Answer: 8
4.Bubble sort on 5 items: how many passes in the worst case?
Show the answer
Think: The last item is placed automatically.
Work: Each pass fixes one item at the end.
Answer: 4
5.Worst-case comparisons for binary search in 32 sorted items?
Show the answer
Think: How many halvings to reach 1?
Work: It halves each time: log₂n + 1.
Answer: 6
6.Bubble sort on 6 items: how many passes in the worst case?
Show the answer
Think: The last item is placed automatically.
Work: Each pass fixes one item at the end.
Answer: 5
7.Worst-case comparisons for binary search in 8 sorted items?
Show the answer
Think: How many halvings to reach 1?
Work: It halves each time: log₂n + 1.
Answer: 4
8.Bubble sort on 8 items: how many passes in the worst case?
Show the answer
Think: The last item is placed automatically.
Work: Each pass fixes one item at the end.
Answer: 7
9.Worst-case comparisons for binary search in 1024 sorted items?
Show the answer
Think: How many halvings to reach 1?
Work: It halves each time: log₂n + 1.
Answer: 11
10.Bubble sort on 7 items: how many passes in the worst case?
Show the answer
Think: The last item is placed automatically.
Work: Each pass fixes one item at the end.
Answer: 6
Before you check an answer
- How many halvings to reach 1?
- The last item is placed automatically.
Questions students ask
- What does Searching and sorting in Class 12 Computer Science cover?
- Binary search and bubble sort. These are the multi-step questions examiners like to set. Read each one twice, write down what you know, then plan before you calculate. These go beyond the syllabus. Each one has a neat idea that makes it short; brute force is slow.
- How should I practise Searching and sorting?
- Read each question twice and say the answer out loud before you check it. For code or binary questions, work it out on paper step by step, the way a computer would. Try all ten questions on this page, then open the chapter in Gradient tuition for step-by-step lessons, a live experiment and an AI tutor who explains where you went wrong.
- Is this for CBSE or ICSE?
- The questions follow the Class 12 Computer Science syllabus shared by CBSE and ICSE / ISC, and suit most state boards too.
Stuck on one of these?
Gradient tuition teaches Searching and sorting step by step, with experiments you can play with and an AI tutor who circles the part of the question you missed.
Open Searching and sorting in tuition