Insertion sort is an example of divide and conquer?
True
False
Given an array of 6 numbers
[6,8,19,48,9,90]
and applyinginsertion sort
, how many swaps must occur before the array is sorted?6
2
4
What time complexity is required to do a linear search?
O(1)
O(n)
((log (n))
Why do we need Big-O notation to evaluate our programs?
Because sorting is complicated, and we need a complicated metric.
Because sorting requires that things are moved around to save space.
Because measuring time is relative to a person’s computer, so a relative metric is required.
What is parallelization?
It is about running code at the same time in threads or on separate computers.
It is about calling functions repetitively until they have achieved a base case.
It is about writing your code in one go.
Why would you decide to use recursion?
It looks cool and makes your code seem more intelligent.
Recursion reduces the pressure on the compiler by making less stack calls.
It lends itself well to a divide and conquer approach.
Why does Memoization work well with dynamic programming?
It takes up less space in the hard drive.
It requires less compiling because it stores previous results, reducing the load on the CPU.
Because it takes a lot of memory to run some programs and memoization allows you to store data in smaller sizes.
How are the principles of dynamic programming and greedy algorithms at odds with one another?
The principle of dynamic programming is to exhaustively compute the best solution, while a greedy approach will favor take the immediate best option.
Because dynamic programming will react with more agility to a program, while the greedy approach will be slower and more self-centered.
The greedy algorithm will use up CPU by monopolizing resources.
Why is a binary search conducted in
O(log n)
time?Regardless of the size of the input, at every step the number of calculations is halved.
It is not, it is conducted in O(n).
Because as it searches it sorts the elements.
In the Fibonacci pseudocode above how many recursive instances can be seen?
0
1
2