• Works on sorted and unsorted data.
• Examines elements sequentially.
• Time Complexity: O(n)
Binary Search
• Requires sorted data.
• Divides the search space into halves.
• Time Complexity: O(log n)
Binary Search is much faster than Linear Search for large sorted datasets.
1️⃣0️⃣0️⃣ What is Merge Sort?
Answer:
Merge Sort is a Divide and Conquer sorting algorithm that recursively divides an array into smaller halves, sorts them, and then merges the sorted halves.
Steps:
1. Divide the array into two halves.
2. Recursively sort each half.
3. Merge the sorted halves into one sorted array.
Time Complexity:
• Best Case: O(n log n)
• Average Case: O(n log n)
• Worst Case: O(n log n)
Advantages:
• Stable sorting algorithm
• Efficient for large datasets
• Guarantees consistent performance
🔥 Double Tap ❤️ For Part-10
Post #2764
2.07K
- ❤ 4