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.2K
Obstacle Avoidance using Stereo Camera

The main aim of our project is to develop an anti-collision system for a quadrotor which c...

1675638330.png
Adil Khan
1 year ago
Single Phase Seven level multi inverter using cascaded system

This proposed inverter consists of an H Bridge circuit with 12 switching devices, three un...

1675638330.png
Adil Khan
1 year ago
Deep Learning based Surface Defect Detection of Rail Tracks

&nbsp; Benefits of the Project (less than 2500 characters)

1675638330.png
Adil Khan
1 year ago
ACADEMIC DEPARTMENT COORDINATION INFORMATION SYSTEM (ADCIS)

In a general sense, the term information system (IS) refers to a system of people, data re...

1675638330.png
Adil Khan
1 year ago
Solar Panel Simulator

We created a power supply with the current and voltage characteristics of a thin film sola...

1675638330.png
Adil Khan
1 year ago