You are using a version without Ads of this website. Please, consider donating:

### Algorithm Required

Can anyone please send me the Algorithm for Stack using pointers and queue using pointers in C+
If you want the algorithm, which is instruction using pseudo code, then you find find them by doing a search on Google. However if you want the implementation then you will have to do it yourself and if you stuck then you can post your code and question on the board and people will help you, they, however, will not write your code for you.
Thanks Longazan.
Need the algorithm for the given program.

//HEAP SORT
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
int a[20],i,j,n,temp;
void sort(int k)
{
while(k>1)
{
for(i=2;i<=k;i++)
{
j=i;
do{
if(a[j]>a[j/2])
{
temp=a[j];
a[j]=a[j/2];
a[j/2]=temp;
j=j/2;
}
else
j=1;
}
while(j!=1);
}
cout<<"\n";
for(i=1;i<=k;i++)
cout<<" "<<a[i];
cout<<"\n\n";
temp=a[1];
a[1]=a[k];
a[k]=temp;
k=k-1;
};
}
void main()
{
clrscr();
cout<<"\n\t\t\t ***HEAP SORT***";
cout<<"\n\n Enter the number of elements:";
cin>>n;
cout<<"\n\n Enter the elements to be sorted:";
for(i=1;i<=n;i++)
cin>>a[i];
cout<<"\n\n The heap after each step: \n";
sort(n);
cout<<"\n\n\n Sorted list:";
for(i=1;i<=n;i++)
cout<<" "<<a[i];
getch();
}
Topic archived. No new replies allowed.