Insertion Sort
Elementary Sorting Algorithms DSA practice problem on Onlearn.
Difficulty: easy.
Topics: Implementing Insertion Sort on an Array, Arrays, Sorting, Loops, Time Complexity, Space Complexity, Big O Notation, sorting algorithms, space complexity, time complexity analysis, array manipulation, Insertion Sort.
Problem Statement: Given an array of N integers, implement the Insertion Sort algorithm to sort the array in ascending order. Input Specification: The first line contains an integer N, the size of the array. The second line contains N space separated integers representing the elements of the array. Output Specification: Print the N space separated integers representing the sorted array. Sample Test Cases: Example 1: Input: 6 13 46 24 52 20 9 Output: 9 13 20 24 46 52 Example 2: Input: 5 5 4 3 2 1 Output: 1 2 3 4 5