Question: How is this pseudo code correct. At the last recursive call when it does My _ sort ( A [ 2 : 2 ] )

How is this pseudo code correct. At the last recursive call when it does My_sort(A[2:2]) which returns 40. Then it goes back up the tree right to the previous recursive call My_sort(A[2:3] which includes 5 and 40 right. And the code picks up where it left off at j=2 so then key =5 and A[j]=40 so then continuing with the code why is it swapping if key is less then j if key is on the left isnt that already the correct order. It is 1 based indexing as well. Please help me understand preferabbly draw the recursion tree with more detail or include detail explanation of how we go to the base case and back up the tree .
How is this pseudo code correct. At the last

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!