Tree Flashcards
(13 cards)
What is a tree?
A hierarchical data structure that simulates a tree-like structure with a set of connected nodes
What is a binary tree?
A type of tree where each node can have at most two children
What is a full tree?
A tree where every node has either zero children (leaf node) or two children. Also known as proper binary trees
What is a complete tree?
A binary tree in which all levels are filled, except possibly the last level. The last level must strictly be filled from left to right. Data structures like Heap uses complete binary trees
What is a balanced tree?
A binary tree where the difference in height between the left and right subtrees of any node in the tree is not more than 1. This ensures the tree remains reasonably balanced, preventing skewed structures
What is a multi-way tree?
A type of tree that allows nodes to have more than two children
What is a binary search tree (BST)?
A fundamental data structure that organizes elements in a hierarchical manner. Each node has at most two children and for any given node, all nodes in its left subtree have values less than or equal to the node’s value, and all nodes in its right subtree have values greater than the node’s value
What is in-order traversal?
A type of binary search tree traversal that visits the left subtree, the current node, and then the right subtree, resulting in the elements being visited in ascending order
What is pre-order traversal?
A type of binary search tree traversal that visits the current node, the left subtree, and the right subtree.
What is a post-order traversal?
A type of binary search tree traversal that visits the left subtree, the right subtree, and then the current node.
What is the time complexity of searching/insertion/deletion a balanced binary search tree (BST)?
O(log n)
What is the time complexity of searching/insertion/deletion an unbalanced binary search tree (BST)?
O(n)
What are issues with binary search trees?
- Unbalanced: They can become unbalanced due to the order in which elements are inserted. If elements are inserted in a sorted order, they can turn into a linked list
- Memory Overhead: Each node requires additional memory for storing pointers
- Not suitable for dynamic datasets
- Limited search performance for equal keys