Posts

What is Stack Data Structure?

Image
What is Stack Data Structure? Stack  is an abstract data type with a bounded(predefined) capacity. It is a simple data structure that allows adding and removing elements in a particular order. Every time an element is added, it goes on the  top  of the stack and the only element that can be removed is the element that is at the top of the stack, just like a pile of objects. Basic features of Stack Stack is an  ordered list  of  similar data type . Stack is a  LIFO (Last in First out) structure or we can say  FILO (First in Last out). push()  function is used to insert new elements into the Stack and  pop()  function is used to remove an element from the stack. Both insertion and removal are allowed at only one end of Stack called  Top . Stack is said to be in  Overflow  state when it is completely full and is said to be in  Underflow  state if it is completely empty. Applications of Stack ...

Tree Traversal Techniques

Image
Traversal  is the method of processing each and every node in the Binary Search Tree exactly once in a systematic manner. There are three different types of tree traversal. (1) Preorder Traversal  (2) In order Traversal  (3) Post order Traversal PreOrder Traversal Steps for Preorder Traversal: (1) Process the root node first. (2) Traverse the left sub tree in preorder. (3) Traverse the right sub tree in preorder. InOrder Traversal Steps for Inorder Traversal: (1) Traverse the left sub tree in inorder. (2) Process the root node. (3) Traverse the right sub tree in inorder. PostOrder Traversal Steps for PostOrder Traversal: (1) Traverse the left sub tree in Post order. (2) Traverse the right sub tree in Post order. (3) Process the root node. Now Consider Following Example PreOrder Traversal :  A B D E C F G  InOrder Traversal :  D B E A F C G PostOrder Traversal :  D E B F G C A