Panda Guru LogoPanda
Guru

Insertion Sort || JAVA || Explained

Round 1

Questions: Specific question not provided.

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.


Round 2

Questions: Insertion Sort
image
image
image
image

class Solution{ public int insert(int arr[]){ int n = arr.length; for(int i = 1; i< n; i++){ int curr = arr[i]; int prev = i - 1; while(prev >= 0 && arr[prev] > curr){ // Filling the blank space arr[prev + 1] = arr[prev]; // moving the pointer in the sorted array prev--; } // Filling the current variable where it is supposed to be, we checked prev < curr, so the next place will be where curr is supposed to be placed, i.e, prev + 1 arr[prev + 1] = curr; } } }
Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.