Advertisement
rupek1995

C DRZEVO

Nov 26th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. typedef struct _NODE_s {
  4.     int value;
  5.     struct _NODE_s *left;
  6.     struct _NODE_s *right;
  7.     struct _NODE_S *node;
  8. } NODE_s;
  9.  
  10. int search(NODE_s *root, int value) {
  11.     NODE_s *current;
  12.     current = root;
  13.    
  14.     while(current != NULL) {
  15.        
  16.         if(current->value==value) {
  17.             return 1;  
  18.             }
  19.         else if(value < current->value)
  20.             current = current->left;
  21.  
  22.         else
  23.             current = current->right;
  24.         }
  25.    
  26.     return 0;
  27. }
  28.  
  29. void insert(NODE_s *root, int value) {
  30.     NODE_s *current;
  31.     current = root;
  32.     NODE_s *parent;
  33.     parent = root;
  34.    
  35.     while(current != NULL) {
  36.            
  37.         if(value < current->value) {
  38.             parent = current;
  39.             current = current->left;   
  40.         }
  41.  
  42.         else if(value > current->value)
  43.             parent = current;
  44.             current = current->right;
  45.         }
  46.    
  47.     if(value <parent->value) {
  48.        
  49.     }
  50. }
  51.  
  52.  
  53. int main( int argc, const char* argv[] )
  54. {
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement