FIT1008 Lecture Notes - Lecture 5: Init

82 views2 pages
ADTs (Abstract+Data+Types)
!"#$%$"&%'()%('*&"$+,-."/0%1"%1*0'",2*'$%0,-&"/10)1"3$-02(+$%*"%1*"&%'()%('*&
4*&0.-*#"5$&*#",-"$5&%'$)%0,-6"0-7,"10#0-."$-#"*-)$2&(+$%0,-
8
97%*-"-,"-**#"%,":-,/"1,/"%;2*&"$'*"032+*3*-%*#
8
<',=0#*"0-7,"'*.$'#0-."2,&&05+*"=$+(*"%;2*&6"3*$-0-.&"$-#",2&"%1$%")$-"5*"
#,-*",-"%1*3
92&"$'*"%1*",-+;"/$;"(&*'")$-"0-%*'$)%"/0%1"#$%$
8
%$-.05+*"%10-.?"data+types
@*.A"0-%6"&%'0-.6"BC
!"'*7*'"%,"$")+$&&070)$%0,-"%1$%"#*%*'30-*&?
<,&&05+*"=$+(*& 7,'"%1$%"%;2*"$-#"1,/"%1*;")$-"5*"032+*3*-%*#
8
D*$-0-. ,7"%1,&*"=$+(*&
8
92& %1$%")$-"5*"#,-*",-"%1*3
8
>>
ContainerADTs
!"&%,'*"$-#"'*3,=*"0%*3&"0-#*2*-#*-%",7"),-%*-%&
E0&%6"&%$):6"F(*(*
8
92&?"$##6"'*3,=*
8
G0%1*'"array-based ,'"linked-nodesH5$&*#
8
Dictionary ADTs
!"2*'30%&"$))*&&"%,"#$%$"0%*3&"5;"),-%*-%"@*.A"(&0-."$":*;C
92&?"0-&*'%6"#*+*%*6"&*$')1
8
I,"032+*3*-%"J4I6"99"2',.'$330-."),-)*2%& %,":-,/?
Objects
!"5+,):&",7"3*3,';"),-%$0-0-."&,3*"#$%$
K0*+#&L$%%'05(%*&
8
D*%1,#& H2*'7,'3*#"5;",5M*)%"%,"0-%*'$)%"/0%1",%1*'&
8
I,"$))*&&"#$%$"$-#"3*%1,#&6"(&*"N#,%N"-,%$%0,-
Classes
!"$"5+(*2'0-%"7,'",5M*)%&"%1$%"#*70-*&"0%&"#$%$"@$%%'05(%*&"O"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',.'$330-."+0:*"[$=$C
8
\0++",-+;"#0&2+$;"=$+(*&"/0%10-"%1*",5M*)%8
].-,'*"*R$)%"=$+(*&",7"'*7*'*-)*&"@0A*A"$##'*&&C8
>>"$&&0.-3*-%&",-+;"$+%*'"%1*"'*7*'*-)*6"-,%"%1*",5M*)%"0%&*+7
^,"%1*"=$'0$5+*"/0++"'*7*'"%,"$"#077*'*-%",5M*)%6"$-#"%1*",+#",5M*)%"'*3$0-&"
0-%$)%"@5(%"M(&%"0&-X%"'*7*'*-)*#CA
Week$5:$abstraction$-ADTs
I1('&#$;6" V_"[(-*"YWV`
YW?ab
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Document Summary

= data structures along with their operations which manipulate the structures. Designed based on abstraction, info hiding and encapsulation. Often no need to know how types are implemented. Provide info regarding possible value types, meanings and ops that can be done on them. Ops are the only way user can interact with data tangible thing: data types (eg. int, string, ) Possible values for that type and how they can be implemented. = store and remove items independent of contents. = permits access to data items by content (eg. using a key) To implement adt, oo programming concepts to know: Methods - performed by object to interact with others. To access data and methods, use dot notation. = a blueprint for objects that defines its data (attributes + methods) class classname: = define ops that can be performed by any object created as an instance of the class. First arg must be reference to instance whose method was called.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents