Advertisement
ahmad_zizo

tree.h

May 31st, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. //
  2. // trees.h
  3. // final-trial
  4. //
  5. // Created by Ahmed Omar on 5/27/14.
  6. // Copyright (c) 2014 Ahmed Omar. All rights reserved.
  7. //
  8.  
  9. #ifndef final_trial_trees_h
  10. #define final_trial_trees_h
  11.  
  12. #include <stdlib.h>
  13. #include <stdio.h>
  14.  
  15. struct bin_tree {
  16. int id;
  17. char name[40];
  18. struct bin_tree * right, * left, *parent;
  19. };
  20.  
  21. struct bin_tree_pointers {
  22. int id;
  23. char name[40];
  24. struct bin_tree_pointers* right, *left;
  25. };
  26.  
  27. typedef struct bin_tree node_id;
  28. typedef struct bin_tree_pointers node_name;
  29.  
  30. node_id* insert_id(node_id* tree, int id, char* name);
  31. node_id* insert_name(node_id* tree, int id, char* name);
  32. void insert(node_id** tree_id, node_id** tree_name, int id, char* name);
  33.  
  34. node_id* search_id(node_id** tree, int id);
  35. //node_id *search_name(node_id** tree, char* name);
  36. void search_name(node_id* root , char *name , node_id* ptrarray[] , int*n)
  37.  
  38. void search_id_2(node_id** tree, int id);
  39. void search_name_2(node_id** tree, char* name);
  40.  
  41.  
  42.  
  43. node_id * min_value_node_id(node_id* node);
  44. node_id * min_value_node_name(node_id* node);
  45.  
  46.  
  47. node_id* delete_id(node_id* tree, int id);
  48. node_id* delete_name(node_id* tree, char* name, int c);
  49.  
  50. //in this functions we will use delete_id and delete_name
  51. void del_id(node_id** tree_id, node_id** tree_name, int id);
  52. void del_name(node_id** tree_id, node_id** tree_name, char* name);
  53.  
  54. void deltree(node_id* tree_id, node_id** tree_name);
  55. void print_preorder(node_id* tree,int c);
  56. void print_inorder(node_id* tree,int c);
  57. void print_postorder(node_id* tree, int c);
  58.  
  59. /*void print_preorder(node_id* tree, int c);
  60. void print_inorder(node_id* tree, int c);
  61. void print_postorder(node_id* tree, int c);*/
  62.  
  63. void reed_file_to_tree(node_id** tree_id, node_id** tree_name, char* file_name);
  64. void write_tree_to_file(node_id* tree_id, FILE* fp);
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement