Non-recursive implementation of preorder traversal, Data Structure & Algorithms

Assignment Help:

For preorder traversal, in the worst case, the stack will rise to size n/2, where n refer to number of nodes in the tree. Another method of traversing binary tree non-recursively that does not employ stack requires pointers to the parent node (called threaded binary tree).

A threaded binary tree is a binary tree wherein every node which does not have a right child has a THREAD (a third link) to its INORDER successor. By doing this threading we ignore the recursive method of traversing a tree and employ of stack, that makes use of many memory and time.

A node structure of threaded binary is following :

For a threaded binary tree the node structure varies a bit and its like this -

struct NODE *leftchild;

int node_value;

struct NODE *rightchild;

struct NODE *thread;  /* third pointer to its inorder successor */

}


Related Discussions:- Non-recursive implementation of preorder traversal

Deletion of an element from the linked list, A LGORITHM (Deletion of an ele...

A LGORITHM (Deletion of an element from the linked list) Step 1  Begin Step 2  if the list is empty, then element cannot be deleted Step 3  else, if the element to be del

Boar corloring, Board coloring , C/C++ Programming

Board coloring , C/C++ Programming

Linear array, representation of linear array

representation of linear array

Implementation of queue, For a queue a physical analogy is a line at bookin...

For a queue a physical analogy is a line at booking counter. At booking counter, customers go to the rear (end) of the line & customers are attended to several services from the fr

The data structure required to evaluate a postfix expression, The data stru...

The data structure needed to evaluate a postfix expression is  Stack

Explain binary search tree, Binary search tree. A binary search tree is...

Binary search tree. A binary search tree is a binary tree that is either empty or in which every node having a key that satisfies the following conditions: - All keys (if an

Deletion from a red-black tree, Deletion in a RBT uses two main processes, ...

Deletion in a RBT uses two main processes, namely, Procedure 1: This is utilized to delete an element in a given Red-Black Tree. It involves the method of deletion utilized in

Stack, Explain in detail the algorithmic implementation of multiple stacks....

Explain in detail the algorithmic implementation of multiple stacks.

Multiple queue, What is multiple queue and explain them

What is multiple queue and explain them

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd