in GATE retagged by
163 views
0 votes
0 votes

Consider the following algorithm:

ORDER (T)
begin
if (T!=NULL) then
begin
ORDER (LPTR(T))
PRINT (DATA(T))
ORDER (RPTR(T))
end
return
end

where LPTR: left pointer
RPTR: right pointer
T: given tree


This above algorithm is used to:

  1.   Traverse the tree in preorder in a recursive manner
  2.   Traverse the tree in in-order, in a recursive manner
  3.   Traverse the tree in post-order in a recursive manner
  4.    Do not Traverse the tree at all
in GATE retagged by
by
163 views

1 Answer

1 vote
1 vote
Best answer
It's a recursive code for inorder traversal.
selected by

2 Comments

how 'if', and not 'while',?!
0
0
@Nitin Sharma

here T is the Tree, it may be NULL, thats why there is " if " .

"while" means we assume Tree T never gonna be NULL, which is not the default case !

By default Tree T is NULL , we assume.
0
0
Answer:

Related questions