CS 270 Algorithms Oliver Kullmann Dynamic sets Simple implementa- tion Special cases Stacks Implementatio Queues Implementatio Tutorial
Week 6 Data structures
1
Dynamic sets
2
Simple implementation
3
Special cases
4
Stacks
5
Implementation
6
Queues
7
Implementation
8
Tutorial
CS 270 Algorithms Oliver Kullmann Dynamic sets Simple implementa- tion Special cases Stacks Implementatio Queues Implementatio Tutorial
General remarks
We start considering Part III “Data Structures” from CLRS. As a first example we consider two special cases of “buffers”, namely stacks and queues.
Reading from CLRS for week 5
The introduction to Part III on using sets on a computer. Chapter 10, Section 10.1.
CS 270 Algorithms Oliver Kullmann Dynamic sets Simple implementa- tion Special cases Stacks Implementatio Queues Implementatio Tutorial
Sets
The most fundamental mathematical notion is that of a set: We have the possibility to determine the elements of a set. And we can form sets, either by some set-defining property,
- r by using already given sets (e.g., unions, intersections,
differences). Now to bring the eternal and infinite world of mathematics to a computer, we need to take care of construction of “objects” destruction of “objects” naming (basically of functions)
- rder issues (sets are unordered, but in computation there is
always order). For this, CLRS uses the (generic) ADT of “dynamic sets”. ADT: “abstract data type” — values (like “sets”) and how to operate with them.
CS 270 Algorithms Oliver Kullmann Dynamic sets Simple implementa- tion Special cases Stacks Implementatio Queues Implementatio Tutorial
Elements of a dynamic sets
A “dynamic set” might contain pointers (or iterators) to objects,
- r the objects themselves (in Java this can be only integers
and other primitive types, in C++ this is possible for every type of object). Whatever the objects in a set are, access to them (especially for changing them) is only possible via a pointer (or iterator). For insertion into a dynamic set, we must be given the
- bject itself, and typically we obtain the pointer (iterator,