Module quiz: Introduction to algorithms Quiz Answers
In this article i am gone to share Coursera Course: Coding Interview Preparation by Meta Week 3 | Module quiz: Introduction to algorithms Quiz Answers with you..
Also visit: Module quiz: Introduction to data structures Quiz Answers
Module quiz: Introduction to algorithms Quiz Answers
Question 1)
Insertion sort is an example of divide and conquer?
- True
- False
Question 2)
Given an array of 6 numbers [6,8,19,48,9,90]and applying insertion sort, how many swaps must occur before the array is sorted?
- 2
- 6
- 4
Question 3)
What time complexity is required to do a linear search?
- ((log (n))
- O(n)
- O(1)
Question 4)
Why do we need Big-O notation to evaluate our programs?
- Because sorting is complicated, and we need a complicated metric.
- Because measuring time is relative to a person’s computer, so a relative metric is required.
- Because sorting requires that things are moved around to save space.
Question 5)
What is parallelization?
- It is about running code at the same time in threads or on separate computers.
- It is about writing your code in one go.
- It is about calling functions repetitively until they have achieved a base case.
Question 6)
Why would you decide to use recursion?
- It lends itself well to a divide and conquer approach.
- Recursion reduces the pressure on the compiler by making less stack calls.
- It looks cool and makes your code seem more intelligent.
Question 7)
Why does Memoization work well with dynamic programming?
- Because it takes a lot of memory to run some programs and memoization allows you to store data in smaller sizes.
- It takes up less space in the hard drive.
- It requires less compiling because it stores previous results, reducing the load on the CPU.
Question 8)
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.
- The greedy algorithm will use up CPU by monopolizing resources.
- Because dynamic programming will react with more agility to a program, while the greedy approach will be slower and more self-centered.
Question 9)
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.
- Because as it searches it sorts the elements.
- It is not, it is conducted in O(n).
Question 10)
In the Fibonacci pseudocode above how many recursive instances can be seen?
- 0
- 1
- 2