Data Structure - Tree Flashcards
What is a tree?
It’s an abstract data type that represents a hierarchical tree structure with a set of connected nodes, where each node in the tree can be connected to many children, but must be connected to exactly one parent, except for the root node, which has no parent.
What is a binary tree?
It’s a tree with the constrain number of children for each parent to exactly two.
What are some applications of trees?
File systems, class hierarchy (inheritance), Abstract Syntax Trees and others.
What is tree transversal?
It’s the process of visiting and outputting the value of each node of a tree in a particular order.
How in-order transversal works?
It traverses from the left subtree, to the root then, to the right subtree
https://kalkicode.com/pixels/binary-tree/inorder-traversal-of-binary-tree.png
How pre-order transversal works?
It traverses from the root, to the left subtree then, to the right subtree.
https://kalkicode.com/pixels/binary-tree/preorder-tree-traversal.png
How post-order transversal works?
It traverses from the left subtree, to the right subtree, then to the root.
https://kalkicode.com/pixels/binary-tree/postorder-tree-traversal.png
Tree transversal exercise
https://media.geeksforgeeks.org/wp-content/cdn-uploads/Preorder-from-Inorder-and-Postorder-traversals.jpg