We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 943b52a commit cc7793cCopy full SHA for cc7793c
include/heap.h
@@ -61,7 +61,7 @@ namespace alg {
61
public:
62
Heap(int max) {
63
m_size = 0;
64
- m_max = max+1;
+ m_max = max;
65
m_heap = new elem[m_max];
66
};
67
@@ -101,7 +101,7 @@ namespace alg {
101
inline void clear() { m_size = 0; }
102
103
bool contains(const T & data) {
104
- for(int i=1;i<=m_size;i++) {
+ for(int i=0;i<m_size;i++) {
105
if(m_heap[i].data== data) return true;
106
}
107
return false;
@@ -166,7 +166,7 @@ namespace alg {
166
167
168
int j = j1;
169
- int j2 = j1+1; // left child
+ int j2 = j1+1; // right child
170
if (j2 < n && !less(j1,j2)) {
171
j = j2; // choose the minium one.
172
0 commit comments