Advertisement
Aldin-SXR

size()

May 12th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.27 KB | None | 0 0
  1. /* Return the size of the BST (total number of nodes) */
  2. public int size() {
  3.     return size(root);                          // 1
  4. }
  5.    
  6. /* Private size() method */
  7. private int size(Node<Key, Value> x) { 
  8.     if (x == null) {                            // 2
  9.         return 0;                               // 2
  10.     }
  11.     return x.size;                              // 3
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement