csgeek
3 years ago1,000+ Views
Data Structures: Max Heaps (in Ruby)
I found this helpful tutorial on heaps in Ruby. A max heap is a tree data structure with the following rules: *The keys of parent nodes are always greater than or equal to those of the children and the highest key is in the root node. They are usually implemented as arrays. [10, 4, 8, 2, 1, 7] (Pic 1) But not arrays are heaps, for example: [2,1,7] (Pic 2) * 2 is smaller than 7, which breaks the rule of heaps To learn how to implement this in Ruby, check out the tutorial at the link!
1 Like
1 Share
2 comments
heaps are so confusing to me, thank you for clarifying!!!
3 years ago·Reply
what do you find most confusing? I'm learning too, no worries!
3 years ago·Reply
1
2
1