Data Structure Presentation
Data Structure Presentation
CONTRIBUTORS
1. Linear searching: Linear search Goes through each element in a list one by
one until it either.
2. Binary search: Binary Search is a technique used to search sorted arrays or lists.
It works by repeatedly dividing the search interval in half
• 2 .
LINEAR SEARCH
Find : 34
12 16 22 26 32 34 37 42 49 53
Found at INDEX [ 6 ]
BINARY SEARCH
12 16 22 26 32 34 37 42 49 53
HIGHEST INDEX
LOWEST INDEX
ELSE IF
TARGET VALUE < VALUE [MID] ;
UPDATE HIGHEST INDEX
.
.
[ Keep the process running ]
.
.
EVENTUALLY
2nd Pass:
•Compare 2 and 5 → OK
•Compare 5 and 1 → swap → [2, 1, 5, 9]
3rd Pass:
•Compare 2 and 1 → swap → [1, 2, 5, 9]
Now the list is sorted
Linear vs Binary
Search
• Linear Search:
Goes through each element one
by one. Simple but slow for large
data.
✅ Works on unsorted data.
• Binary Search:
Much faster. Divides the search
interval in half each time.
❗ Requires data to be sorted
beforehand."
Time Complexity of
Searching Techniques
Technique Best Case Average Case Worst Case
Case Time
Best Case O(n)
Average Case O(n²)
Worst Case O(n²)
Conclusions