Question: Q 7 ( 1 0 ) : What will be the output of the following program? public static void insertionSort ( int [ ] data

Q7(10): What will be the output of the following program?
public static void insertionSort(int[] data)
{
for (int index =1; index data.length; index++)
{
int key = data[index];
int position = index;
while (position >0 && data[position-1]>key)
{
data[position]= data[position-1];
position--;
}
System.out.println (position);
data[position]= key;
}
}
public static void main(String[] args){
int [] arr={34,12,37,5,19,11};
insertionSort(arr);
}
Output:
 Q7(10): What will be the output of the following program? public

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!