Professional Documents
Culture Documents
Abstract Data Types
Abstract Data Types
(ADTs)
What is abstract?
“An abstract idea or way of
thinking is based on general
ideas”
“Thought of apart from
concrete realities, specific
objects, or actual
instances”
2
Abstract Data Types
“It is just a concept and every Different
programming languages have a languages have
different way of implementing a different
it.” implementation
for this concept
3
Talk about data structure as:
1. Mathematical/Logic models
- just look at an abstract view of them, look at from a high
level what all features and what all operations
4
}
Electrical device
Turned on/off
Receive signals Abstract view
Audio video
5
Talk about data structure as:
1. Mathematical/Logic models
- just look at an abstract view of them, look at from a high
level what all features and what all operations
2. Implementation
- concrete types and not an abstract data
6
Different types
List
Queue
Stack
Tree
7
List
“Represents a List is nothing but a
countable number collection of objects of the
of ordered values, same type.
where the same
value may occur
more than once.”
8
Queue
An ordered collection of Queue following the
items which are added at
concept of first in first out
one end, called the
“rear,” and removed
FIFO
from the other end,
called the “front.”
9
Stack
serves as • push, which adds
a collection of an element to the
elements, with collection, and
two main • pop, which removes
principal the most recently
operations: added element that
Stack following the was not yet
concept of last in first removed.
out LIFO 10
Tree
A tree data structure can be defined recursively as a
collection of nodes (starting at a root node), where
each node is a data structure consisting of a value,
together with a list of references to nodes (the
"children"), with the constraints that no reference is
duplicated, and none points to the root.
11
12
Pointers and
Dynamic Memory
Memory
- “Is one important and crucial resource on our
machine and it is always good to know the
architecture of memory, the way operating
system manages memory and the way memory
is accessible to us as programmers.”
14
Application’s memory
Application’s memory
sq()
SOS()
Global
Total()
16
Stack
Application’s memory
sq()
SOS()
Global
Total()
17
Stack
Application’s memory
SOS()
printf
Global
Total()
18
Stack
Application’s memory
printf
Global
Total()
19
Stack
Application’s memory
Global
Total()
20
Stack 1mb
e()
Application’s memory
d()
c()
b()
Stack } Free
store
overflow
a()
Global
21
Stack 1mb
C:
}
malloc
calloc Heap Application’s memory
functions
realloc
free
C++:
new
delete } operators
250
Main()
10 200
p 200
a
Global
23
Stack
20 250
Main()
10 200
p 100
250
a
100
Global
24
Stack
Main()
200
p 100
a
100
Global
25
26