Guest User

Untitled

a guest
Oct 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. struct Element {
  2. int key;
  3. };
  4.  
  5. void BuildHeap(Heap* heap, struct Element A[], int n, int f)
  6. {
  7. // n is set to be 12 since its the # of elements in the array A
  8.  
  9. struct Element extra[n+1];
  10. extra[0].key = n;
  11.  
  12. for(int p = 1; p <= n; p++)
  13. {
  14. extra[p] = A[p-1];
  15. }
  16.  
  17. cout << "size of extra: " << sizeof(extra) << endl;
  18. // prints out 52 since i set 13 spaces in the array
  19. cout << "size of extra[0]: " << sizeof(extra[0]) << endl;
  20. // prints out 4 since there is only one integer held in struct
  21.  
  22. Max_Heapify(extra, 1);
  23. }
  24.  
  25. void Max_Heapify( Element Arr[], int i)
  26. {
  27. int left = LEFT(i);
  28. int right = RIGHT(i);
  29.  
  30. cout << "size of array: " << sizeof(Arr) << endl;
  31.  
  32. int largest = 0;
  33. int totalsize = (sizeof(Arr) / sizeof(Arr[0])) - 1;
  34. cout << "total size: " << totalsize << endl;
  35. }
Add Comment
Please, Sign In to add comment