Unit - II
Unit - II
Sorting
MASTER SIMMI
[Lecturer]
Lecture 1: Introduction to
Searching
Objectives:
Understand the concept of searching in data
sets.
Learn about Linear Search and its
implementation.
Learn about Binary Search and its
implementation.
Topics Covered:
Introduction to Searching
Linear Search:
Definition
Algorithm
Time Complexity
Code Implementation (in Python and C)
Binary Search:
Definition
Algorithm
Time Complexity
Code Implementation (in Python and C)
Introduction to Searching
Concept:
Searching is the process of finding a specific item within a data
structure (e.g., an array or list).
It's important because it helps us quickly locate data, which is
fundamental in computing.
2. Linear Search
Definition:
Linear Search is a straightforward method of
searching where each element is checked
sequentially until the target is found or the list
ends.
Algorithm:
Definition:
Binary Search is an efficient algorithm for finding a
target value in a sorted array. It repeatedly divides the
search interval in half.
Algorithm:
1. Start with two pointers: low at the beginning and high at the end of
the array.
2. Calculate the middle index.
3. If the target equals the middle element, return the middle index.
4. If the target is less than the middle element, narrow the search to
the lower half.
5. If the target is greater, narrow the search to the upper half.
6. Repeat steps 2-5 until the target is found or the low pointer
exceeds the high pointer.
Time Complexity: