Download presentation
Presentation is loading. Please wait.
1
Abstract Data Types (ADTs)
CS 261 – Data Structures Abstract Data Types (ADTs)
2
Container Classes Over the years, programmers have identified a small number of different ways of organizing collections of data These container abstractions are now the fundamental heart of the study of data structures Examples: bag, stack, queue, set, map, etc.
3
Three Levels of Abstraction
There are at least three levels of abstraction in the study of data structures: ADT: Abstract Data Type, language independent Interface: the interface in a particular library of containers Implementation: the various implementations in a particular library
4
ADT (Abstract Data Type) View
Every data type can be described in a way that is independent of language/library Example: a Stack is a collection that has the property that an item removed is the most recently entered item Properties that are true regardless of the names given to operations in library An Abstract Data Type is: A behavior-level description of the operations on and properties of some data/values
5
Metaphors ADT view are often described by metaphors:
Example: stack of plates Easy to remember Easy to understand
6
The Interface View Gives specific names and parameters to operations:
struct Stack; void initStack(struct Stack *stk); void pushStack(struct Stack *stk, double val); double topStack(struct Stack *stk); void popStack(struct Stack *stk); int isEmptyStack(struct Stack *stk); In C, interface view is defined by .h file(s)
7
Interface View: Additional Information
The interface view gives only signatures (i.e., declarations) Must also attach meanings (LIFO properties of stack, etc.) Can also attach expected execution times (want push and pop to be constant time)
8
Implementation View Fill in the (language specific) details:
void pushStack(struct Stack *stk, double val) { stk->data.add(val); } int stackIsEmpty(struct Stack *stk) { return vectorSize(stk->data) == 0: In C, implementation view is defined by .c file(s)
9
Study of Data Structures
The study of data structures moves constantly between all three views: ADT view is constant from one language to the next Interface view allows you to compare implementations using common terminology Implementation allows you to see how it is done
10
The Classic ADTs Simple collections: Arranged by position:
Bag Ordered bag Arranged by position: List (Indexed) Ordered by insertion: Stack Queue Deque Ordered by removal: Priority queue Unique elements: Set Key/value associations: Map (dictionary)
11
The Classic Implementation Techniques
Arrays and Vectors Linked Lists Binary Trees, Balanced Trees Heaps Hash Tables Skip Lists Etc., etc., etc.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.