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
|
888 Discussions
|
Please Login in order to post a comment
JAVA int key = arr.get(n - 1); int j = n - 2;
Here is my c++ solution, you can watch the explanatoin here : https://youtu.be/xFqneyHR96g
C# Solution
!/bin/python3
import math import os import random import re import sys
#
Complete the 'insertionSort1' function below.
#
The function accepts following parameters:
1. INTEGER n
2. INTEGER_ARRAY arr
#
def insertionSort1(n, arr): # Write your code here for i in range(n): j = i curr = arr[i] if curr < arr[j-1]: while j > 0 and curr < arr[j-1]: arr[j]= arr[j-1] j-=1 print(*arr)
if name == 'main': n = int(input().strip())