Professional Documents
Culture Documents
Week 3
Week 3
01
Searching Algorithms
02
Sorting Algorithms
Course Objectives:
To understand searching and sorting algorithms
and the different ways to write them.
Searching Algorithms
Serial Binary
The search then starts with the A binary search algorithm takes
first item and then moves to the data and keeps dividing it in
each item in turn, until either a half until it finds the item it is
match is found, or it reaches the looking for, provided should be
end of the data with no match an ordered list.
found.
Example for Serial Search:
Imagine that you have a database of sales made to customers. You need to deliver the g
Flowchart
Example for Binary Search:
Imagine that you have a database of customers and want to search for the customer Joh
Flowchart
Comparison of Searches
Serial Search Binary Search
• It is a very simple algorithm. • Much quicker than a serial
• It can be used on any kind of search.
data regardless of type or • In each step, data is searched
sorted. in halves.
• It is very slow. • The data needs to be sorted
for search.
Sorting Algorithm
A sorting algorithm will put items in a list into an order, such as
alphabetical or numerical order