Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. int node_insert(node_t *n, int data)
  2. {
  3. while (1)
  4. {
  5. if (data < n->data)
  6. {
  7. if (n->left)
  8. {
  9. n = n->left;
  10. }
  11. else
  12. {
  13. n->left = node_init(data);
  14. return 0;
  15. }
  16. }
  17. else if (data > n->data)
  18. {
  19. if (n->right)
  20. {
  21. n = n->right;
  22. }
  23. else
  24. {
  25. n->right = node_init(data);
  26. return 0;
  27. }
  28. }
  29. else
  30. {
  31. return 1;
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement