This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
DSA/notes.md

1.1 KiB

Complexity

General way to describe efficiency algorithms (linear vs exponential) indipendent from the computer architecture/speed.

The RAM - random-access machine

Model of computer used in this course.

Has random-access memory.

Basic types and basic operations

Has basic types (like int, float, 64bit words). A basic step is an operation on a basic type (load, store, add, sub, ...). A branch is a basic step. Invoking a function and returning is a basic step as well, but the entire execution takes longer.

Complexity is not measured by the input value but by the input size in bits. Fibonacci(10) in linear in n (size of the value) but exponential in l (number of bits in n, or size of the input).

By default, WORST complexity is considered.

Donald Knuth's A-notation

A(c) indicates a quantity that is absolutely at most c

Antonio's weight = (pronounced "is") A(100)

(big-) O-notation

f(n) = O(g(n))

Definition: if f(n) is such that f(n) = k * A(g(n)) for all n sufficiently large and for some constant k > 0, then we say that