134x Filetype PPT File size 0.16 MB Source: courses.cs.washington.edu
Today • Finish amortized analysis of stretchy arrays • The List ADT Reading assignment for this week: Weiss, Chapter 3 2 Amortized Analysis Stack A E D C B A B C • Stack operations D – push E – pop F F – is_empty • Stack property: if x is on the stack before y is pushed, then x will be popped after y is popped What is biggest problem with an array implementation? 3 Stretchy Stack Implementation int[] data; int[] data; Best case Push = O( ) int maxsize; int maxsize; int top; Worst case Push = O( ) int top; Push(e){ Push(e){ if (top == maxsize){ if (top == maxsize){ temp = new int[2*maxsize]; temp = new int[2*maxsize]; for (i=0;i
no reviews yet
Please Login to review.