FIT1045 Lecture Notes - Lecture 3: Adjacency List
Lists
list = ['Milk','Eggs']
Suppose we have 2 lists, a and b
len(a) !"#$%&'()*("+,&(a
a +b!-)$-.&#$.&+$%(/+**("+,&,
n*a!-)$-.&#$.&+$%("+,&($(&+0#,
a[k] = x !(( 1#2".-+$% .$(#"#0(3(+$/#4(5(6+&'(4
x in a!&17#(+*(4(+,(.$(+�()*(a
x not in a!&17#(+*(4(+,$8&(.$(+�()*((a
a.append(x) !(( .//(+�(4(&)(&'#(#$/()*("+,&(a
a.count(x) !(( %+9#,($):()*(&+0#,(+�(4(.22#.1,(+$(a
a.index(x) !(( 1#&71$,(*+1,&(2),+&+)$()*(+�(4(+$(a
a.insert(k,x) !((+$,#1& +�(4(.&(+$/#4(5(+$(a
a.pop() !((%+9#,(".,&(+�(.$/(1#0)9#,
a.remove(x) !(( 1#0)9#,(*+1,&()--711#$-#( )*(4(+$(a
a.reverse() !(( 1#9#1,#(.""(+�,
b = a[:] !(( -1#.&#,(-)2;()*("+,&(.$/(.,,+%$,(&)(<
=.$(.",)(7,#(import copy
>>>(y = copy.copy(x)
?$/#4#,@(,&.1&(*1)0(A(BC9#DE()1(!F(B1#9#1,#D
=.$(+$-"7/#($70<#1,(.,(6#""(.,(,&1+$%,
Mutable G(#"#0#$&,(-.$(<#(."#/()$#(<;()$#(+$()1+%+$."(
+&,#"*:
H,+$%(+$/#4(&)(.--#,,(+�,()$#(<;()$#
?.&+$%()9#1("+,&,
n = len(shoppingList)
for i in range(n):
print(shoppingList[i])
Tables
I#-'$+-."";("+,&,(+$("+,&,:
JJ.--)1/+$%(&)(1)6K
table = [['Coles','milk','eggs'],
['K-mart','shirt']]
table.append(x) !((.//("+,&(4(&)(&'#(#$/()*(
&.<"#(a
Graphs
L#1M(N))2M(O/%#
P+1#-&#/Q(R+02"#Q(=)$$#-&#/Q(S#+%'&#/Q(N.<#""#/Q
T/U.-#$-;("+,&
G(.(&.<"#(6'#1#(#.-'(+$$#1("+,&(')"/,(&'#(9#1&+-#,(&'.&(.1#(
./U.-#$&(&)(.(%+9#$(9#1:(V)10."";(/)$#(7,+$%(&'#(+$/#4()*(
&'#(9#1:
O/%#W9#1("+,&
G(.(&.<"#(6'#1#(#.-'(+$$#1("+,&(1#21#,#$&,(.$(#/%#
X+1,&(#"#0#$&()*(#/%#W"+,&(+,(,&.1&(9#1E(&'#$(#$/(9#1
L#1&+-#,(7,7."";(+/#$&+*+#/(<;(+$/#4
?*(%1.2'(6#+%'&#/E(6#+%'&(-)7"/(<#(Y1/(#"#0()*(+$$#1("+,&
Week$3:$Data$Structures
Z)$/.;E([(T7%7,&(\AF[
F\@A]