Question: CSCI-311 Training Insertion, Partition, Quicksort, Mergesort Problem 1. Given the code for insertion sort and a vector v with integers, show the content of the

 CSCI-311 Training Insertion, Partition, Quicksort, Mergesort Problem 1. Given the code

CSCI-311 Training Insertion, Partition, Quicksort, Mergesort Problem 1. Given the code for insertion sort and a vector v with integers, show the content of the vector v after each iteration of the for loop (i.e. after iteration with i = 1, then after iteration when i = 2, ...). I showed an example of what is expected the content of v after the first iteration with i = 1. void insertion(vector int> &v){ v at the beginning int size = v.size(); 14 9 15 12 8 for(int i = 1; i = 0 && v[j] > key){ v[j+1] = v[j]; v after the iteration i = 2 --; }//while v[j+1] = key; v after the iteration i = 3 }//for }//insertion v after the iteration i = 4 BAA 3 4 8 Problem 2. Given the code for partition function, run partition on the given array A below, show A after each iteration of while loop (that starts at line 4 and ends at line 16): 1 int partition (vector 6A, int low, int high) { 2 int pivot = A[high]; int i = low, j - high - 1; while(i - low && A[i] > pivot) j--; if(i

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 Databases Questions!