Adil Khan 7 years ago
AdiKhanOfficial #Data Structures

C++ Program for Insertion Sort

#include <iostream>

using namespace std;

void insertionSort(int *arr,int n){

  int i, temp, j;
  for (i = 1; i < n; i++)
  {
    temp = arr[i];
    j = i-1;

    while (j >= 0 && arr[j] > temp)
    {
      arr[j+1] = arr[j];
      j = j-1;
    }
    arr[j+1] = temp;
  }

}

int main()
{
  int arr[5],counter=0;
  for(int i=0;i<5;i++){
    cout<<"Enter a Number : ";
    cin>>arr[i];
    counter++;
    insertionSort(arr,counter);

    for(int j=0;j<counter;j++){
      cout<<arr[j]<<" ";
    }
    cout<<endl;



  }
  return 0;
}


0
1.3K
Face Recognition Base Attendance System

Face recognition-based attendance system is a process of recognizing the students face for...

1675638330.png
Adil Khan
1 year ago
Blockchain based NGO

Blockchain innovation and conveyed records are drawing enormous consideration and trigger...

1675638330.png
Adil Khan
1 year ago
Voice Enabled WheelChair

IOT Based Voice Enabled Wheel Chair is a project for the wheel chair patients who cannot m...

1675638330.png
Adil Khan
1 year ago
Automatic Washing Station for Bus

There are three stages of our FYP.The first stage is related to cleaning of Bus tyres and...

1675638330.png
Adil Khan
1 year ago
Rockwell

Rockwell is an android application that deals in property and all types of businesses invo...

1675638330.png
Adil Khan
1 year ago