Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CS-2852 Data Structures Week 8, Class 1 Amortized ArrayList.add() CS-2852 Dr. Josiah Yoder Slide style: Dr. Hornick 1."— Presentation transcript:

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

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 2

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 3

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 4

5 Amortized Add How 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 5

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

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


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

Similar presentations


Ads by Google