Heaps and the Highest Paid Actors

Heaps and the Highest Paid Actors

Heaps and the Highest Paid Actors By Jason England What is a Heap? ● Collection of Nodes ● Binary ● Node - Left, Right, key, value ● Either Min or Max Min Heap vs. Max Heap ● Min Heap - lowest value is root ● Max Heap - Highest value is root Jackie Chan ● 5th Highest Paid Actor in 2019 ● $58 Million ● Stars in: The Climb The Knight of Shadows: Between Yin and Yang Heap vs. BST Heaps BST ● Always add left to right ● Can be either left or right ● Full/complete trees ● Not always a full/complete tree ● Always O(log n) ● Can be O(n) in worst case Full vs Complete Binary Tree Full Binary Tree ● Every node except leaves have two children Complete Binary Tree ● Every level of nodes except for the last level have 2 children Performance O(log n) ● Insert is O(log n) -> tree depth is log n ● removeMin() is O(log n) -> getting the min is O(1) but you have to get the new root Akshay Kumar ● 4th Highest Paid Actor in 2019 ● $65 Million ● Stars in: Heap Commands ● insert(item) ● removeMin() ● isEmpty() insert() ● Returns nothing ● Adds a new node at the end ● Swaps with parent if less than insert() Example insert() Example Cont. Robert Downey Jr ● 3rd Highest Paid Actor in 2019 ● $66 Million ● Stars In: removeMin() ● Removes the smallest value ● Returns that node ● Makes the next smallest number the root removeMin() Example Chris Hemsworth ● 2nd Highest Paid Actor in 2019 ● $76.4 Million ● Stars In: isEmpty() ● Checks if the Heap Tree is empty ● Returns true or false Applications of Heaps ● Priority Queues ● Dijkstra’s algorithm - finding the shortest path Dwayne “The Rock” Johnson ● Highest Paid Actor in 2019 ● $89.4 Million ● Stars in: Review ● Smallest value is the root ● Always full/complete tree ● O(log n) - Always.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    20 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us