247 views
0 votes
0 votes
Given an algorithm:

void preorder(tree *t)

{

if(t)

{

1. if(t->data==NULL)

return ;

else printf(t->data);

2. preorder(t->left);

3. preorder(t->right);

 }

}

Find the number of function calls made for traversing for preorder following above algorithm,for th below given tree;

                                                                        A

                                                                    /       \

                                                                  B         C

                                                                 /              \

                                                               D                  E

                                                                  \               /     

                                                                    F           G

1 Answer

0 votes
0 votes
Seems to be  15  Iterations. Though , not sure !!

Related questions

0 votes
0 votes
2 answers
1
Sourin Kundu asked Jan 23, 2023
396 views
How many number of add and remove operations are required to access 26th element of a queue of 50 elements,so that the original queue remains the same after the access is...
0 votes
0 votes
2 answers
2
Overflow04 asked Oct 2, 2022
333 views
#include <stdio.h int main(){ int a[] = {5,3,7,2,4}; int *p = &a[3]; p -= *p; printf("%d ",*p); return 0; } output is 3.Why 2 * sizeof(int) is doene.?
1 votes
1 votes
0 answers
3
srestha asked Mar 6, 2019
750 views
void find(int x){ static int i=10,y=0; y=y+i; for(i;i>0;i=i-10){ if(x!=0) find(x-1); else{ printf("%d",y); } } }What will be output printed for find(4)?
0 votes
0 votes
1 answer
4