Algorithms Flashcards
What is an algorithm?
A series of steps to solve a given problem
What is algorithmic thinking?
A way of solving problems by producing algorithms
Writing down an algorithm
Can be written as a set of numbered steps to follow
What is often used to represent algorithms?
Pseudocode or flow diagrams
How do you interpret an algorithm?
Identify what the algorithm does
What is a search algorithm?
A set of instructions for finding a specific item of data within a data set
What is an effective search?
A search that will either find the solution or determine that the target data is not present
What is an efficient search?
Will find the solution quickly regardless of its location within the data set
What are examples of search algorithms?
1) linear search 2) Binary search
What is linear search?
A simple searching algorithm
What is the concept of linear search?
If you were looking for a specific piece of paper in a stack of papers, then one way to find it would be to work from the top of the stack to the bottom, checking each paper on the way.
Linear search -
1) Check the first item in the dataset:
- if it is what we are looking for, return it
2) Check the second item in the dataset:
- if it is what we are looking for, return it
3) Continue for the rest of the items
What does it mean when you reach the end of the dataset in linear search?
The item was not in the data set
Linear search pseudocode example =
for item in dataset if item = target then return True endif endfor return False
What are the pros of linear search?
Very easy to implement