Algorithm for removing from a queue?
Found in photos
Algorithm for adding to a queue?
Found in photos
Algorithm for removing from a stack?
If stack pointer minimum then report stack empty
Else
Set data to stack(stack pointer)
Set stack pointer to stack pointer -1
Endif
Algorithm for adding to a stack?
If stack pointer maximum then report stack full
Else
Set stack pointer to stack pointer +1
Set stack(stack pointer) to data
Endif
What are the two main types of algorithmic operations?
What are the two approaches used by sorting algorithms?
- divide and conquer approach (breaks down list into smaller lists and reassemble into correct order)
What is bubble sort? +/-
-uses incremental approach
-Each value is compared to adjacent values and bubbled up the list if it is greater than its adjacent value
-Repeated for each value until in correct order
-very slow and inefficient so only used for small lists
+most simple to understand
How are variable values swapped in programming?
What is insertion sort?
What is linear search?
-start at beginning of list comparing your value to this value. if not the same move on if it is the same your finished. Repeat until value found
-simple loop with incrementing values used to represent
+list does not have to be ordered
+efficient for long lists
-only returns value once so if it represented multiple times it will still only be outputted once
What is binary search?
What is complexity?
What is the basis of big O notation?
What is the time complexity in big O notation of 7n^3+n^2+4n+1?
O(n^3)
What is constant complexity? Draw the graph
What is linear complexity? Draw the graph
-graph on paper
-O(n)
-if the input size doubles, the time taken for the algorithm to complete also doubles
Eg; average time to find an element using linear search
What is polynomial complexity? Draw the graph
What exponential complexity? Draw the graph
What is logarithmic complexity? Draw the graph
What is Dijkstra’s shortest path algorithm used for? Algorithm?
What is the A* algorithm?
Look over 15 puzzle
In book
What is merge sort?
What is quicksort?