in GATE retagged by
374 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
374 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

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

64.3k questions

77.9k answers

244k comments

80.0k users