![Page 1: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/1.jpg)
ADS 1 Algorithms and Data Structures 1 Syllabus
Asymptotical notation(Binary trees,) AVL trees, Red-Black treesB-treesHashingGraph alg: searching, topological sorting, strongly connected components
Minimal spaning tree (d.s. Union-Find)Divide et Impera methodSorting: low approximation of sorting problem, average case of Quicksort, randomization of Quicksort, linear sorting alg.
Algebraic alg. (LUP decomposition)
![Page 2: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/2.jpg)
LiteratureT.H. Cormen, Ch.E. Leiserson, R.L. Rivest,
Introduction to Algorithms, MIT Press, 1991
Organization Lecture Seminar
![Page 3: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/3.jpg)
Comparing of algorithms
Measures: Time complexity, in (elementary) steps Space complexity, in words/cells Communication complexity, in packets/bytes
How it is measured: Worst case, average case (wrt probability distribution) Usually approximation: upper bound
Using functions depending on size of input data We abstract from particular data to data size We compare functions
![Page 4: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/4.jpg)
Size of data
Q: How to measure the size of (input) data? Formally: number of bits of data Ex: Input are (natural) numbers ,
size D of input data is Time complexity: a function f: N->N, such that f(|
D|) gives number of algorithm steps depending on data of the size |D|
Intuitively: Asymptotical behaviour: exact graph of function f does not matter (ignoring additive and multiplicative constants), a class of f matters (linear, quadratic, exponential)
![Page 5: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/5.jpg)
Step of algorithm
In theory: Based on a abstract machine: Random Access Machine (RAM), Turing m. Informally: algorithm step = operation executable in
constant time (independent of data size) RAM, operations:
Arithmetical: +, -, *, mod, <<, && … Comparision of two numbers Assignment of basic data types (not for arrays)
Numbers have fixed maximal size Ex: sorting of n numbers: |D| = n (Contra)Ex: test for zero vector
![Page 6: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/6.jpg)
Why to measure time comlexity Why sometimes more quickly machine doesn't help Difference between polynomial and worse algs.
![Page 7: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/7.jpg)
Asymptotical complexity
Measures a behaviour of the algorithm on „big“ data It ignores a finite number of exceptions
It supress additive and multiplicative constants Abstracts from processor, language, (Moore law)
Classifies algs to categories: linear, quadratic, logarithmic, exponential, constant ... Compares functions
![Page 8: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/8.jpg)
(Big) O notation, definitions
f(n) is asymptotically less or equal g(n), notation iff f(n) is asymptotically greater or equal g(n),notation , „big Omega“iff f(n) is asymptotically equal g(n), notation , „big Theta“iff
![Page 9: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/9.jpg)
O-notation, def. II
f(n) is asymptotically strictly less than g(n),notation , „small o“iff f(n) is asymptotically strictly greater than g(n),notation , „small omega“iff Examples of classes: O(1), log log n, log n, n, n log n, n^2, n^3, 2^n, 2^2n, n!, n^n, 2^(2^n),... Some functions are incomparable
![Page 10: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/10.jpg)
Exercise
Notation: sometimes is used f=O(g) Prove: max(f,g) ɛ Θ(f+g) Prove: if c,d>0, g(n)=c.f(n)+d then g ɛ O(f) Ex.: if f ɛ O(h), g ɛ O(h) then f+g ɛ O(h)
Appl: A bound to sequence of commands Compare n+100 to n^2, 2^10 n to n^2
Simple algorithms (with low overhead) are sometimes better for small data
![Page 11: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/11.jpg)
Dynamic sets
Data structures for remembering some data Dynamic structure: changes in time An element of a dynamic d.s. is accesible
through a pointer and has1. A key, usually from some (lineary) ordered set2. Pointer(s) to other elements, or parts of d.s.3. Other (user) data (!)
![Page 12: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/12.jpg)
Operations S is a dynamic set, k is a key, x is a pointer to a
element Operations
Find(S,k) – returns a pointer to a element with the key k or NIL
Insert(S,x) – Inserts to S an element x Delete(S, x) – Deletes from S an element x Min(S) – returns a pointer to an element with
minimal key in S Succ(S,x) – returms a pointer to an element next to
x (wrt. linear ordering) Max(S), Predec(S,x) – analogy to Min, Succ
![Page 13: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/13.jpg)
Binary search trees
Dynamic d.s. which supports all operations
![Page 14: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/14.jpg)
![Page 15: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/15.jpg)
![Page 16: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/16.jpg)
![Page 17: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/17.jpg)
![Page 18: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/18.jpg)
![Page 19: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/19.jpg)
![Page 20: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/20.jpg)
![Page 21: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/21.jpg)
![Page 22: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/22.jpg)
![Page 23: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/23.jpg)
![Page 24: ADS 1 Algorithms and Data Structures 1 Syllabus Asymptotical notation (Binary trees,) AVL trees, Red-Black trees B-trees Hashing Graph alg: searching,](https://reader036.vdocument.in/reader036/viewer/2022062523/5a4d1ad07f8b9ab05997123d/html5/thumbnails/24.jpg)