Advertisement
ahmad_zizo

:3

Jun 1st, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. node_id* delete_name(node_id* tree, char name[],int id)
  2. {
  3. if (tree == NULL)
  4. return tree;
  5. if (strcmp(name, tree->name) > 0)
  6. tree->left = delete_name(tree->left, name,id);
  7. else if (strcmp(name, tree->name) < 0)
  8. tree->right = delete_name(tree->right, name,id);
  9. else
  10. {
  11. if (tree->left == NULL)
  12. {
  13. node_id* temp = tree->right;
  14. free(tree);
  15. return temp;
  16. }
  17. else if (tree->right == NULL )
  18. {
  19. node_id* temp = tree->left;
  20. free(tree);
  21. return temp;
  22. }
  23. node_id* temp = min_value_node_id(tree->right);
  24. strcpy(tree->name, temp->name);
  25. tree->id = temp->id;
  26.  
  27. tree->right = delete_name(tree->right, temp->name,id);
  28. }
  29. return tree;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement