Beruflich Dokumente
Kultur Dokumente
Interface: What
Implementation: The
other objects
Abstract
Container: An
Add/insert
We
STACKS
A
STACK EXAMPLE
Operation
Push(2)
We
Push(7)
2, 7
We
Push(4)
2, 7, 4
Pop()
2, 7 (4 is removed)
Pop()
2 (7 is removed)
Push(5)
2, 5
Computer
Real-world
QUEUES
A
New
Values
Computer
Real-world
QUEUE EXAMPLE
Operation
Enqueue(2)
Enqueue(7)
2, 7
Enqueue(4)
2, 7, 4
Dequeue()
7, 4 (2 is removed)
Dequeue()
4 (7 is removed)
Enqueue(5)
4, 5
Trees
Trees
Binary tree
Root node
Leaf node
A picture is worth a
thousands words
22
23
Each node
is the root
of a subtree
made up of
its left and
right children
24
TREE TRAVERSAL
Order
Inorder: print
For
Preorder: print
Postorder: print