Advertisement
nato_fernandes

Untitled

Mar 1st, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <stdlib.h>
  2.  
  3. #include "bst.h"
  4.  
  5. BST BSTmake(int key, BST lt, BST rt) {
  6. BST newnode = malloc(sizeof(struct bst_node));
  7. newnode->key = key;
  8. newnode->left = lt; newnode->right = rt;
  9. return newnode; }
  10.  
  11. void BSTdestroy(BST t) {
  12. if (t == NULL) return;
  13. else {
  14. BSTdestroy(t->left); BSTdestroy(t->right);
  15. free(t); }}
  16. int BSTkey(BST t) { return t->key; }
  17. BST BSTleft(BST t) { return t->left; }
  18. BST BSTright(BST t) { return t->right; }
  19. BST BSTempty() { return NULL; }
  20. bool BSTisempty(BST t) { return (t == NULL); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement