0% found this document useful (0 votes)
3 views

lect02-basics-slides

The document discusses various data structures, particularly focusing on dynamic lists and their operations such as initialization, insertion, deletion, and reallocation strategies. It emphasizes the importance of amortized costs in managing dynamic arrays and outlines different strategies for increasing size, including fixed increments and doubling. Additionally, it touches on the concept of sparse matrices and their storage efficiency.

Uploaded by

abhimanyu thakur
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

lect02-basics-slides

The document discusses various data structures, particularly focusing on dynamic lists and their operations such as initialization, insertion, deletion, and reallocation strategies. It emphasizes the importance of amortized costs in managing dynamic arrays and outlines different strategies for increasing size, including fixed increments and doubling. Additionally, it touches on the concept of sparse matrices and their storage efficiency.

Uploaded by

abhimanyu thakur
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

m

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

getli ) ( algorithm / old to


returns
programming) new

tgfff
ai
copy
- -

k.mg?ort:oxitn
remove old
sister
-

array

'I÷÷÷¥:i÷i¥%÷:w7
( moving others back ) -

delete ( i) -

deletes ith item Basic Data structures I Dynamic Lists + Sequential


( others up ) Allocation what to do
moving
:

④I:p.im?::::?snumotitem ÷:* : .
. run .
.

"

#fDegue(
)
"

deck :
can insert or
huh uh uh
sequential store items in delete from either end
array
:
an

IT-a.la/at...an1 ¥4 Stack All access from side T P

#
: 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 :

reallocation When overflow double Break the full sequence after


cheap No Innit
-

: 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

: htt items in stack and

:* :*

'Fdt;: dm%ba:iwM Daiieasthsnti ::ew"


.no.
Basic Data Structures I before the end of run

eat
.in?:.:..::::i:ii' .is
" " "
ii
-

the Ifor each



w : →
L L L L . op
4 for deposit
-


.

'

Amortized lost Next reallocation costs


Starting from charging Argument
'

: : :
an
-
.

request of pushlpopwe
.

empty structure suppose that 4h , but we have


'

Each
'

any
-
:
, "

of mops takes tinietlm )


charge ÷ enough saved !
" "

sequence . users work tokens


The amortized Tim )/m 1 token to for
.

cost is we ÷ I
pay

-

.
use

the operation +
put other

Than tinged:* :c.mn#gtsatgYs.w4iiishawnktn:EeTTt'enough


e :÷::i:÷a:c:S:p.si.com.om , intermission"
.es
'm

!! 1- 5
"
÷
-15=20
.
'
y

£4 Dynamic Stack
-
Fixed Increment Increase : :

Amortized
i

by a fixed constant showed


doubling
'

:
-

-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
'

which of these provide -04 )


amortized cost per operation ? I
°→
and column
wlnext wwnext
.

Lggpvgiearsagxercige
Multi hits : lists of lists

sparse matrices :
-

Fixed increment head matrix has


top-rated An
→ - '
no nxm

Fixed factor -
yes n -
m entries and takes
( naively ) Oln ) space
squaring
"

yes
→ m
TEETH
-

't
sparse matrix : Most
entries are zero

- J

You might also like