# VU HELP

Virtual University of Pakistan Study forum !

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

solution need

Views: 733

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:

## Discussion Forum

### CS301 GDB Solution Spring 2018

Started by Mian Sufyan.
by + caмe4ѕтυdιeѕ Aug 9.

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

Started by Iqra Mubasher.
by + ! ! ! ! CS Jul 26.

### CS301 SPRING 2018 MID TERM PAPERS FROM 24 JUNE 2018 TO 04 JULY 20185

Started by Cute S@mra.
by Cute S@mra Jul 1.

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

Started by + caмe4ѕтυdιeѕ.