Lecture2Blackboard

Lecture2Blackboard - ADTs and Generic Classes EECS 233...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
ADTs and Generic Classes EECS 233
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
-2- Previous Lecture: Memory Management in PLs Programming languages provide low-level support (for basic memory management mechanisms) Static storage: for global variables Stack storage: for method calls (parameters, return address, and local variables) Heap storage: for dynamic memory allocation, new() Knowing these concepts will help us develop good computer programs
Background image of page 2
-3- Where Is “data structures”? Low-level memory management of modern programming languages Various applications (managing complex types of data), to be built by high-level application programmers Data structures and algorithm design to accomplish common tasks
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
-4- Abstract Data Types Need an interface between… …“common data structures” and high-level programming …different high-level objects (modular development) An abstract data type (ADT) is the model of a data structure that specifies: What data (or what characteristics of objects of this type) are defined What operations can be performed on the data. To implement an ADT, we need to design data structures (to organize the data/information) and algorithms (to describe the procedures to complete desired tasks) The objective of this course!
Background image of page 4
-5- An Example: The Bag ADT As the name suggests, a bag is just a container for a group of data items. Analogy: a bag of candy Some characteristics of a bag: The positions of the data items don t matter (unlike a sorted list). {3, 2, 10, 6} is equivalent to {2, 3, 6, 10} The items do not need to be unique (unlike a set). {7, 2, 10, 7, 5} is a bag but not a set
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Bag Operations Operations supported by the Bag ADT: add(item): add item to the bag remove(item): remove one occurrence of item (if any) from the bag contains(item): check if item is in the bag grab(): get an item at random, without removing it numItems(): get the number of items in the bag toArray(): get an array containing the current contents of the bag The operations are provided to the programmer. Note that we don
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/07/2008 for the course EECS 233 taught by Professor Rabinovich during the Spring '08 term at Case Western.

Page1 / 19

Lecture2Blackboard - ADTs and Generic Classes EECS 233...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online