1 / 7

CS-2852 Data Structures

CS-2852 Data Structures. Week 8, Class 1 Amortized ArrayList.add (). Not in outcomes. The material in these slides is not part of the course outcomes, and is provided only for the curious…. Amortized Analysis. Amortization

tao
Télécharger la présentation

CS-2852 Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS-2852Data Structures • Week 8, Class 1 • Amortized ArrayList.add() CS-2852 Dr. Josiah Yoder Slide style: Dr. Hornick

  2. Not in outcomes • The material in these slides is not part of the course outcomes, and is provided only for the curious… CS-2852 Dr. Josiah Yoder Slide style: Dr. Hornick

  3. Amortized Analysis • Amortization • “The paying off of debt in regular installments over a period of time.” – Investopedia • The average cost of an operations over multiple calls – Amortized analysis CS-2852 Dr. Josiah Yoder Slide style: Dr. Hornick

  4. Amortized Analysis (2) • Is • Worst-case bound – just like Big-O we’ve discussed so far • Cost of a single call average over a special group of calls • Not • Random – not averaged over “possible events” • Single call – no bound provided for a single call CS-2852 Dr. Josiah Yoder Slide style: Dr. Hornick

  5. Amortized AddHow we avoid O(1) add(E) • If we have enough capacity, this is easy! • [Draw on board] • Array with extra capacity • Then just stick in the extra element CS-2852 Dr. Josiah Yoder Slide style: Dr. Hornick

  6. Attempt 1: Add block of extra space • Draw out approach • Block of space CS-2852 Dr. Josiah Yoder Slide style: Dr. Hornick

  7. CS-2852 Dr. Josiah Yoder Slide style: Dr. Hornick

More Related