Unit 12 Algorithms Flashcards
What is an algorithm?
A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer
What are some examples of computational algorithms? (3)
- Binary search
- Insertion Sort
- Bubble Sort
What kind of problems are solved by Algorithms? (6)
- Routing problems
- Timetabling aircrafts
- Searching information on the Internet
- Encrypting communications
- Sorting large amounts of data
- Writing a compiler program
What are the properties of a good algorithm? (5)
- Has clear and well stated steps
- Should allow for invalid inputs
- Must terminate at some point
- Should be executed efficiently and in as few steps as possible
- Must be easy to understand and modify by other people
What is a good basic measure of Efficiency?
The number of assignment statements
What is a Linear Function?
A function that takes the form of f(n) = an + b where a and b are constants
What is a Quadratic Function?
A function that takes the form of f(n) = an^2 +bn + c where a, b and c are constants
What is a Logarithmic Function?
A function that takes the form of f(n) = alog2n (that’s a little low 2)
What is the Logarithm of a number?
The power to which the base must be raised to make it equal to the number
What is Big-O Notation?
A measure of the time complexity of an algorithm. It is a useful approximation of the time taken to execute an algorithm for a given number of items in a data set
How does an algorithm of time complexity O(n) increase?
Linearly
e.g. 10,000 items will take approximately twice as long as 5,000 items to process
How does a Divide and Conquer Algorithm work?
It halves the size of the problem at each pass
What is a Permutation?
A permutation of n items is the number of ways the n items can be arranged
What are the types of Permutation? (2)
- Repetition allowed
- No repetition allowed
What is Big-O notation used for?
Describing the time complexity of different algorithms
What happens in a Linear Search?
Each item is checked one after another until the desired item is found
What is the worst case scenario of a Linear Search?
Every item is checked
What happens in a Binary Search? (4)
- Middle item is examined
- If it is the desired item, the item is found
- If not, depending on whether the current item is higher or lower than the desired item, half the list is eliminated
- This is repeated until the item is found or proved to not be in the list
What do Binary Trees do?
Hold items in a way that can be searched quickly and easily