0% found this document useful (0 votes)
7 views16 pages

Data Structure Presentation

This document presents fundamental techniques of searching and sorting in computer science, emphasizing their importance for data management and optimization. It covers linear and binary searching methods, as well as various sorting algorithms like bubble sort, selection sort, and quick sort, detailing their processes and time complexities. The conclusion highlights the significance of these techniques for enhancing performance and resource management in software development.

Uploaded by

Tauhid Islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views16 pages

Data Structure Presentation

This document presents fundamental techniques of searching and sorting in computer science, emphasizing their importance for data management and optimization. It covers linear and binary searching methods, as well as various sorting algorithms like bubble sort, selection sort, and quick sort, detailing their processes and time complexities. The conclusion highlights the significance of these techniques for enhancing performance and resource management in software development.

Uploaded by

Tauhid Islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Searching and Sorting

CONTRIBUTORS

Md. Tauhidul Islam : 232-35-448


Md. Tayabul Alam Fahim : 213-35-786
Ashri Jamil Sazin : 232-35-793
Jehad Ahmed : 232-35-556
Introduction
This presentation covers the fundamental techniques of
searching and sorting in computer science, which are critical
for data management and optimization.
Basics of Searching and Sorting

• Searching is the process of finding a particular element in a dataset


• Sorting is arranging data in a particular order – usually ascending or
descending.
Searching
There are two types of searching technique:

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

MID = (LOWEST INDEX + HIGHEST INDEX) / 2

THE ARRAY MUST BE SORTED


IF
TARGET VALUE > VALUE [MID]
UPDATE LOWEST INDEX

ELSE IF
TARGET VALUE < VALUE [MID] ;
UPDATE HIGHEST INDEX

.
.
[ Keep the process running ]
.
.

EVENTUALLY

TARGET VALUE = VALUE [MID]


TARGET VALUE FOUND
Sorting Techniques

•Bubble Sort: Simple, but not efficient.

•Selection Sort: Selects the smallest/largest and places it in order.

•Insertion Sort: Builds the sorted array one element at a time.

•Quick Sort: Fast and widely used. Uses divide-and-conquer.

•Merge Sort: Very stable and efficient for large datasets


Bubble sort

• Bubble Sort is a simple algorithm that


repeatedly compares and swaps adjacent
elements if they are in the wrong order.
• It keeps "bubbling up" the largest unsorted
element to its correct position in each pass
through the list — just like a bubble rising to the
surface
How bubble sort works
Let’s say we have the list:
[5, 2, 9, 1]
1st Pass:
•Compare 5 and 2 → swap → [2, 5, 9, 1]
•Compare 5 and 9 → OK
•Compare 9 and 1 → swap → [2, 5, 1, 9]

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

Binary Search O(1) O(log n) O(log n)

Linear Search O(1) O(n/2) ≈ O(n) O(n)


Time Complexity of
Sorting Algorithms

Case Time
Best Case O(n)
Average Case O(n²)
Worst Case O(n²)
Conclusions

In summary, searching and sorting are


foundational techniques in computer science
that play a crucial role in optimizing data
management. Understanding their complexities
and applications will enable developers to make
informed decisions that enhance performance,
improve resource management, and ultimately
lead to more efficient software solutions.
Thank
you!

Do you have any questions?

You might also like