Thread: I have some problems about AVL tree...Please help me....

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    52

    I have some problems about AVL tree...Please help me....

    I'm learning about AVL tree, and I have a question.....
    When you want to convert from AVL to Binary Search Tree, it is whether you can have more than 2 nodes that are not valid...Ex:
    I have a list that is:
    1 6 9 17 25 32 64 55 78 43 48
    I will input this list into a Binary search Tree, and convert it to AVL tree...
    I want to ask whether I can do this...
    Code:
            "1" --   ->        "6"/   ->         "6" --               ->             "6"\                             ->
                             "1" --              "1"--    "9"--                    "1"--      "9"\
                                                                                                              "17"--
    
    
                          "6"\\                                     ->             "6"\                      OR             "9"-- 
                    "1"--       "9"\\                                      "1"--         "17"--                   "6"/      "17"\ 
                                          "17"\                                        "9"--     "25"--         "1"--          "25"-- 
                                                  "25"-- 
    
    OR when I have 
                    "9"\                                                 "9"\\ 
             "6"/       "25"\                         ->      "6"/       "25"\\                     ->
        "1"--     "17"--    "32"\                       "1"--     "17"--     "32"\\
                                          "64"--                                                  "64"/
                                                                                            "55"--  
    
    
                                 "9"\
                           "6"/       "25"\   
                       "1"--     "17"--    "55"--
                                           "32"--    "64"--
    IS IT TRUE???

    Please help me!! Thanks very much.....

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well your diagram made NO sense at all.

    What reading have you done?
    http://faq.cprogramming.com/cgi-bin/...ect=1073086407
    http://www.nist.gov/dads/
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Drunken Progammer CaptainMorgan's Avatar
    Join Date
    Feb 2006
    Location
    On The Rocks
    Posts
    45

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    The best thing is if you eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente.

    I hope that helps.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    A binary tree can be converted to an AVL tree, but that is not what you normally do. It should always be an AVL tree, right from the start.

    Other than that the answer is 42.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weight Balanced Tree - Implementation
    By paulovitorbal in forum C Programming
    Replies: 1
    Last Post: 10-31-2007, 02:28 PM
  2. BST delete again, but this time I think I'm close
    By tms43 in forum C++ Programming
    Replies: 9
    Last Post: 11-05-2006, 06:24 PM
  3. problem in creating a tree
    By Lorin_sz in forum C++ Programming
    Replies: 2
    Last Post: 09-26-2005, 01:28 PM
  4. problem in creating a tree
    By Lorin_sz in forum C Programming
    Replies: 1
    Last Post: 09-26-2005, 01:24 PM
  5. AVL tree
    By sammy in forum C++ Programming
    Replies: 1
    Last Post: 02-21-2002, 01:46 PM