Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool MyHeap::display()
- {
- if(!heapLength)
- return 0;
- int specialLevel = 2;
- int elementsToDisplay = 1;
- int index = 0;
- while (specialLevel * 2 <= heapLength)
- specialLevel *= 2;
- specialLevel--;
- for(; specialLevel > 0 && heapLength > 1; specialLevel/=2, elementsToDisplay *= 2)
- {
- cout << " ";
- for (int x = 0; x < elementsToDisplay; x++, index++)
- {
- if(x == 0)
- {
- for (int space = 0; space < specialLevel / 2; space++)
- cout << " ";
- }
- else
- {
- for (int space = 0; space < specialLevel; space++)
- cout << " ";
- }
- printf("%3d ",mainHeap[index]);
- }
- cout << endl;
- }
- for (; index < heapLength; index++)
- {
- printf("%3d ", mainHeap[index]);
- }
- cout << endl;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement