Abstraction A tool concept to manage complexity Hide
Abstraction • A tool (concept) to manage complexity • Hide irrelevant details; focus on the features needed Examples Integer addition File deletion using icons The brakes on a car Television remotes Primitive date types are already abstracted from bits 0/1 10/25/2021 IT 179 1
• Characterize data into different kinds for convenience Some here are primitive data types 1. 2. 3. 4. 5. 6. 7. 8. 9. 10/25/2021 bit byte integer ascii character array string real record objects + operations IT 179 2
Data Type (how to view it) • Specification View of a data type – Data values – Operations defined on those values Abstract Data Type (ADT) –use of abstraction! • Implementation View of a data type – Language-specific representation for the values – Implementation of the operations Implementation of an ADT 10/25/2021 IT 179 3
Abstract Data Type (ADT) Abstract model of Priority Queues (Specification View) insert one item Priority Queue a black box 10/25/2021 IT 179 Get the one with the highest priority the minimum one (or maximum) 4
Abstract Data Type (ADT) Abstract model of Priority Queues (Implementation View) insert one item Binary Search Tree or Binary Heap? Get the one with the highest priority the minimum one (or maximum) 10/25/2021 IT 179 5
Collection is an ADT Typical Operations • • • Add an element Remove an element Replace an element Retrieve an element Determine if a collection contains an element • Get the collection’s size 10/25/2021 • Determine if a collection is empty • Traverse a collection • Determine if two collections are equal • Clone a collection • Serialize a collection IT 179 6
List is a Collection with extra two requirements 1. Homogenous 2. Logical Order Student 1, Student 2, Student 3, Student 4 10/25/2021 IT 179 7
At the implementation level: Tow kinds of student 4 Lists Linked List student 1 Array student 2 student 1 student 3 student 4 student 3 10/25/2021 IT 179 student 2 8
Array Characteristics Array A 10/25/2021 student 1 A[0] student 2 A[1] student 3 A[2] student 4 A[3] • The elements of an array are in adjacent memory locations • An array is a random (direct) access data structure. IT 179 9
Collection Queue {interface} List {interface} Random. Access Abstract. List {marker interface} {abstract} The Java Collections Framework (JCF) UML Class Diagram Array. List Vector Java Provides a List interface for several implementations 10/25/2021 Stack IT 179 Abstract. Sequential. List {abstract} Linked. List 10
What can be done? What can be easily done? Some typical operations Array Linked List on Lists student 4 1. 1 Random student access student 2. 2 Add/remove from the head student 3 student 1 3. Add/remove from the tail student 4 4. Add/remove from the middle student 3 student 2 5. Resize 10/25/2021 IT 179 11
- Slides: 11