-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinaryheap.cpp
More file actions
47 lines (44 loc) · 817 Bytes
/
binaryheap.cpp
File metadata and controls
47 lines (44 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<bits/stdc++.h>
using namespace std;
#define pf printf
#define sf(a) scanf("%d",&a)
#define sf(a,b) scanf("d",&a,&b)
#define sfc1(a) scanf("%c",&a)
struct heap
{
int n;
int capacity=0;
heap(int inp){
n=inp;
}
int *heaparr = new int[n];
int parent(int child);
int left(int parent);
int right(int parent);
void insertval(int val);
int getmin();
void delmin();
void decreasekey(int i,int val);
};
int heap :: parent(int child)
{
return (child-1)/2;
}
int heap :: left(int parent)
{
return 2*parent+1;
}
int heap :: right(int parent)
{
return 2*parent+2;
}
void heap :: insertval(int val)
{
if(capacity==n){
cout<<"overloaded"<<endl;
return;
}
}
int main()
{
}