AVLCommands.h 915 B

123456789101112131415161718192021222324252627
  1. // include guard
  2. #ifndef AVLC_H
  3. #define AVLC_H
  4. #include <iostream>
  5. #include <cstdio>
  6. #include <string>
  7. #include "json.hpp"
  8. #include "BST.h"
  9. class AVLCommands{
  10. int *heapArray; // pointer to heap array
  11. int max_size; // max size of heap array
  12. int heap_size; // elements in heap
  13. void swap(int*, int*); // swaps two keys in the heap
  14. void heapifyUp(int); // moves keys up if they are larger than their parent key
  15. void heapifyDown(int); // moves keys down if they are smaller than their parent key
  16. public:
  17. // required functions from PDF
  18. void Insert(int key); // inserts a new key into AVL tree
  19. void Delete(int key); // deletes specified key
  20. void DeleteMin(); // removes the minimum value key
  21. // helpful functions
  22. void printJSONTree(int, int); // prints the heap as a JSON object
  23. };
  24. #endif