0
0
DSA Javascriptprogramming~5 mins

Merge Sort Algorithm in DSA Javascript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main idea behind the Merge Sort algorithm?
Merge Sort works by dividing the list into smaller parts, sorting each part, and then merging them back together in order.
Click to reveal answer
intermediate
What is the time complexity of Merge Sort in the average and worst cases?
The time complexity of Merge Sort is O(n log n) for both average and worst cases, where n is the number of elements to sort.
Click to reveal answer
intermediate
Why is Merge Sort considered a stable sorting algorithm?
Merge Sort is stable because it keeps the original order of equal elements when merging the sorted parts.
Click to reveal answer
beginner
Show the basic steps of Merge Sort on the array [4, 1, 3, 2].
Step 1: Divide into [4,1] and [3,2]<br>Step 2: Divide further to [4], [1], [3], [2]<br>Step 3: Merge [4] and [1] to get [1,4]<br>Step 4: Merge [3] and [2] to get [2,3]<br>Step 5: Merge [1,4] and [2,3] to get [1,2,3,4]
Click to reveal answer
intermediate
What is the space complexity of Merge Sort and why?
Merge Sort has a space complexity of O(n) because it requires extra space to hold the temporary arrays during the merge process.
Click to reveal answer
What technique does Merge Sort use to sort an array?
ABrute force
BDivide and conquer
CDynamic programming
DGreedy approach
Which of the following is true about Merge Sort?
AIt is a stable sorting algorithm
BIt has a worst-case time complexity of O(n^2)
CIt sorts in place without extra space
DIt only works on sorted arrays
What is the first step in the Merge Sort algorithm?
ADivide the array into halves
BMerge two sorted arrays
CCompare all elements
DSwap elements
How does Merge Sort combine the divided parts?
ABy reversing the arrays
BBy swapping elements randomly
CBy sorting each part separately without merging
DBy merging sorted subarrays
What is the space complexity of Merge Sort?
AO(1)
BO(log n)
CO(n)
DO(n^2)
Explain how Merge Sort sorts an array step-by-step.
Think about breaking the problem into smaller pieces and then combining them.
You got /4 concepts.
    Describe the advantages and disadvantages of using Merge Sort.
    Consider speed, memory use, and stability.
    You got /4 concepts.