0
0
DSA C++programming~5 mins

Merge Sort Algorithm in DSA C++ - 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 divides the list into two halves, sorts each half, and then merges the two sorted halves back together.
Click to reveal answer
beginner
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.
Click to reveal answer
intermediate
Why does Merge Sort require extra space?
Merge Sort needs extra space to hold temporary arrays during the merging process because it combines two sorted lists into one.
Click to reveal answer
intermediate
Explain the merge step in Merge Sort.
The merge step takes two sorted halves and compares their elements one by one, placing the smaller element into a new array until all elements are merged in sorted order.
Click to reveal answer
intermediate
Is Merge Sort a stable sorting algorithm? Why or why not?
Yes, Merge Sort is stable because it preserves the relative order of equal elements during the merge step.
Click to reveal answer
What technique does Merge Sort use to sort the array?
ADivide and conquer
BGreedy
CDynamic programming
DBrute force
What is the space complexity of Merge Sort?
AO(1)
BO(n log n)
CO(log n)
DO(n)
During the merge step, what happens when elements from both halves are equal?
AThe element from the right half is chosen first
BThe element from the left half is chosen first
CBoth elements are skipped
DThe algorithm stops
Which of the following is true about Merge Sort's performance?
AIt always divides the array into halves
BIt has a worst-case time complexity of O(n^2)
CIt is faster than Quick Sort in all cases
DIt sorts in place without extra memory
What is the base case for the recursive Merge Sort function?
AWhen the array has more than two elements
BWhen the array is fully sorted
CWhen the array has one or zero elements
DWhen the array is empty
Describe step-by-step how Merge Sort sorts an array of numbers.
Think about splitting, sorting smaller parts, and merging.
You got /3 concepts.
    Explain why Merge Sort is considered a stable sorting algorithm.
    Focus on how equal elements are handled during merging.
    You got /3 concepts.