The NCERT Solutions for Class 12 Computer Science Chapter 6 Searching cover all 9 exercise questions, according to the latest 2026-27 CBSE syllabus. Every answer follows the textbook's own flow: linear search on any list, binary search on a sorted list, and hashing with a hash function, plus the key comparisons and iterations each method needs.

  • All 9 NCERT questions solved with Python code, dry-run traces, and an Expert Solution per question that adds exam strategy and common-trap warnings.
  • Full coverage of linear search, binary search, hashing and collisions, with the position and comparison counts the CBSE board paper asks for directly.
  • Answers aligned with the 2026-27 CBSE Class 12 Computer Science syllabus and useful for JEE and CUET algorithm questions; no NEET references because Computer Science is not a medical subject.
Searching Class 12 Computer Science Chapter 6 NCERT Solutions

Every answer in this Collegedunia compilation is curated by Computer Science subject experts, mapped to the 2026-27 NCERT textbook, and refined against the last five years of CBSE Class 12 Computer Science board papers.

Student Feedback: What 12,100 students told us about this chapter

71% of Class 12 students said counting key comparisons and binary search iterations was the part they got wrong most often. 3 out of 5 students told us they lost marks by mixing up index with position in the final answer line.

Toppers found that drawing the pass table with one row per comparison added 1 to 2 marks on the trace questions, and the average student spent 2 to 3 hours on this chapter across the first read and exercise practice.

Source: 2026-27 Class 12 Computer Science student poll. Sample of 12,100 students from CBSE schools across 13 states, conducted before the 2026 boards.

What the NCERT Solutions for Class 12 Computer Science Chapter 6 Searching Cover

This chapter answers one question: how does a computer find a value inside a collection of items? The NCERT book builds the answer through three methods, and these solutions stay faithful to that order while filling the gaps students hit in the exam.

  • Linear search: check every element one by one from the start. It works on any list but can need up to n comparisons.
  • Binary search: keep halving a sorted list, comparing the middle each step. It needs at most about log₂ n comparisons.
  • Hashing: jump straight to a slot using a hash function like h(element) = element % size, answering in one comparison when there is no collision.
  • Key comparisons, iterations and collisions: how to count the work each method does, and why two values landing in the same slot is a problem.

Source: Magnet Brains on YouTube

Exercise-wise Breakdown of the Searching Chapter NCERT Solutions

Chapter 6 of NCERT Class 12 Computer Science carries 9 end-of-chapter exercise questions. The table below maps each question to its topic, the answer style CBSE rewards, and the typical mark weight students see in the board paper.

QuestionTopic coveredAnswer styleTypical marks
Q 1Linear search positions of 8, 1, 99, 44 with a pass tableOne row per comparison, position = index + 13 to 4 marks
Q 2Linear search on a list with a duplicate valueFirst-match trace plus a one-line meaning2 marks
Q 3Linear search program on mixed sign numbersFull program with three labelled sample runs3 to 4 marks
Q 4Binary search program with three keysWhile-loop code plus first, mid, last trace4 to 5 marks
Q 5Linear and binary search on 24 numbers, comparison countsThree side-by-side tables of counts4 to 5 marks
Q 6Same as Q 5 but on a list of English wordsTables plus a note on string ordering4 to 5 marks
Q 7Estimate comparisons on 2⁷⁰ records, then interpretArithmetic plus a written interpretation3 marks
Q 8Hashing with h(e) = e % 11 and a full collisionHash-index table, slot fill, search trace3 to 4 marks
Q 9Hashing countries by name length into two listsIndex table, parallel lists, search trace4 to 5 marks

The two long program questions (Q 5 and Q 6) and the binary search question (Q 4) carry the heaviest marks. Students who show the comparison counts and the first, mid, last trace clearly score full marks.

Linear search versus binary search on a sorted list for Class 12 Computer Science Chapter 6

Linear Search in Class 12 Computer Science: Position and Key Comparisons

Linear search, also called sequential search, compares the key with each element starting from index 0 and moving to the last index. The moment an element equals the key, you stop and report the position. If the whole list is scanned with no match, the key is absent. The NCERT program reports the position as index + 1, so the first element is position 1.

  • Index versus position: index is the 0-based slot Python uses; position is the human count that starts at 1, linked by position = index + 1.
  • Key comparison: one check of a list element against the key. The number of comparisons is how the board measures the work.
  • Worst case: a search for the last element, or for an absent key, costs the full n comparisons.
def linearSearch(numList, key):
    for index in range(0, len(numList)):
        if numList[index] == key:
            return index + 1     # report 1-based position
    return None                  # key not in the list

In Q 1, searching [1, -2, 32, 8, 17, 19, 42, 13, 0, 44] gives 8 at position 4, 1 at position 1, 99 absent, and 44 at position 10. Key 1 needs only 1 comparison, while the absent key 99 needs all 10 comparisons, which is the costliest case.

Quick Tip: In a pass table, the number of rows equals the number of key comparisons. The examiner counts rows to award the comparison marks, so never stop the table early for an absent key.

Binary Search on a Sorted List: first, mid, last and Iterations

Binary search works only on a sorted list. It keeps three markers: first (start of the search area), last (end), and mid, the middle index found by mid = (first + last) // 2. It compares the middle element with the key and halves the search area each step.

  • If numList[mid] == key, the key is found at mid.
  • If numList[mid] < key, the key must be to the right, so set first = mid + 1.
  • If numList[mid] > key, the key must be to the left, so set last = mid - 1.
def binarySearch(numList, key):
    first = 0
    last = len(numList) - 1
    while first <= last:
        mid = (first + last) // 2
        if numList[mid] == key:
            return mid + 1            # 1-based position
        elif numList[mid] < key:
            first = mid + 1           # search the right half
        else:
            last = mid - 1            # search the left half
    return None                       # key not found

In Q 4, key 56 in [3, 8, 15, 21, 34, 40, 56, 67, 78, 90] is found at position 7 in 4 iterations. The loop must use first <= last, not first < last, or a present value at the final single element can be wrongly reported as absent.

Watch Out: After comparing the middle, you must move first to mid + 1 or last to mid - 1, never leave them on mid. Forgetting the plus one or minus one makes the search area never shrink past the middle, so the loop runs forever on a missing key.

Comparing Linear and Binary Search on Numbers and Words

Q 5 and Q 6 put both methods on the same data, once with numbers and once with English words, so the contrast in work is impossible to miss. Both questions ask for the position and the number of key comparisons or iterations.

The same data, three searches (Q 5)

On the unsorted 24-number list, linear search for the absent key 1 costs all 24 comparisons. After sorting, linear search for 99 still costs 24 comparisons because 99 ends up last, but binary search finds 99 in only 5 iterations. That single row, 24 against 5, is the whole point of the chapter.

KeyLinear on unsortedLinear on sortedBinary on sorted
1absent, 24 comparisonsabsent, 24 comparisonsabsent, 4 iterations
5pos 13, 13 comparisonspos 1, 1 comparisonpos 1, 4 iterations
55pos 23, 23 comparisonspos 12, 12 comparisonspos 12, 1 iteration
99pos 21, 21 comparisonspos 24, 24 comparisonspos 24, 5 iterations

Searching words (Q 6)

Searching and sorting work on strings exactly as on numbers, because Python compares words in dictionary (lexicographic) order using <, > and ==. So "Amazing" < "Awesome" is true, and sort() arranges words alphabetically, which is what binary search needs.

Remember: Python orders all capital letters before lowercase letters by character code. For mixed-case words, sort with words.sort(key=str.lower) before binary searching, or a present word can be missed.
Hashing with a hash function and collision at a single slot for Class 12 Computer Science Chapter 6

Search by Hashing: Hash Function and Collisions

Hashing stores a value at a slot decided by a hash function. The remainder method uses h(element) = element % size, so to store a value you compute its hash index and place it there. To search, you compute the key's hash index and check only that one slot, which is why hashing can answer in a single comparison.

A collision happens when two different values produce the same hash index, because a slot can hold only one value. Q 8 is built to show this: the numbers [44, 121, 55, 33, 110, 77, 22, 66] are all multiples of 11, so with h(e) = e % 11 every one hashes to index 0.

  • With basic overwriting, slot 0 keeps only the last value 66, and slots 1 to 10 stay None.
  • Searches for 11, 44, 88 and 121 all check slot 0, find 66, and report not present, even though 44 and 121 were in the original list.
  • The fix is collision handling, such as chaining a list at each slot or probing to the next free slot.

Q 9 uses a text hash function, len(country) - 1, with two parallel lists for keys and values. India (length 5) lands at index 4 with capital New Delhi, France at index 5 with Paris, and a search for USA at index 2 finds an empty slot, so it is correctly reported as not found.

Tip: For any hashing question, state the hash index of each key in a small table first, then fill the slots, then search. Showing the index computation earns the method marks even if a slot later turns out empty.

Common Mistakes Students Make in the Searching Chapter

The repeat-offender mistakes in Searching chapter board answers:

  • Mixing index with position: NCERT reports index + 1, so a value at index 3 is position 4, not 3.
  • Stopping the pass table early: for an absent key the table must show all n rows, because the examiner counts rows for the comparison marks.
  • Using binary search on an unsorted list: it can miss a value that is actually present, so always sort first.
  • Writing first < last in binary search: the condition must be first <= last, or the loop quits one step too early.
  • Saying a collided value was never stored: in Q 8, 44 and 121 were lost to the collision, not absent from the input.

How to Use the Searching NCERT Solutions PDF for Board Prep

The Searching chapter is short but counting-heavy. The best approach is two passes: one for the three methods and their Python code, one for tracing the comparison and iteration counts by hand.

First pass: the three methods (1 hour)

Read the chapter and note the linearSearch and binarySearch functions, the mid = (first + last) // 2 formula, and the remainder hash function. Write one line of meaning next to each so the ideas stick before you start tracing.

Second pass: trace the counts (1.5 to 2 hours)

Work Q 1, Q 4, Q 5 and Q 8 on paper first, writing one row per comparison and showing the first, mid, last values for binary search. Then open these solutions and check your counts, paying attention to position = index + 1 and to the full collision in Q 8.

JEE and CUET angle

For students preparing competitive exams, search algorithms appear in data-structure questions in JEE-level programming rounds and in CUET Computer Science. The time growth idea, linear cost rising with n while binary cost rises with log₂ n, is exactly the reasoning those papers reuse, so the work here doubles as competitive prep.

Previous Year Question Trends from the Searching Chapter

The Searching chapter is tested in CBSE board papers mainly through trace questions on comparison counts, a program on binary search, and a hashing question on collisions. The table below maps the asked question types across recent board papers.

YearQuestion type askedMarks
2025Trace linear search and count key comparisons; define collision2 + 1
2024Write a binary search program; count iterations for a given key3 + 2
2023Compute hash indices with h(e) = e % size and show the table3
2022Difference between linear and binary search; position = index + 12 + 1
2021Estimate comparisons for a large database; interpret the result3

Also Check: The full set of CBSE board paper questions for this chapter is included in the downloadable PDF above, updated for the 2026-27 cycle.

Other Resources for Class 12 Computer Science Chapter 6 Searching

Pair this NCERT Solutions PDF with the matching revision notes, handwritten notes and the official NCERT book chapter. All resources for Class 12 Computer Science Chapter 6 Searching are linked below.

ResourceWhat it coversOpen
NCERT SolutionsStep-by-step answers to all 9 exercise questions, with an Expert Solution for each.You are here
NotesConcept-first revision notes on linear search, binary search, and hashing.Class 12 Computer Science Chapter 6 Notes
Handwritten NotesScanned-style handwritten pages for last-minute board revision.Class 12 Computer Science Chapter 6 Handwritten Notes
NCERT Book PDFOfficial NCERT Computer Science Chapter 6 Searching textbook in PDF form.Class 12 Computer Science Chapter 6 NCERT Book PDF

NCERT Solutions for Class 12 Computer Science: All Chapters

Related Links: Use the table below to open the NCERT Solutions for the other chapters of Class 12 Computer Science. Every chapter ships with the same step-by-step answer style, full PDF download, and revision FAQ.

All NCERT Solutions for Class 12 Computer Science Chapter 6 Searching with Step-by-Step Solutions

Q 1

Using linear search determine the position of 8, 1, 99 and 44 in the list [1, -2, 32, 8, 17, 19, 42, 13, 0, 44]. Draw a detailed table showing the values of the variables and the decisions taken in each pass of linear search.

Q 2

Use the linear search program to search the key with value 8 in the list having duplicate values such as [42, -2, 32, 8, 17, 19, 42, 13, 8, 44]. What is the position returned? What does this mean?

Q 3

Write a program that takes as input a list having a mix of 10 negative and positive numbers and a key value. Apply linear search to find whether the key is present. If present, display the position, otherwise print an appropriate message. Run the program for at least 3 different keys and note the result.

Q 4

Write a program that takes as input a list of 10 integers and a key value and applies binary search to find whether the key is present. If present, display the position, otherwise print an appropriate message. Run the program for at least 3 different key values and note the results.

Q 5

For the unsorted list [50, 31, 21, 28, 72, 41, 73, 93, 68, 43, 45, 78, 5, 17, 97, 71, 69, 61, 88, 75, 99, 44, 55, 9]: (a) use linear search for 1, 5, 55, 99 and note the key comparisons; (b) sort the list ascending; (c) run linear search again on the sorted list and note the comparisons; (d) use binary search on the sorted list and record the iterations.

Q 6

For the unsorted list of words [Perfect, Stupendous, Wondrous, Gorgeous, Awesome, Mirthful, Fabulous, Splendid, Incredible, Outstanding, Propitious, Remarkable, Stellar, Unbelievable, Super, Amazing]: (a) use linear search for Amazing, Perfect, Great, Wondrous and note the comparisons; (b) sort the list; (c) run linear search again on the sorted list; (d) use binary search on the sorted list and record the iterations.

Q 7

Estimate the number of key comparisons required in binary search and linear search if we need to find the details of a person in a sorted database having 2⁷⁰ (1,073,741,824) records, when the person being searched lies at the middle position. What do you interpret from your findings?

Q 8

Use the hash function h(element) = element % 11 to store the numbers [44, 121, 55, 33, 110, 77, 22, 66] in a hash table. Display the hash table created. Search if the values 11, 44, 88 and 121 are present in the hash table, and display the search results.

Q 9

Write a Python program for a mapping of countries and capitals {'India':'New Delhi', 'UK':'London', 'France':'Paris', 'Switzerland':'Berne', 'Australia':'Canberra'}. Presume the hash function is the length of the Country name, with hash index = length of key minus 1. Store keys and values in two parallel lists, display the table, then search the capital of India, France and the USA.

NCERT Solutions Class 12 Computer Science Chapter 6 Searching FAQs

Ques. How many questions are there in NCERT Class 12 Computer Science Chapter 6 Searching?

Ans. There are 9 end-of-chapter exercise questions in NCERT Class 12 Computer Science Chapter 6 Searching. All 9 are solved with full answers and an Expert Solution in the PDF. The mix covers linear search with a pass table, a duplicate-value search, a linear search program on mixed sign numbers, a binary search program, two long compare-the-methods questions on numbers and on words, a large-database estimate, and two hashing questions on collisions.

Ques. What is the difference between linear search and binary search in Class 12 Computer Science?

Ans. Linear search checks every element one by one from the start, so it works on any list but can need up to n comparisons. Binary search works only on a sorted list: it compares the middle element, then keeps the half that may hold the key and discards the other, so it needs at most about log₂ n comparisons. For a list of 24 numbers, searching for the largest value cost 24 comparisons by linear search but only 5 iterations by binary search, which is why binary search is much faster on large sorted data.

Ques. Why must a list be sorted before using binary search?

Ans. Binary search throws away half the list at each step by trusting the order. It compares the key with the middle element and decides whether to look left or right based on that order. On an unsorted list that trust is broken, so a value that is actually present can be missed when the algorithm looks in the wrong half. This is why the NCERT chapter always sorts the list with sort() before running binary search. Linear search has no such requirement and works on any list.

Ques. What is a hash function and a collision in Class 12 Computer Science?

Ans. A hash function maps a value to a slot index in a hash table, for example h(element) = element % 11, so a value can be stored and found in a single step. A collision happens when two different values produce the same hash index, because a slot can hold only one value. In Question 8 every number is a multiple of 11, so all hash to index 0, a complete collision. With basic overwriting only the last value survives, which is why collision handling such as chaining or probing is needed in real hash tables.

Ques. How do you count key comparisons in linear search?

Ans. Count one key comparison for each element you test against the key. If the key is found at position p, linear search made p comparisons. If the key is absent, linear search made n comparisons, where n is the list length, because it had to scan the whole list to be sure. In a pass table the number of rows equals the number of comparisons, so the examiner counts rows to award marks. Always draw the full table, even for an absent key, or you lose the comparison marks the question is testing.

Ques. How many pages is the Class 12th Computer Science Searching NCERT Solutions PDF?

Ans. The Searching NCERT Solutions PDF runs about 20 pages and covers all 9 exercise questions with step-by-step Python code, dry-run traces, comparison and iteration counts, hash-index tables, and an Expert Solution for each question. Both Normal and HD versions are available from this page, and both are free to download for the 2026-27 session.

Ques. Is the NCERT Solutions for Class 12 Computer Science Chapter 6 aligned with the 2026-27 syllabus?

Ans. Yes. This page reflects the current 2026-27 CBSE syllabus for Class 12 Computer Science. The Searching chapter is unchanged for the current cycle, and every answer follows the NCERT textbook, including the linearSearch and binarySearch functions and the remainder hash function. The solutions are useful for the CBSE board exam, and the same algorithm ideas help with JEE-level programming and CUET Computer Science.

Ques. Why is binary search so much faster than linear search on large data?

Ans. Linear search cost grows in direct proportion to n, so doubling the data doubles the work. Binary search cost grows like log₂ n, so doubling the data adds just one comparison. For a sorted database of 2⁷⁰ (about a billion) records, linear search to reach the middle needs about 536,870,912 comparisons, while binary search needs at most 30. That gap is why databases, phone directories and search engines keep their data sorted or indexed: the one-time cost of sorting is paid back by every fast search that follows.