Big O Flashcards
How can an algorithm be classed as efficient?
-no unnecessary steps
-same outcome but with minimum processing requirements
-shortest execution time
Define Big O notation
A mathematical notation used to describe how well an algorithm will perform as it is given increasingly larger datasets
Define efficiency
The ratio between the work an algorithm produces and its speed or memory requirements.
What do time requirements denote?
The time taken to complete the task
What do space requirements denote?
The amount of memory taken to complete a task
What can the time parameter be based off in a time measure function?
Number of memory accesses, number of comparisons, number of loops etc.
Sometimes refers to the real time taken to execute, run time
What does the parameter of the space measure function depend on?
Whether additional memory is used to store inputs for processing
List the factors that can determine efficiency of an algorithm:
-Human coding time
-time complexity
-space complexity
What factors are used to measure human coding time?
-time taken to develop a program
-time taken to maintain a program
What main factor effects human coding time?
Readability of the program
Define refactoring
Code is restructured without changing its purpose and behaviour to make it more clear, readable and efficient.
Describe the meaning of permutations
The number of ways of arranging objects
What is the formula for calculating the number of permutations?
p = n^r, where n is the number of choices we have, and r is the number of times a choice is made.
Describe the purpose of big O notation
-Big O notation is used to describe how the time requirements of an algorithm grow in relation to the number of items being processed. (worst case scenario)
-n refers to the number of items
List the types and their notations:
Constant: O(1)
Linear: O(n)
Logarithmic: O(log n)
Quadratic: O(n^2)
n Log n: O(n log n)
Cubic: O(n^3)
Exponential: O(2^n)