Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. template<typename TKey, typename TValue>
  2.  
  3. class avltree{
  4. private:
  5.     // called by both clear() and ~avltree() to clear avl tree.
  6.     _clearMemory(){
  7.     }
  8.  
  9. public:
  10.     // constructors:
  11.    
  12.     // default
  13.     avltree(){
  14.  
  15.  
  16.     }
  17.    
  18.     //  copy constructor
  19.     avltree(avltree& other){
  20.  
  21.     }
  22.  
  23.     int size(){
  24.    
  25.     }
  26.    
  27.     int height(){
  28.  
  29.     }
  30.  
  31.     // empties tree
  32.     void clear(){
  33.         _clearMemory();
  34.         // TODO: When clear returns, the root should be nullptr and the size 0
  35.     }
  36.  
  37.     TValue* search(TKey key){
  38.     }
  39.  
  40.     void insert(){
  41.        
  42.     }
  43.    
  44.     /*
  45.         returns path length between 2 keys
  46.         (the length of the minimum path)
  47.        
  48.     */
  49.     int distance(TKey k1, TKey k2){  // distance
  50.         //int distance = -1;
  51.  
  52.         if k1 or k2 does not exist in the tree  
  53.             return -1
  54.  
  55.         else if(k1 == k2)
  56.             return 0;
  57.     }
  58.  
  59.     void inorder(){
  60.  
  61.     }
  62.  
  63.     std::vector<TKey> inorder_keys(){
  64.     }
  65.  
  66.     std::vector<TValue> inorder_values(){
  67.     }
  68.  
  69.     std::vector<int> inorder_heights(){
  70.     }
  71.  
  72.     //destructor - TODO: checked using valgrind (week 5 labs)
  73.     virtual ~avltree(){
  74.         _clearMemory();
  75.     }
  76.  
  77.  
  78. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement