lect02-basics-slides
lect02-basics-slides
Linear
stores
list ADT
of elements
: Abstract Datatype ( ADT)
Abstracts the functional
Doubling
when
Reallocation
of size h
:
a
sequence array
-
Sabar ,
. . . an )
, Operations .
: elements of a data structure overflows
init ) create empty list (math ) from its implementation allocate 2h
-
new size
-
array
an
tgfff
ai
copy
- -
k.mg?ort:oxitn
remove old
sister
-
array
'I÷÷÷¥:i÷i¥%÷:w7
( moving others back ) -
delete ( i) -
④I:p.im?::::?snumotitem ÷:* : .
. run .
.
"
#fDegue(
)
"
deck :
can insert or
huh uh uh
sequential store items in delete from either end
array
:
an
#
: one
En (top ) push -
,,
+
pop
skied ; "%itjm
nu
"" :
push pop eedeaueue
tail
engueve Itai , cheat I
←
;
Doubly : head -
itJaJa÷ Queue : FIFO list :
engueue
inserts
at tail and deletes
with implementation
dequeue
Performance varies from head
Cost model ( Actual cost ) ft Dynamic ( sequential ) Allocation proof :
: we
-
→ ,
§
Expensive Array of size E. Stack each reallocation
2hPM
:
n run →
g.
-
" .
is reallocated to :
12/3/45/678911011 16171
⑤
size .
. . -
⑦÷
"y⑤g
atstartofarun there
'
:¥÷÷:÷.io?i:.!9.ii.i.iiii..!tl::oa...i::::i
-
are
:* :*
eat
.in?:.:..::::i:ii' .is
" " "
ii
-
→
.
'
: : :
an
-
.
request of pushlpopwe
.
Each
'
any
-
:
, "
cost is we ÷ I
pay
⑤
-
.
use
the operation +
put other
!! 1- 5
"
÷
-15=20
.
'
y
£4 Dynamic Stack
-
Fixed Increment Increase : :
Amortized
i
:
-
-1100 (t) !
;§q¥÷¥±
h - n
t.ly#fnixgdzgmstanttactorinot
i
Fixed factor : Increase by Other strategies ?
÷¥¥,¥÷'
i
-
a
,
tyg ,
?
.IQ?a7ethesizecor ii
'
'
' ' ' ' ' '
'
:i÷÷÷÷t÷÷÷÷:÷÷÷÷÷¥÷mM
'
. ' .
squaring
.
:* : :c:* .
some
:
④ i Node :
Idea : Store only
vw Yinnkteedrobyenrtrmif
'
Lggpvgiearsagxercige
Multi hits : lists of lists
⑨
sparse matrices :
-
Fixed factor -
yes n -
m entries and takes
( naively ) Oln ) space
squaring
"
←
yes
→ m
TEETH
-
't
sparse matrix : Most
entries are zero
- J