Algorithm: Insertion Sort

Goal: Sort an array of numbers in ascending order using Insertion Sort.

Steps:

  1. Start
  2. Input n (number of elements in the array).
  3. Input the array arr[0…n-1].
  4. Fori = 1 to n-1:
    • Set key = arr[i].
    • Set j = i - 1.
    • Whilej >= 0 and arr[j] > key:
      • Set arr[j+1] = arr[j].
      • Decrement j = j - 1.
    • Set arr[j+1] = key.
  5. Print the sorted array.
  6. Stop.

Flowchart: Insertion Sort

पुढे वाचा

Algorithm: Bubble Sort

Algorithm: Binary Search

Algorithm and flowchart to Search a particular data from the given Array of numbers using: Linear Search Method.

Simple algorithm To Create, Insert, Delete, and Display elements in an array.

Bubble Sort Demonstration

Leave a comment