Divide and Conquer Visualizer

Divide and Conquer: Basic Idea

The divide and conquer approach involves breaking a problem into smaller subproblems. Once the solutions to the subproblems are found, they are combined to obtain a final solution.

Examples of Divide and Conquer

Some common examples of divide and conquer algorithms include binary search and merge sort.

Binary Search

Binary search is a searching algorithm that finds the position of a target element within a sorted array. The algorithm works by repeatedly dividing the search interval in half.

Steps

Time Complexity

binary search visualization

Merge Sort

Merge sort is a sorting algorithm that uses the divide and conquer approach to sort an array. The array is split into two halves, each half is sorted, and then they are merged back together.

Time Complexity

The best, worst, and average case time complexity of merge sort is O(n log n). Splitting takes O(log n) and merging takes O(n).

merge sort visualization