C
C#2y ago
Tundrin

❔ 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
Tundrin
TundrinOP2y ago
oh yeah I should probably mention that my issue is to do with the rotations (I think specifically the LR and RL ones)
Anchy
Anchy2y ago
parent.left is probably null
Tundrin
TundrinOP2y ago
then why is it trying to rotate right?
Anchy
Anchy2y ago
I meant parent.right brain malfunction if pivot is null then parent.right is null no wait i was right
Tundrin
TundrinOP2y ago
yeah
Anchy
Anchy2y ago
im reading the wrong line now
Tundrin
TundrinOP2y ago
lol, vibe
Anchy
Anchy2y ago
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
Tundrin
TundrinOP2y ago
I think it's an issue with choosing which rotations to call, so this code, but idk how
Anchy
Anchy2y ago
im too cooked to read any of this, I hope you find the help you need lol
Tundrin
TundrinOP2y ago
all g, thanks for trying
Tundrin
TundrinOP2y ago
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.
Tundrin
TundrinOP2y ago
which is obviously extremely correct and valid
Tundrin
TundrinOP2y ago
here is a diagram from https://www.cs.usfca.edu/~galles/visualization/AVLtree.html with the same inputs
Tundrin
TundrinOP2y ago
the previous state of the tree was this, which is correct...
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server