Skip to content

Module quiz: Introduction to algorithms :Coding Interview Preparation (Meta iOS Developer Professional Certificate) Answers 2026

Question 1

Insertion sort is an example of divide and conquer.

True
False

Explanation:
Insertion sort does not divide the problem into subproblems. It builds the sorted list one element at a time, so it is not a divide-and-conquer algorithm.


Question 2

Given the array [6, 8, 19, 48, 9, 90], how many swaps occur using insertion sort?

2
4
6

Explanation:
When inserting 9, it swaps with 48 and 19 (2 swaps).
Overall, total swaps required = 4.


Question 3

What time complexity is required to do a linear search?

O(log n)
O(1)
O(n)

Explanation:
A linear search may need to check every element, so time grows linearly with input size.


Question 4

Why do we need Big-O notation?

❌ Sorting is complicated
❌ Sorting requires saving space
Because measuring time depends on hardware, so a relative metric is required

Explanation:
Big-O measures algorithm efficiency independent of machine speed.


Question 5

What is parallelization?

Running code simultaneously using threads or multiple computers
❌ Writing code in one go
❌ Calling functions repeatedly until a base case

Explanation:
Parallelization improves performance by doing work at the same time.


Question 6

Why would you decide to use recursion?

❌ Reduces compiler pressure
It lends itself well to a divide-and-conquer approach
❌ Makes code look smarter

Explanation:
Recursion naturally fits problems that can be broken into smaller identical subproblems.


Question 7

Why does memoization work well with dynamic programming?

It stores results of subproblems to avoid recomputation
❌ Stores data in separate memory areas
❌ Takes less hard drive space

Explanation:
Memoization improves efficiency by reusing previously computed results.


Question 8

How are dynamic programming and greedy algorithms at odds?

DP exhaustively finds the best solution, greedy picks the immediate best choice
❌ Greedy monopolizes CPU
❌ DP is more agile than greedy

Explanation:
Greedy algorithms make local decisions, while DP finds a global optimum.


Question 9

Why is binary search O(log n)?

❌ Because it sorts elements
❌ It is actually O(n)
Because the search space is halved at every step

Explanation:
Each comparison cuts the problem size in half → logarithmic time.


Question 10

In Fibonacci recursion, how many recursive instances can be seen?

0
1
2

Explanation:
Each Fibonacci call makes two recursive calls:
fib(n-1) and fib(n-2).


🧾 Summary Table

Question Correct Answer Key Concept
Q1 False Sorting algorithms
Q2 4 Insertion sort
Q3 O(n) Linear search
Q4 Relative metric Big-O notation
Q5 Parallel execution Parallelization
Q6 Divide & conquer Recursion
Q7 Store sub-results Memoization
Q8 Global vs local optimum DP vs Greedy
Q9 Halving input Binary search
Q10 2 Recursion tree