Skip to content
← Computer Science

Computer Science · Class 12 Optional

Ch 6Searching — Class 12 Computer Science, concept-first.

We store things at home and later look for them when needed. Sometimes we remember exactly where an item is kept; other times we do not, and we have to search for it. A computer works in a similar way — it stores large amounts of data and must retrieve that data later when a user or a program asks for it.

17

Q&A

5

Concepts

Not available

Exam weightage

Start learning — read this chapter →

Key concepts

Hover a concept to preview it and jump to its most relevant Q&A.

Chapter contents

The NCERT structure, section by section. Open a section to see its questions, then read the concept-first solution.

6.1

Introduction

We store things at home and later look for them when needed. Sometimes we remember exactly where an item is kept; other times we do not, and we have to search for it.

6.2

Linear Search

3 Q

Linear search is the simplest way to find an item in a list. It works by checking every single element, one after another, from the very first element to the last.

6.3

Binary Search

4 Q

Imagine you need to find the meaning of the word "Zoology" in an English dictionary. Would you start from the first page and flip through every single page until you reach Z? Of course not.

6.3.1

Applications of Binary Search

Binary search is not just a technique for locating one value in a list — the same idea shows up, in one form or another, wherever fast lookup matters:

6.4

Search by Hashing

Hashing is a search technique designed to answer one question in a single step: Is this key present in the list? The logic is simple: if you already know exactly which index position every value shoul…

6.4.1

Collision

Hashing works beautifully when every element in a list maps to a unique slot in the hash table. But that ideal situation does not always happen. Consider a list like [34, 16, 2, 26, 80].

Summary

- Searching: the process of trying to locate a particular element, called the key, within a collection of elements.

Exercises