A PowerPoint about Algorithm’s. What is an algorithm? a process or set of rules to be followed in...
-
Upload
meghan-reed -
Category
Documents
-
view
216 -
download
2
Transcript of A PowerPoint about Algorithm’s. What is an algorithm? a process or set of rules to be followed in...
![Page 1: A PowerPoint about Algorithm’s. What is an algorithm? a process or set of rules to be followed in calculations or other problem-solving operations,](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649eb45503460f94bbcc04/html5/thumbnails/1.jpg)
A PowerPoint about
Algorithm’s
function binarySearch(values,
target, start, end) { if (s
tart >
end) { return -1; } //does not
exist var middle =
Math.floor((start + end) / 2);
var value = values[middle];
![Page 2: A PowerPoint about Algorithm’s. What is an algorithm? a process or set of rules to be followed in calculations or other problem-solving operations,](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649eb45503460f94bbcc04/html5/thumbnails/2.jpg)
What
is a
n
alg
ori
thm
?
a process or set of rules to be
followed in calculations or
other problem-solving
operations, especially by a
computer. "a basic algorithm for
division"
![Page 3: A PowerPoint about Algorithm’s. What is an algorithm? a process or set of rules to be followed in calculations or other problem-solving operations,](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649eb45503460f94bbcc04/html5/thumbnails/3.jpg)
START
GET CUP
PUT TEA BAG IN
PUT MILK IN
PUT SUGAR
IN?
STIR IT
END
NO
YES
START
Put water in kettle
Boil kettle
Get a cup and put a tea bag in
Pour water in kettle
Remove tea bag
Put milk in?
Put sugar
in?
END
NOYES
YES NO
WHERE IS THE HOT WATER IN A KETTLE !!!
YOU DON’T POOR THE HOT WATER INTO THE KETTLE AGAIN
![Page 4: A PowerPoint about Algorithm’s. What is an algorithm? a process or set of rules to be followed in calculations or other problem-solving operations,](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649eb45503460f94bbcc04/html5/thumbnails/4.jpg)
Searc
hin
g f
or
data
….
Usi
ng
Alg
ori
thm
s.
What is a linear search algorithm?
A linear search is the most basic of search algorithm
you can have. A linear search sequentially moves
through your collection (or data structure) looking for a
matching value.What is a binary search algorithm?
Binary search relies on a divide and conquer strategy
to find a value within an already-sorted collection. The
algorithm is deceptively simple. Pretend I was thinking
of a number between 1 and 100. Every guess you take,
I'll say higher or lower. The most efficient way to
discover my number is to first guess 50. Higher. 75.
Lower. 62. Higher 68.
![Page 5: A PowerPoint about Algorithm’s. What is an algorithm? a process or set of rules to be followed in calculations or other problem-solving operations,](https://reader036.fdocuments.net/reader036/viewer/2022062517/56649eb45503460f94bbcc04/html5/thumbnails/5.jpg)
Which is best when searching for data?
Why?
Use an example and give the good and bad points of
each search methodIf you use a linear search if your playing
a guessing game e.g
guess who if you go
throw all of the names
you will take longer
than you need to . But
if you use a binary
search it will narrow
the search down in
sections. Except the
data must be sorted
first.