solution need

Views: 706

Attachments:

Replies to This Discussion

CS301... Sol

Attachments:

kiya ye assignment no: 3 ka solution hai

idea Correct Codding

#include<iostream>
#include <conio.h>
using namespace std;
void min_heapify(int *a,int i,int n)
{
int j, temp;
temp = a[i];
j = 2 * i;
while (j <= n)
{
if (j < n && a[j+1] < a[j])
j = j + 1;
if (temp < a[j])
break;
else if (temp >= a[j])
{
a[j/2] = a[j];
j = 2 * j;
}
}
a[j/2] = temp;
return;
}
void build_minheap(int *a, int n)
{
int i;
for(i = n/2; i >= 1; i--)
{
min_heapify(a,i,n);
}
}
int main()
{
int n, i, x;
cout"enter no of elements of array\n";
cin>>n;
int a[20];
for (i = 1; i <= n; i++)
{
cout"enter element"(i)endl;
cin>>a[i];
}
build_minheap(a, n);
cout"Min Heap\n";
for (i = 1; i <= n; i++)
{
couta[i]endl;
}
getch();
}

CS301 SOl...

Attachments:

RSS

Discussion Forum

CS301 GDB Solution Spring 2018

Started by Mian Sufyan.
Last reply
by + caмe4ѕтυdιeѕ on Thursday. 2 Replies

CS301 Assign # 3 Due Date: 26th June, 2018

Started by Iqra Mubasher.
Last reply
by + ! ! ! ! CS Jul 26. 4 Replies

CS301 Assign # 2 Due Date: 28th May, 2018

Started by + caмe4ѕтυdιeѕ.
Last reply
by anum May 29. 5 Replies

CS301 assignment no 1 spring 2018

Started by Iqra Mubasher.
Last reply
by Iqra Mubasher May 8. 2 Replies

SPONSORED LINKS

© 2018   Created by Muhammad Anwar Tahseen.   Powered by

Badges  |  Report an Issue  |  Terms of Service