❔ Help with AVL Binary Tree implementation
I'm working on a uni assignment implementing an AVL Binary Tree and keep getting errors even tho I think it's correct. Could someone give me a hand? it may be due tonight....
16 Replies
oh yeah I should probably mention that my issue is to do with the rotations (I think specifically the LR and RL ones)
parent.left is probably null
then why is it trying to rotate right?
I meant parent.right
brain malfunction
if pivot is null then parent.right is null
no wait i was right
yeah
im reading the wrong line now
lol, vibe
double brain malfunction, its been a long day
yeah so if its reporting pivot is null, then parent.left is null; since you are assigning it on the previous line
I think it's an issue with choosing which rotations to call, so this code, but idk how
im too cooked to read any of this, I hope you find the help you need lol
all g, thanks for trying
if anyone wants to know, been doing some diagnostics, trying to visualize what it's doing, when the following nodes are inserted I get a binary tree that looks like the attached diagram.
which is obviously extremely correct and valid
here is a diagram from https://www.cs.usfca.edu/~galles/visualization/AVLtree.html with the same inputs
the previous state of the tree was this, which is correct...
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.