Component 19 - Key Definitions Flashcards
Big O notation
A mathematical representation of the best or worst case time and space complexity of a problem. Translated – how long will this take to execute and how much memory will it require?
Constant
The time taken will be the same regardless of the size of the problem/data set
linear
The time/space requirements will grow directly in proportion with the size of the data set.
polynomial
The time/space requirements will grow as some form of function of n (the size of the data set)
Exponential
The time/space requirements will grow at an exponential rate as the data set grows (as the data set increases, time/space doubles for each increase of n)
logarithmic
Usually a best case scenario, the time/space requirements will grow rapidly at first as data set size increased, however this will then “level out” and increasing the size of a data set will have less and less of an effect
Stacks – algorithm
You need to be able to recognise/create the code which will implement a stack. Stacks are LIFO data structures which can only be accessed from the top by “Popping” data off the top of the stack.
Queues - algorithm
You need to be able to recognise/create the code which will implement a queue using either an array or a list. A queue is a FIFO data structure which can only be accessed at the “head” and “tail.”
Tree
See Unit 1 notes.
Linked list
See Unit 1 notes
Depth first traversal
A method of searching a tree data structure by following the left most nodes until the bottom of the tree is reached and then backtracking up to each level and traversing the right hand nodes
Breadth first traversal
A method of searching a tree by systematically accessing all nodes on the same level before then visiting nodes of a lower level
bubble sort
A method of sorting data by comparing pairs of numbers in a list and swapping when one is bigger than the other. Continues until no swaps are made. Computationally very expensive due to the number of iterations and comparisons made, grows exponentially in complexity/time requirements
Insertion sort
A method of sorting data by creating two lists – sorted and unsorted. Each iteration sees one value taken from the unsorted list and then “inserted” in the correct place using one of the following rules:
If the element is smaller than the first element of the sorted list – place at the start. If the element is bigger, then compare to the next element in the list. If bigger, move to the next element, if smaller, place in the list before this element.
If the end of the list is reached, place at the end
Merge sort
Splits numbers to be sorted into lists and then merges pairs of lists:
Take the first number from each list. Compare. Place the smallest in the new list. Repeat until both lists are empty