forked from gzc/CLRS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathp_queue.h
33 lines (29 loc) · 766 Bytes
/
p_queue.h
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
/*************************************************************************
> File Name: p_queue.h
> Author: Louis1992
> Mail: [email protected]
> Blog: http://gzc.github.io
> Created Time: Sun Jan 4 19:16:19 2015
************************************************************************/
#ifndef _P_QUEUE_H
#define _P_QUEUE_H
#endif
#include <iostream>
class p_queue
{
public:
p_queue(int *A, int n);
void insert(int x);
int maximum(void);
int extract_max(void);
void increase_key(int i, int x);
private:
int a[10000];
int size;
int parent(int i);
int left(int i);
int right(int i);
void maxHeapify(int A[], int n, int i);
void buildMaxHeap(int A[], int n);
void heapsort(int A[], int n);
};