-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverification.h
64 lines (56 loc) · 1.14 KB
/
verification.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <time.h>
#include"./traversal_methods.h"
tree* create_tree(tree* root);
void reset_visited(tree* node);
tree* create_tree(tree* root){
int val;
srand(time(NULL));
for (int i = 0; i < 10; i++)
{
val=rand()%1000;
root=insert(root,val);
}
return root;
}
void reset_visited(tree* node) {
if (node!=NULL) {
ass_visited(node,false);
reset_visited(fg(node));
reset_visited(fd(node));
}
}
void branch_verpre(tree* root,tree tab[],int* index){
if (root!=NULL)
{
tab[*index]=*root;
(*index)++;
//printf("| %d |",value(root));
branch_verpre(fg(root),tab,index);
branch_verpre(fd(root),tab,index);
}
}
void branch_trav(tree tab[],int size){
tree* node;
stack s;
create_stack(&s);
for (int i = 0; i < size; i++)
{
push(&s,(tab+i));
if (tab[i].fg==NULL && tab[i].fd==NULL)
{
while (!empty_stack(s))
{
pop(&s,&node);
printf("%d |",value(node));
}
}
}
}
void preorder(tree* root){ // <Root> <left> <Right>
if (root!=NULL)
{
printf("| %d |",value(root));
preorder(fg(root));
preorder(fd(root));
}
}