Definitions List Flashcards

1
Q

Algorithm

A

An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in a nite amount of time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Big-O Notation

A

A function f(n) is in O(g(n)) (read “f is in big oh of g”) if there are positive numbers c and n₀ such that for all n ≥ n₀ it holds that t(n) ≤ cg(n).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Lexicographic order

A

In simple terms, Python sorts into Lexicographic order by default.

Let x and y be two sequences containing mutually comparable elements. Then we call x lexicographically smaller than y if either

a) up to some position i (exclusive) all elements of x and y are equal and x[i] < y[i]
b) if x is a proper prefix of y, i.e., x is shorter than y and the leading positions of y contain exactly the same element as x.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

NP, complexity class

A

The class NP is the class of decision problems D that have a polynomial time verification algorithm A.

That is:

A accepts as inputs pairs of D-inputs x and short certificates c

For each D-input there is a certificate such that A(x, c) = True if and only if x is a yes-input of D.

Note: the length of c must be polynomially bounded in the length of x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Assertion

A

An assertion is a logical statement on a program (execution) state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Computational complexity

A

The computational (time) complexity of an algorithm is the number of elementary steps T(n) needed for computing its output for an input of a size n.

Note: this typically is in the best or worst case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Decision Problem

A

A computational problem is called a decision problem if the required output for each input is Boolean (yes or no).

Inputs for which output is yes (True) are a called yes-input.

Inputs for which output is no (False) are a called no-input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Invariant

A

An assertion INV is a loop invariant for a loop if the loop initialisation will yield a state in which INV holds and every execution of the loop body yields a state in which INV holds again (if run in any state in which INV holds and the loop exit condition does not hold).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a NP-complete?

A

A decision problem D is NP-complete if it is:

  • In NP

and

  • All problems in NP are polynomially reducible to D
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Permutation

A

A sequence a is a permutation of a sequence b if a and b contain the same elements at the same number of positions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

P, complexity class

A

The class P is the class of decision problems that can be solved by a polynomial time algorithm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Polynomial time

A

An algorithm is called polynomial time if its worst-case time complexity is in O(p(n)) for some polynomial p

(e.g. O(n), O(n²), O(n³), etc.).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Polynomially reducible

A

A function exists to convert one decision problem to a different problem in polynomial time

A decision problem D₁ is polynomially reducible to a decision problem D₂ if there is a function t that transforms inputs of D₁ to inputs of D₂ such that t is computable by a polynomial time algorithm and maps yes-inputs of D₁ to yes-inputs of D₂ and no-inputs of D₁ to no-inputs of D2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Adjacency Matrix

A

Represntation of a graph as a 2D square matrix

An adjacency matrix is an n×n table with 0/1 entries that represent a graph G = (V, E) of n vertices by storing in row i and column j whether there is an edge between vertices i and j (0 means no edge, 1 means edge present).

[[0,1,1,0],

  • *[1,0,1,1],**
  • *[1,1,0,0],**
  • *[0,1,0,0]]**
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Adjacency List

A

List of lists, where each child list includes all the nodes that link to the existing node

An adjacency list is a list containing n lists that represents a graph of n vertices by storing in the i ͭ ͪ list the indices of the vertices adjacent to vertex i in order.

E.g.

[[1,2],

  • *[0,2,3],**
  • *[0,1],**
  • *[1,3]]**
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Binary Search Tree

A

Binary tree - all vertices to the left are smaller, all vertices to right are larger

A binary search tree is a binary tree where all vertices are labelled with mutually comparable keys and that satisfies the following order property:

for each vertex v with label k the labels of all vertices in the left subtree of v are less or equal to l

and the labels of all vertices in the right subtree of v or greater or equal to k.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Bit List

A

List of yes/no flags showing which options to include

A bit list is a list of 0/1 entries that represents a sub-selection of elements of some base list of options of the same length through the following convention: the i ͭ ͪ option is present in the sub-selection if the i ͭ ͪ element of the bit list is 1 (and 0 otherwise).

E.g.: bit list of length 3

[[0,0,0], [0,0,1], [0,1,0], [0,1,1], [1,0,0], [1,0,1], [1,1,0], [1,1,1]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Min Heap

A

Type of tree where children are bigger than parent

A min heap is a binary tree where all vertices are labelled with mutually comparable keys that satisfies the following two properties:

  • The tree is essentially complete, i.e., only some right-most vertices on the last level can be missing.
  • The tree is partially ordered, i.e., for each vertex v with label k, the labels of each of its children are greater or equal to k.

1

/ \

2 3

/ \ / \

4 5 9 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Max Heap

A

Type of tree where children are smaller than parent

A max heap is a binary tree where all vertices are labelled with mutually comparable keys that satisfies the following two properties:

  • The tree is essentially complete, i.e., only some right-most vertices on the last level can be missing.
  • The tree is partially ordered, i.e., for each vertex v with label k, the labels of each of its children are less than or equal to k.

100

/ \

40 50

/ \ / \

10 15 50 40

20
Q

Queue

A

A queue is a linear data structure in which elements are added only to the back (enqueue) and removed only from the front (dequeue).

21
Q

Stack

A

A stack is a linear data structure in which elements are added (push) and removed (pop) only from the back.

22
Q

Table

A

A table is a data structure that organises a set of values along the two dimensions of rows and columns.

23
Q

Graphs

Clique

A

A set of vertices where every vertex joins to every other vertex

A clique is a subset of vertices C of a graph such that for every two distinct vertices v, w from C there is an edge between v and w (compare with an independent set).

24
Q

Connected

A

A graph is called connected if it contains a path between any two of its vertices.

25
Q

Cycle

A

A path that returns to the beginning

A cycle is a path P = [v₁ , . . . , vₖ] in a graph such that v₁ = vₖ.

26
Q

Path

A

A series of nodes that does not intersect itself.

A path is a non-self-intersecting sequence P = [v₁, . . . , vₖ] of successively connected vertices in a graph G = (V, E). That is, for all m from 1 to k − 1 we have that (vₘ, vₘ₊₁) is in E, and for all m, n with 1 ≤ m < n ≤ k we have that if vₘ = vₙ then m = 1 and n = k (that means a vertex is only allowed to show up twice in the path if it is the start and end vertex, in which case we refer to the path as a cycle).

27
Q

Path Length

A

For a path with no edge weights, the number of edges
For a path with edge weights, the sum of the edge weights

The length of a path P = [v₁, . . . , vₖ] in an edge-weighted graph

G = (V, E, w) is the sum of all edge weights along the path, i.e., w(v₁, v2)+ . . . + w(vₖ₋₁, vₖ).

In an unweighted graph the length P is simply the number of contained edges k-1, which is the same as assuming that all edge weights are equal to 1.

28
Q

Spanning Tree

A

Contains every node
Contains enough edges to link every node in a tree

A spanning tree of a graph G = (V, E) is a subgraph T = (V, F ) of G that contains all vertices of G and that is a tree.

29
Q

Simple

A

A graph is called simple if it does not contain loops or parallel edges. In this unit we usually assume graphs to be simple unless we explicitly mention otherwise.

30
Q

Tree

A

A tree is a graph that is connected and does not contain any cycles (acyclic).

31
Q

Vertex Cover

A

A set of nodes that includes at least one end of every link

A vertex cover is a subset of vertices C of a graph such that for every edge of the graph either of the two end points is in C.

○─●─┬○ or ●─●─┬○

└●┘ └○ └○┘ └○

not ○─●─┬○

└○┘ └○

32
Q

Rooted Trees

Binary Tree

A

A binary tree is a rooted tree where each vertex has at most two children, a left child and a right child.

33
Q

Rooted Trees

Child

A

In a tree with root r, a vertex v is called the child of another vertex p if p is the predecessor of v on the unique path from v to the root r.

34
Q

Rooted Trees

Complete

A

A rooted tree is called complete (or essentially complete) if only some right-most vertices on the last level are missing (when compared to a perfect tree).

35
Q

Rooted Trees

Height

A

The height of a rooted tree is the maximum length of a path from the root to a leaf (or -1 if the tree is empty).

36
Q

Rooted Trees

Inner Vertex

A

A vertex in a rooted tree is called an inner vertex if it has at least one child.

37
Q

Graph

Independent Set

A

A set of vertices where no two vertices have an edge between them.

An independent set is a subset of vertices C of a graph such that for every two distinct vertices v, w from C there is no edge between v and w (cf. clique).

38
Q

Graph

Hamiltonian Cycle

A

A Hamiltonian Cycle of a graph is a cycle that contains all vertices of that graph.

39
Q

Rooted Trees

Leaf

A

A vertex in a rooted tree is called a leaf if it does not have any children.

40
Q

Rooted Trees

Level

A

Number of steps from a Vertex to the root of the tree

The level of a vertex v in a tree with root r is the length of the unique path from v to r. This implies that the level of r is 0.

41
Q

Rooted Trees

Node

A

Same as vertex

The term node is a synonym for the term vertex which is often used in the context of rooted trees.

To avoid confusion, we avoid using this synonym in this unit.

42
Q

Rooted Trees

Parent

A

Next node closer to the root

The parent of a vertex v in a tree with root r is the predecessor of v on the unique path from v to the root r (the root itself does not have a parent).

43
Q

Binary Tree

Perfect

A

A binary tree is called perfect if all of its inner vertices have exactly two children and all leafs are on the same level.

44
Q

Data Structure

Pair-of-children List

A

Binary Tree as a list
Each item in the list is a tuple with the index of the left & right child

A pair-of-children list represents a binary tree as a list of length equal to the number of vertices where index i contains a pair (l; r) referring to the indices of the left and the right child of i, respectively (or a special value if a child is missing; in Python we use None for this case).

e.g. [(1,2), (3,4), (5,6),(None,None), (None,None), (None,None), (None,None)]

0

/ \

1 2

/ \ / \

3 4 5 6

45
Q

Data Structure

Parent List

A

Binary Tree as a list
Each item in the list is the parent of that vertex

A parent list represents a rooted tree as a list of length equal to the number of vertices where the parent of vertex i is stored at index i of the list.

e.g. [None, 0, 0, 1, 1, 2, 2]

0

/ \

1 2

/ \ / \

3 4 5 6