Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool check_heap(int* heap, unsigned n)
- {
- for (unsigned i = 0; i <= (n - 2) / 2; ++i)
- {
- if (heap[2 * i + 1] > heap[i])
- return false;
- if (2 * i + 2 < n && heap[2 * i + 2] > heap[i])
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement