DSA Final
DSA Final
Types of tress:
Binary Tree: A binary tree is a tree in which each node has at most two
children, referred to as the left child and the right child. It's like
a family tree, where each person has at most
two children.
AVL Tree: An AVL tree is a self-balancing binary search tree. It
maintains a balance factor for each node, which represents the
difference in height between its left and right subtrees. AVL trees
automatically adjust their structure to ensure that the balance factor of
every node stays within a specific range, ensuring efficient operations.
Red-Black Tree: A red-black tree is another
type of self-balancing binary search tree. It maintains balance by
coloring the nodes either red or black and following specific rules to
ensure balance. Red-black trees are commonly used in many
applications, including map and set data structures.
Now, collision occurs when two different inputs produce the same hash
value. It's like two different keys trying to occupy the same slot in the
hash table. This can happen due to the limited size ofthe hash table or
the nature of the hash function.