eedeaueue
play

eedeaueue # T P IT-a.la/at...an1 access from one side : All - push - PowerPoint PPT Presentation

m Abstract Datatype ( ADT ) Doubling Reallocation Linear list ADT : : - Abstracts the functional stores a sequence of elements when array of size h Sabar , overflows . , an ) . Operations elements a data structure of : . . - allocate -


  1. m Abstract Datatype ( ADT ) Doubling Reallocation Linear list ADT : : - Abstracts the functional stores a sequence of elements when array of size h Sabar , overflows . , an ) . Operations elements a data structure of : . . - allocate - create an empty list implementation init ) ( math ) from its new array size 2h ( algorithm / programming ) - returns ai getli ) copy old to new tgfff - - remove old array sister k.mg?ort:oxitn . 'I÷÷÷¥:i÷i¥%÷:w7 ( moving others back ) - u Dynamic Lists + Sequential - deletes ith item delete ( i ) Basic Data structures I ( moving others up ) Allocation : what to do run . . ④ I :p .im?::::?snumotitem ÷ :* : . #fDegue( " ) : can insert or " deck huh uh uh delete from either end : store items in sequential an array ¥4 Stack eedeaueue # T P IT-a.la/at...an1 access from one side : All - push En ( top ) + pop nu , , skied ; "%itjm " " : push pop I ↳ tail engueve Itai , cheat ⇐ ; ← : head - itJaJa÷ : engueue inserts Queue : FIFO list Doubly at tail and dequeue deletes varies with implementation from head Performance

  2. Cost model ( Actual cost ) ft Dynamic ( sequential ) Allocation proof : , double - When - Break the full sequence after No reallocation → Innit we overflow cheap : : Array of size n § each reallocation → run Expensive E. g. Stack is reallocated to size 2hPM " - . . . - 16171 : 12/3/45/678911011 ⑤ . "y ⑤ g - atstartofarun there are ⑦ ÷ ' :¥÷ .io?i:.!9.ii.i.iiii..!tl::oa...i::::i htt items in stack and : " ii 'Fdt;::dm%ba:iwM :* :* .no . before the end of run Basic Data Structures I - Daiieasthsnti .is ::ew" eat ÷ :÷ .in?:.:..::::i:ii' " " : the L → Ifor each op ④ w : L L L 4 for deposit . - → . Amortized lost : Starting from an . ' - Next reallocation costs charging Argument ' : : . . - Each request of pushlpopwe . . empty structure , suppose that any , but we have ' 4h ' : " charge users enough saved ! sequence of mops takes tinietlm ) . " " work tokens ÷ 1 token to pay for The amortized - we is Tim )/m . I cost ⑤ ÷ use . the operation + put other Than tinged :* :c .mn#gtsatgYs.w4iiishawnktn:EeTTt' .es ! enough ! e :÷::i:÷a :c intermission " :S :p .si .com.om , 'm " ÷ . 1- 5 -15=20

  3. y ' Fixed Increment : Increase £4 - Dynamic Stack : - showed doubling ⇒ Amortized i ' by a fixed constant : ! ( t ) n -1100 tyg ;§q¥÷¥± h - Increase by - Other strategies ? t.ly#fnixgdzgmstanttactorinot i Fixed factor : a i . ÷¥¥,¥÷' , , ? .IQ?a7ethesizecor ii ' ' ' ' ' ' ' ' ' :i÷÷÷÷t÷÷÷÷:÷÷÷÷÷¥÷mM ' ' . . . squaring : :* . :* : :c some ④ Idea : Store only Node : i Yinnkteedrobyenrtrmif vw ' which of these provide -04 ) amortized cost per operation ? ° → and column I wwnext wlnext ⑨ Multi hits lists of lists Lggpvgiearsagxercige : - . sparse matrices : head - top-rated nxm matrix has Fixed increment → no ' An Fixed factor - yes - m entries and takes n ← " ( naively ) → yes Oln squaring - m ) space TEETH 't : Most sparse matrix entries are zero - J

Recommend


More recommend