Graphs Flashcards
1
Q
Binary Search Tree (BST)
A
A binary search tree is a data structure consisting of nodes, each holding a value and pointers to its left and right children. Nodes on the left side of the tree have values less than the root’s value, while those on the right have greater values.
2
Q
Operations on Binary Search Trees
A
- Insertion: Adding a new node with a specific value to the binary search tree while maintaining its properties.
- Deletion: Removing a node with a specific value from the binary search tree while maintaining its properties.
- Search: Finding a node with a specific value in the binary search tree.
- Traversal: Visiting all nodes of the binary search tree in a specific order (inorder, preorder, postorder).
3
Q
Time complexity for binary search trees
A
- The average-case time complexity for insertion, deletion, and search operations in a balanced binary search tree is O(log n), with ‘n’ representing the number of nodes.
- In a worst-case scenario, where the binary search tree is unbalanced, the time complexity for insertion, deletion, and search operations may deteriorate to O(n), with ‘n’ being the number of nodes.