WEBVTT

00:00.000 --> 00:14.000
In this video, we will understand why searching is needed in computing.

00:14.000 --> 00:18.000
Describe how linear and binary search work.

00:18.000 --> 00:24.000
Choose the right search method for different data sets.

00:24.000 --> 00:27.000
Why searching matters?

00:27.000 --> 00:30.000
Searching is a fundamental operation in computers.

00:30.000 --> 00:38.000
We use it constantly, looking up a contact, locating a file, or finding items in a large inventory system.

00:38.000 --> 00:42.000
But the speed of a search depends on how the data is organized.

00:42.000 --> 00:46.000
If items are unsorted, we may need to check each one.

00:46.000 --> 00:50.000
If the data is sorted, we can skip large portions at once.

00:50.000 --> 00:56.000
To make searching efficient, we choose the right algorithm for the right situation.

00:56.000 --> 00:59.000
Linear search.

00:59.000 --> 01:02.000
Linear search is the simplest method.

01:02.000 --> 01:07.000
We start from the first element and check each item one by one until the target is found.

01:07.000 --> 01:11.000
It works well with small or unsorted data sets.

01:11.000 --> 01:15.000
But as the data set grows larger, the number of checks grows too.

01:15.000 --> 01:21.000
Worst case performance is O of N, meaning more data equals more time.

01:21.000 --> 01:28.000
However, it requires no extra memory, so its space complexity is O of 1.

01:28.000 --> 01:31.000
Binary search.

01:31.000 --> 01:35.000
Binary search is much faster, but only if the data is sorted.

01:35.000 --> 01:40.000
Instead of checking each item, it repeatedly divides the list into halves.

01:40.000 --> 01:46.000
We compare the middle element to the target and eliminate half the list each step.

01:46.000 --> 01:52.000
This gives O log N time complexity, making it ideal for large data sets.

01:52.000 --> 02:00.000
Binary search is used in databases, phone directories, and many real-time systems.

02:00.000 --> 02:03.000
Choosing the right algorithm.

02:03.000 --> 02:07.000
Linear search is best when data is unsorted.

02:07.000 --> 02:11.000
The list is small, the data updates frequently.

02:11.000 --> 02:15.000
Binary search is best when data is sorted.

02:15.000 --> 02:24.000
Speed is important. The data set is large and mostly unchanged.

02:24.000 --> 02:27.000
Searching helps us find information quickly.

02:27.000 --> 02:34.000
Linear search is simple for small or unsorted data, while binary search is faster for large-sorted data.

02:34.000 --> 02:39.000
Choosing the right method improves performance.

