We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Insertion Sort - Part 1
Insertion Sort - Part 1
Sort by
recency
|
874 Discussions
|
Please Login in order to post a comment
JAVA 8 public static void insertionSort1(int n, List arr) { // Write your code here int key=arr.get((arr.size()-1)); for(int i=arr.size()-1;i>=0;i--){ if((i-1)<0){ arr.set(0,key); for(int j:arr){ System.out.print(j+" "); } } else if((arr.get(i-1)>=0)&& arr.get(i-1)>key){ arr.set(i,arr.get(i-1)); for(int j:arr){ System.out.print(j+" ");
js
My code in JAVA
public static void insertionSort1(int n, List arr) {
}
JS
Here is my c++ solution, you can watch the explanatoin here : https://youtu.be/xFqneyHR96g