Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
0 of .
Results for:
P. 1
Algo Micro

# Algo Micro

Ratings:
(0)
|Views: 28|Likes:

### Availability:

See more
See less

09/22/2011

pdf

text

original

14. Design a conventional iterative algorithm to traverse a binary treerepresented in one dimensional array in inorder
Ans. In-order traversal :-Algorithm: Inorder TraversalInput: A[ ], one dimensional arrayrepresenting the binary tree,‘i’, the root address//initially i=1Output: Inorder SequenceMethod:If (A[i] != 0)Inorder Traversal (A, 2i)Display (A[i])Inorder Traversal (A, 2i + 1)If endAlgorithm ends.
15. Design a conventional iterative algorithm to traverse a binary treerepresented in one dimensional array in preorder
.Ans. Pre-Order traversal:-Algorithm:PreOrder TraversalInput:A[ ], one dimensionalarray representing the binary tree,‘i’, the root address //initially i=1Output:PreOrder SequenceMethod:If (A[i] != 0)Display (A[i])PreOrder Traversal (A, 2i)PreOrder Traversal (A, 2i + 1)If endAlgorithm ends.
16. Design a conventional iterative algorithm to traverse a binary treerepresented in one dimensional array in postorder
.Ans. Post-order traversal :-Algorithm:PostOrder TraversalInput:A[ ], one dimensionalarray representing the binary tree,‘i’, the root address//initially i=1Output:PostOrder SequenceMethod:If (A[i] != 0)Algorithms postorder Traversal (A, 2i) postorder Traversal (A, 2i + 1)Display (A[i])If endAlgorithm ends.
17. Design a conventional algorithm to traverse a binary tree representedin two dimensional array in inorder
.Ans. In-order traversal:-Algorithm:InOrder TraversalInput:A[ ], two dimensionalarray representing the binary tree,‘i’, ‘j’, the two root address//initially i=j=1Output:InOrder SequenceMethod:If (A[i, j] != 0)Inorder Traversal (A, 2i, 2j)Display (A[i, j])Inorder Traversal (A, 2i + 1, 2j + 1)If endAlgorithm ends.
18. Design a conventional iterative algorithm to traverse a binary treerepresented in two dimensional array in preorder
.Ans. Pre-order traversal:-Algorithm:PreOrder TraversalInput:A[ ], two dimensionalarray representing the binary tree,‘i’, ‘j’, the two root address//initially i=j=1Output:PreOrder SequenceMethod:If (A[i, j] != 0)Display (A[i, j])Preorder Traversal (A, 2i, 2j)Preorder Traversal (A, 2i + 1, 2j + 1)If endAlgorithm ends.
19. Design a conventional iterative algorithm to traverse a binary treerepresented in two dimensional array in postorder
.Ans. Post-order traversal:-Algorithm:PostOrder TraversalAlgorithmsInput:A[ ], two dimensionalarray representing the binary tree,‘i’, ‘j’, the two root address//initially i=j=1Output:PostOrder SequenceMethod:If (A[i, j] != 0)Postorder Traversal (A, 2i, 2j)Postorder Traversal (A, 2i + 1, 2j + 1)Display (A[i, j])
If endAlgorithm ends.0. Design a conventional iterative algorithm to traverse a binary treerepresented in linked lists in inorder
.Ans. In-order traversal :-Algorithm:InOrder TraversalInput:bt, address of the rootnodeOutput:InOrder SequenceMethod:If (bt != NULL){Inorder Traversal ([bt].LChild)Display ([bt].data)Inorder Traversal ([bt].RChild)}If endAlgorithm ends.
21. Design a conventional iterative algorithm to traverse a binary treerepresented in linked lists in preorder.
Ans. Pre-order traversal :-Algorithm:PreOrder TraversalInput:bt, address of the rootnodeOutput:PreOrder SequenceMethod:If (bt != NULL){Display ([bt].data)Preorder Traversal ([bt].LChild)Preorder Traversal ([bt].RChild)}If endAlgorithm ends.
23. Design a conventional iterative algorithm to traverse a binary treerepresented in linked lists in postorder.
Ans. Post-order traversal :-Algorithm:PostOrder TraversalInput:bt, address of the rootnodeOutput:PostOrder SequenceMethod:If (bt != NULL){AlgorithmsPostorder Traversal ([bt].LChild)Postorder Traversal ([bt].RChild)Display ([bt].data)}If end Algorithm ends
.