Red-Black Trees

前端 未结 12 2259
逝去的感伤
逝去的感伤 2020-12-07 10:15

I\'ve seen binary trees and binary searching mentioned in several books I\'ve read lately, but as I\'m still at the beginning of my studies in Computer Science, I\'ve yet to

12条回答
  •  情话喂你
    2020-12-07 11:05

    BSTs make the world go round, as said by Micheal. If you're looking for a good tree to implement, take a look at AVL trees (Wikipedia). They have a balancing condition, so they are guaranteed to be O(logn). This kind of searching efficiency makes it logical to put into any kind of indexing process. The only thing that would be more efficient would be a hashing function, but those get ugly quick, fast, and in a hurry. Also, you run into the Birthday Paradox (also known as the pigeon-hole problem).

    What textbook are you using? We used Data Structures and Analysis in Java by Mark Allen Weiss. I actually have it open in my lap as i'm typing this. It has a great section about Red-Black trees, and even includes the code necessary to implement all the trees it talks about.

提交回复
热议问题