Uploaded by Kishan Kumar

ADT

advertisement
ADT interface in
Python programming.
1.ADT only defines as what operations are to be performed but not how tnese
operations will be implemented
2. It
does not
algorithms
specify
how data will be organized in
memory and
will be used for
impleinenting the
wiat
operations.
3. It is called "abstract" because it qives an implementation-independent view.
4. The process of providing only the essentials and hiding the details IS KIow"
as abstraction.
Abstract Data Type
Application
Program
Interface
Public
Private
Functions Functions
Data Structures
Linked List
Array
Meinory
5. The user of data type does not need to know how that data type is
implemented, for example, we have been using primitive values like int, float,
and char data types only with the knowledge that these data type can operate
and be performed on without any idea of how they are implemented.
6. So, a user only needs to know whal a data type can do, but not how it will
be implemented.
Date:
C.bstract Doata Type (ADT)
ADT
Loita a
s
a e
(ox class) on obrecta
Set cycbenations to manpulate
the elemen
The deimin oy ADT Onlu menhiond Lchat
obeAodicms ahe- h e perlmed but
nor houa these ceeaaiensSillbe
implemertrd.
Dataahshrocion k possíble uita ADT
puieling m
Hae nelevast indumat
d e hidto. lie unnecessoy detailc..
AST includles stack, queues.
Link Lit_
stad ADT
A stack is a ineah dala chutwhe that
is LTCo suune ie last In Gaxt Dut
OpeAachCn. meons the element inces te
in aat wil be semaved firkdt caedo
incedion, deletton botn take blace at
cnE end' calledtop o he stack
The
stok
empty
stack opeotionc ae
: Cseadbes a new slack a
is
puhtenm)
adds 4he dem 4a dhe top
a dhe stach 4 it beland tbung
emoves dhe
pop)
top item ugm thhe
Stack.T akes no panameteAs and hetdw
4 e xemovec item
p eeko
e
takel
-
deluhnt h e top item o m
stack bt dses not aenove it
no pohameten
iEmply)-test to see whethen he
staok is empty
>sizeD-Netunng he no.
itemA om the
stack.
lous stack
de
int-(sel
sell. Hems
1
deiskmpdy(sell
eudin sel.items==t
de puchlsel tem) i
se.terng.oppend(ttem)
de pap(sd
cton sel.items.bosl)
de peek (sel
Snettunn sel.itemsllen(self.iems)-11.
desige(se):
eun len(selp. Bema)
S=Stak)
prind: (
GAath
tpeodion Gaae
talr (s.itndyts)
spn(Python")
pidtspeek)
s.bush sue)
prit (S.size.ti)
pvint (s.istnely)_
Sush.(LLK)
pint(s.poplJ) .
pint (s popo)
pint (ssizet ))
Queue ADT= A ueue iç a fiFo(Sat
in fiart Out litThe allnusing open
Enoueue
equeue Rize,sDnd
Cseqes a ne Queue thodtis
emelyt neealA no panamteas
Cndetung.a n emph
queue
em
engueue (
ddde 0 De
t e m to dthe
eanC quele
quele.
degueuel =Semovel dhe
non
e
quetue
item o n he
Tneedsno pana-
Tnen.and reuons dhe tem thad ix
gemoved
rt
euong
e
cEmuL):
qaetue
Aests o
the ont Hem
Jaum
bud does nat emove it,
sempt
sige) etuons e
h e ueue.
see
whelhen
numbe
te queue
o items cn
Data:
Paga:
class tlueMe
initke
sel.item =t1
d
isEmly(sed):
etuan sel.items
==
J
cle enquetue (sell, item)
Seidems.oppend (item)
del dequeue (sell:
ehuon setema.poplo)
cle tad(ss;
hetunn aelitems[len(selHems)-1
de size (sell :
ekunn len(sel, items)
=tueuel)
rint4 isEmpayti)
enqueMe[5)
enqueue ('puthan)
prindlanond (3)
enquee(tsue )
prin,Szet)
tridt(istmhyt)
,raueue (M.s)°
pyindequete )
rind(4 deaueuel)
psind(sget)-
Download