Skip to content

Commit

Permalink
修正了堆插入操作的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev-XYS committed Jan 24, 2017
1 parent 579b4b4 commit 2643637
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Min-Heap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ void insert(int x)
H[++heapsize] = x;

int ch = heapsize, p = heapsize >> 1;
while (H[p] > H[ch] && p > 1)
while (H[p] > H[ch] && p >= 1)
{
int temp = H[p];
H[p] = H[ch];
H[ch] = temp;

ch = p;
p = ch >> 1;
p >>= 1;
}
}

Expand Down

0 comments on commit 2643637

Please sign in to comment.