![]() ![]() If we haven't yet reached the base case, we again divide both these subarrays and try to sort them. In the conquer step, we try to sort both the subarrays A and A. ![]() If q is the half-way point between p and r, then we can split the subarray A into two arrays A and A. ![]() A subproblem would be to sort a sub-section of this array starting at index p and ending at index r, denoted as A. When the solution to each subproblem is ready, we 'combine' the results from the subproblems to solve the main problem. Using the Divide and Conquer technique, we divide a problem into subproblems. Finally, sub-problems are combined to form the final solution. Here, a problem is divided into multiple sub-problems. Merge Sort is one of the most popular sorting algorithms that is based on the principle of Divide and Conquer Algorithm.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |