Courses
Courses for Kids
Free study material
Offline Centres
More
Store Icon
Store

Important Questions and Answers for Class 12 Computer Science Chapter 6 Searching | 2026-27

ffImage
banner

Class 12 Computer Science Chapter 6 Important Questions and Answers PDF

Searching is an important topic in Class 12 Computer Science that teaches students how to locate specific values in a list. Chapter 6 introduces linear search and Binary Search, helping students understand how they work, how they differ, and how to implement them in Python. Practising Class 12 Computer Science Important Questions chapter by chapter can make these programming concepts easier to understand and recall.


The Computer Science Chapter 6 Important Questions with answers for 2026-27 focus on searching techniques, algorithm-based problems, and Python programming questions. 


Students can use these questions to test their understanding, identify areas that need more practice, and prepare confidently for exams. Alongside Computer Science, practising Class 12 Important Questions across subjects helps students maintain a consistent practice routine.

Get Class 12 Computer Science Chapter 6 Important Questions PDF Download

Download the Class 12 Computer Science Chapter 6 Important Questions PDF for easy revision. Practice Class 12 Computer Science Chapter 6 important questions, including MCQs, very short, short, and long-answer questions, to strengthen your understanding and prepare for board exams.


Class 12 Computer Science Chapter 6 Multiple Choice Questions

1. Which searching technique is suitable for finding an element in an unsorted list?


(a) Binary Search

(b) Linear Search

(c) Both require sorting

(d) None of these


Answer: (b) Linear Search.


2. In Binary Search, if the key is greater than the middle element of an ascending list, which part is searched next?


(a) Left half

(b) Right half

(c) Entire list

(d) First element only


Answer: (b) Right half.


3. What will be the output of the following Python code?


L = [15, 25, 35, 45, 55]

key = 35


for i in range(len(L)):

    if L[i] == key:

        print(i + 1)

        break


(a) 2

(b) 3

(c) 35

(d) 4


Answer: (b) 3.


Explanation: The key 35 is at index 2, so i + 1 prints position 3.


4. Which Python operator is used to calculate the middle index in Binary Search?

(a) /

(b) %

(c) //

(d) **

Answer: (c) //


5. What is the hash value of 38 using the hash function h(key) = key % 7?

(a) 2

(b) 3

(c) 5

(d) 7

Answer: (b) 3.

Explanation: 38 % 7 = 3


Class 12 Computer Science Chapter 6 Very Short Answer Questions

1. What is the role of a key in a searching algorithm?

Answer: 

A key is the value that a searching algorithm attempts to locate in a given collection of elements.


2. When is Linear Search considered unsuccessful?

Answer: 

Linear Search is unsuccessful when it has compared every element in the list with the key and finds no match.


3. Why does Binary Search require an ordered list?

Answer: 

Binary Search uses the ordering of elements to decide which half of the list to exclude after comparing the key with the middle element.


4. What is a hash function?

Answer: 

A hash function calculates the index at which an element should be stored in a hash table.

For example, h(key) = key % 10.


5. What is a collision in hashing?

Answer: 

A collision occurs when two different elements generate the same hash index.

For example, when h(key) = key % 10, both 17 and 27 produce index 7.


Class 12 Computer Science Chapter 6 Short Answer Questions

1. Explain the best-case and worst-case conditions of Linear Search.

Answer:

  • Best case: The key is present at the first position, requiring only one comparison.

  • Worst case: The key is at the last position or absent from the list, requiring n comparisons, where n is the total number of elements.


2. Differentiate between Linear Search and Binary Search.

Answer:


Linear Search

Binary Search

Checks elements sequentially.

Compares the key with the middle element.

Works on unsorted lists.

Requires a sorted list.

May require checking all elements.

Reduces the search area by approximately half.

Suitable for small collections.

Efficient for large sorted collections.


3. Trace Linear Search to find the key 42 in the following list. Mention the number of comparisons.

L = [16, 29, 35, 42, 57, 63]

Answer:


Comparison

Element checked

Result

1

16

Not matched

2

29

Not matched

3

35

Not matched

4

42

Matched


Result: The key 42 is found at position 4 after four comparisons.


4. Explain how Binary Search reduces the search area after each unsuccessful comparison.

Answer:

Binary Search compares the key with the middle element of a sorted list.

  • If the key matches, the search ends.

  • If the key is smaller, the search continues in the left half.

  • If the key is greater, the search continues in the right half.


This process eliminates approximately half of the remaining elements after every unsuccessful comparison.


5. What is a perfect hash function? Why is it useful?

Answer:

A perfect hash function assigns a unique hash index to every element in a given collection.

It is useful because it prevents collisions, allowing elements to be stored at distinct positions in the hash table.


6. Explain the difference between hashing and Binary Search.

Answer:


Hashing

Binary Search

Calculates the position of a key using a hash function.

Finds a key by repeatedly examining the middle element.

Does not require sorting.

Requires sorted elements.

Can locate a key using one comparison when there are no collisions.

May require several iterations.

Collisions may occur.

Does not involve hash collisions.


Class 12 Computer Science Chapter 6 Long Answer Questions

1. Write a Python program to search for an element using Linear Search.

Answer:


def linearSearch(L, key):

    for i in range(len(L)):

        if L[i] == key:

            return i + 1

    return None


L = [18, 27, 39, 46, 58]

key = 46


position = linearSearch(L, key)


if position is None:

    print("Element not found")

else:

    print("Element found at position", position)


Output:

Element found at position 4

Explanation: The program checks the elements sequentially. It finds 46 after four comparisons and returns position 4.


2. Write a Python program to implement Binary Search in a sorted list.

Answer:


def binarySearch(L, key):

    first = 0

    last = len(L) - 1


    while first <= last:

        mid = (first + last) // 2


        if L[mid] == key:

            return mid + 1

        elif key > L[mid]:

            first = mid + 1

        else:

            last = mid - 1


    return None


L = [4, 9, 15, 21, 28, 35, 42]

key = 28


position = binarySearch(L, key)


if position is None:

    print("Element not found")

else:

    print("Element found at position", position)


Output:

Element found at position 5

Explanation: The algorithm first compares 28 with 21. Since 28 is greater, it searches the right half. It then compares 28 with 35 and searches left, finding 28 at index 4.


3. Apply Binary Search to find the key 45 in the following sorted list. Show the iterations.

L = [5, 10, 15, 20, 25, 30, 35, 40, 45]

Answer:


Iteration

First

Last

Mid

Middle element

Decision

1

0

8

4

25

Search right

2

5

8

6

35

Search right

3

7

8

7

40

Search right

4

8

8

8

45

Key found


Result: The key 45 is found at position 9 after four iterations.


4. Construct a hash table of size 10 using the remainder method for the elements [23, 46, 71, 58, 90].

Answer:

The hash function is:


h(key)= key mod 10 


Step 1: Calculate the hash values.


Element

Calculation

Hash index

23

23 % 10

3

46

46 % 10

6

71

71 % 10

1

58

58 % 10

8

90

90 % 10

0


Step 2: Construct the hash table.


Index

Stored value

0

90

1

71

2

None

3

23

4

None

5

None

6

46

7

None

8

58

9

None


Result: Every element is stored at its calculated index. No collisions occur.


5. Explain collision in hashing with an example. Why is collision resolution necessary?

Answer:

A collision occurs when two different elements produce the same hash index.

Consider the elements:


L = [18, 25, 38]


Hash function:


h(key) = key % 10


Element

Hash calculation

Hash index

18

18 % 10

8

25

25 % 10

5

38

38 % 10

8


Both 18 and 38 map to index 8, resulting in a collision.


Why is collision resolution required?

In a hash table where each position holds only one element, two different elements cannot occupy the same position. Collision resolution provides a way to store and retrieve both elements correctly.


Key Concepts to Understand in Class 12 Computer Science Chapter 6: Searching

Students practising Class 12 Computer Science Chapter 6 Important Questions and Answers should focus on understanding how searching methods work. Learning these concepts helps students solve new questions confidently, even when the examples are different.


Topic

What Students Should Learn

Linear Search

How to find an element by checking each value one by one.

Binary Search

How to find an element in a sorted list by reducing the search area.

Linear vs Binary Search

When to use each method and how they differ.

Python Programs

How to write and understand searching programs.

Hashing

How hash functions calculate positions in a hash table.

Collision

Why two elements may get the same hash index.


Understanding these topics helps students answer concept-based, MCQ, and programming questions more confidently.


How Vedantu's Class 12 Computer Science Important Questions Help in Board Exam Preparation

Knowing an answer helps, but understanding how to solve a new question matters more. 


Vedantu's Class 12 Computer Science Important Questions help students practise applying concepts through different question formats.


  • Understand Before Memorising: Focus on why an answer is correct and how the concept works.

  • Think Like a Programmer: Follow the logic of Python code and predict the output before running it.

  • Write Better Answers: Practise explaining algorithms and concepts in simple, clear steps.

  • Check Your Progress: Attempt questions independently and review mistakes using the given answers.

  • Prepare for New Questions: Apply the same concepts to different examples rather than learning only fixed answers.


With consistent practice, students can strengthen their programming knowledge and approach board exam questions with greater confidence.


Important Study Material Links for Class 12 Computer Science Chapter 6 

Students can strengthen their understanding of Searching using these chapter-specific learning resources.



Class 12 Computer Science Chapter-Wise Important Questions


Additional Study Materials for Class 12 Computer Science

FAQs on Important Questions and Answers for Class 12 Computer Science Chapter 6 Searching | 2026-27

1. How can I score 100 marks in Class 12 Computer Science?

To aim for 100 marks in Class 12 Computer Science, students should understand all chapters, practise Python programs regularly, and solve previous years' question papers. Vedantu's Class 12 Computer Science Important Questions and Answers help students practise chapter-wise concepts, revise key topics, and prepare confidently for exams.

2. Are NCERT books enough to prepare for Class 12 Computer Science board exams?

NCERT textbooks provide a strong foundation for Class 12 Computer Science preparation. Students should understand the concepts, practise textbook programs and exercises, and solve additional chapter-wise important questions and previous years' papers for better preparation.

3. How can I improve my Python programming skills for Class 12 Computer Science?

Students can improve their Python skills by writing programs regularly, understanding the logic behind each step, and practising output-based questions. For Chapter 6 (Searching), they should focus on Linear Search and Binary Search programs.

4. How should I divide my study time between theory and programming in Class 12 Computer Science?

Students can start by dividing their study time equally between theory and programming, then adjust based on their learning needs. They should revise definitions and algorithms, practise Python coding, and solve different types of exam questions.

5. Is Class 12 CBSE Computer Science Chapter 6 Searching Difficult?

Class 12 Computer Science Chapter 6, Searching, is generally not difficult if students understand how linear search and Binary Search work. Binary Search may require extra practice because it involves sorting and step-by-step comparisons. Practising Python programs and tracing search algorithms can make the chapter easier to understand.

6. What important questions are included in Class 12 Computer Science Chapter 6 Searching PDF?

Students can download the Class 12 Computer Science Chapter 6 Searching Important Questions PDF with answers from Vedantu. It includes MCQs and very short, short, and long-answer questions covering Linear Search, Binary Search, Hashing, and Collisions, along with Python programming questions for CBSE board exam preparation.

7. How can I prepare for the Class 12 Computer Science practical viva?

Students should practice Python syntax, understand their practical programs, and practise explaining the logic behind their code. They should also prepare for questions on variables, loops, functions, and program outputs.

📌 Add Vedantu as a preferred source on Google