Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void wstaw(struct Wezel *start, int wartosc)
- {
- if(root == NULL)
- {
- root = (struct Wezel *)malloc(sizeof(struct Wezel));
- root->wartosc = wartosc;
- root->lewySyn = NULL;
- root->prawySyn = NULL;
- root->rodzic = NULL;
- }
- else if(wartosc < start->wartosc)
- {
- if(start->lewySyn != NULL)
- wstaw(start->lewySyn, wartosc);
- else
- {
- struct Wezel *nowy = (struct Wezel *)malloc(sizeof(struct Wezel));
- nowy->wartosc = wartosc;
- nowy->lewySyn = NULL;
- nowy->prawySyn = NULL;
- nowy->rodzic = start;
- start->lewySyn = nowy;
- }
- }
- else
- {
- if(start->prawySyn != NULL)
- wstaw(start->prawySyn, wartosc);
- else
- {
- struct Wezel *nowy = (struct Wezel *)malloc(sizeof(struct Wezel));
- nowy->wartosc = wartosc;
- nowy->lewySyn = NULL;
- nowy->prawySyn = NULL;
- nowy->rodzic = start;
- start->prawySyn = nowy;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement