Question: Question 5 ( 2 points ) Gianluca wants to sort the array arr. He writes the following Java code to do this. Which sorting algorithm

Question 5(2 points)
Gianluca wants to sort the array arr. He writes the following Java code to do this. Which sorting algorithm has he implemented?
```
void sort(int arr[])
{
int n = arr.length;
for (int i =1; i n; ++i){
int key = arr[i];
int j = i -1;
// move elements of arr[0..i-1], that are
// greater than key, one position towards higher indexes
while (j >=0 && arr[j]> key){
arr[j +1]= arr[j];
}
j = j -1;
//place key in its new position
arr[j +1]= key;
}
}
```
quicksort
insertion sort
bubble sort
merge sort
selection sort
Question 5 ( 2 points ) Gianluca wants to sort

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!