3. ArrayLists_outside

List the space used by the data structure is o n size

Info iconThis preview shows pages 7–10. Sign up to view the full content.

View Full Document Right Arrow Icon
list: The space used by the data structure is  O ( n ) size empty at   and  set   run in  O (1)  time insert   and  erase   run in  O ( n )  time in worst case If we use the array in a circular fashion,  operations insert (0, x )   and  erase (0, x )   run in  O (1)  time In an  insert   operation, when the array is full,  instead of throwing an exception, we can  replace the array with a larger one © 2010 Goodrich, Tamassia
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Array Lists 8 Growable Array-based Array  List In an  insert(o)  operation  (without an index), we always  insert at the end When the array is full, we  replace the array with a  larger one How large should the new  array be? Incremental strategy : increase  the size by a constant  c Doubling strategy : double the  size Algorithm insert ( o ) if t = S.length - 1 then A new array of size … for i 0 to n - 1 do A [ i ] S [ i ] S A n n + 1 S [ n 1] o © 2010 Goodrich, Tamassia
Background image of page 8
Array Lists 9 Comparison of the Strategies We compare the incremental strategy and  the doubling strategy by analyzing the total 
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page7 / 11

list The space used by the data structure is O n size empty...

This preview shows document pages 7 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online