Skip to main content
Share Your Experience: Take the 2024 Developer Survey

New answers tagged

0 votes

Balancing tree by removing nodes instead of perfoming rotations to defined height $h$

the reason your code results in an unbalanced tree: Prioritizing Height: You prioritize removing nodes with the highest height. This removes higher levels from the tree, potentially creating long ...
Sujay_ks's user avatar
0 votes

Finding middle vertex of tree

You can find the diameter of the tree, and pick the middle vertex (or one of its two middle vertices). A simpler linear time algorithm to find a diameter would be: rooting the tree arbitrarily find a ...
Nathaniel's user avatar
  • 15.7k
3 votes

Efficient data structure for fast Insertions, lookups, and union operations on sets

Here are a few ideas: There are balanced binary search tree variants which are designed for efficient union/meld, such as weight-balanced trees. It's fairly well-established that the purpose of ...
Pseudonym's user avatar
  • 22.2k
1 vote

Possible values of root of AVL tree

The objective is to find the minimum and maximum possible values of the root of an AVL tree that contains keys $1,2,\ldots,1000$. Let $N(h)$ denote the minimum number of nodes in an AVL tree that ...
Ashwin Ganesan's user avatar

Top 50 recent answers are included