-5

I do not know how to do either of these problems. However, I did find example code for the AVL tree here: http://users.cis.fiu.edu/~weiss/dsaajava/code/DataStructures/AvlTree.java

However, I still am unsure how to do this. Can someone please help me out with this?

I need to insert the following keys into an empty AVL tree and show the tree after each insertion. The keys need to be taken as strings of characters not as months. For example, Jul < Jun. DEC, JAN, APR, MAR, JUL, AUG, OCT, SEP, FEB, NOV, MAY, JUN

Insert the following keys into an empty red-black tree and show the tree after each insertion. The keys should be taken as strings of characters not as months. For example, Jul < Jun. DEC, JAN, APR, MAR, JUL, AUG, OCT, SEP, FEB, NOV, MAY, JUN

  • 1
    Do you understand how these trees work? If you have some code but don't understand the basic algorithm, you're not really going to be doing much but wasting your time. – AHungerArtist Dec 03 '12 at 15:24
  • The link I posted in my question is my startup code for the AVL tree problem. – Luke Mantrol Dec 03 '12 at 15:26
  • 1
    If there is a specific concept you would like explained, consider asking about that directly. For example, "Given a tree in [some state], what happens when [some node] is inserted?" is a far more productive question than "How do I do my homework?" – Griffin Dec 03 '12 at 15:39

1 Answers1

4

Go find a whiteboard, bring your textbook and follow the operations exactly as described in your textbook for insertion, deletion etc. Forget about actual code until you understand what is happening. If you don't have a textbook, get this one (possibly at the library) Corman, Leiserson, Rivest and Stein.

No one on StackOverflow is going to be able to help you any better than Googling "How do I implement an AVL Tree?" will until you do this. I promise, whiteboard-fu will help you way more than anything you read on the internet - learn by doing.

durron597
  • 31,968
  • 17
  • 99
  • 158