Chapter 0, 1 (intro) Flashcards

1
Q

Deciding on the proper algorithm

A

Analyze underlying characteristics of problem

Design algorithm according to characteristics of problem, NOT types of problems

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

What is an algorithm?

A

Sequence of unambiguous instructions for solving a problem in the finite amount of time

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

Fundamentals of algorithmic problem solving

A

Problem -> Algorithm -> (input-> ‘computation’ -> output)
|
Definiteness
Finiteness
Effectiveness

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

Euler path

A

A path that uses every edge of the graph exactly once. The path starts and ends at different vertices

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

Euler circuit

A

an Euler path that starts and ends at the same vertex

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

Analysis of algorithms is the determination of the amount of ____ and ____ resources required to execute it

A

time
space

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

Efficiency or running time of algorithm is stated as a function relating input size to the number of steps, known as ___ ___, or volume of memory, knowm as ____ ____

A

time complexity
space complexity

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

Programming paradigm
Procedural

A

state the order in which to execute instructions (how to compute the answer)

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

Programming paradigm
Declarative

A

does not state the order in which to execute instruction, instead, declare properties of the desired result (not how to compute the answer)

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

Data Structures

A

Storing and organizing data so data can be accessed efficiently
- Linear Data structures
* Arrays (static vs. dynamic)
* Linked Lists (Singly vs doubly)
- stacks
- Trees
- Graphs
- Sets and Dictionaries

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

An array contains ____ _____

A

homogeneous elements

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

Static array

A

allocated at compile time, its size must be a compile time constant.
Size of array is allocated on the stack

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

Dynamic array

A

allocated at run time.
Size is allocated on the heap.
May be allocated and then de-allocated multiple times

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

A linked list contains nodes and each node stores its elements

A

Singly linked list
Doubly linked list
Circularly linked list

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

Writing code for Linked Lists

A

A class define the node

A class define the linked list

Using head and tail to construct linked lists

Operations on the linked list

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

Operations on Singly Linked List

A
  • SinglyLinkedList()
  • ~SinglyLinkedList()
  • bool empty()
  • addFront(item)
  • removeFront()
  • displaySinglyLinkedList()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Singly linked list acting like stack

A

First in Last out (FILO)

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

Doubly Linked List operations

A

– DoublyLinkedList();
– ~DoublyLinkedList();
– bool empty();
– void addFront(dNode& newNode);
– void addBack(dNode& newNode);
– void removeFront();
– void removeBack();
– void displayDoublyLinkedListFromFront();
– void displayDoublyLinkedListFromBack();

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

A circularly linked list has the same kind of nodes as a
singly linked list.
The nodes of a circularly linked list are linked into a ______

A

cycle

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

Arrays are faster than linked lists because they use an ____ _____

A

array index

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

____ ____ are faster if an element must be removed from the middle of inserted into the middle

A

Linked lists

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

Stacks

A

LIFO (last-in first-out)

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

stack operation:
push(e)

A

Insert element e at the top of the stack

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

stack operation:
pop()

A

Remove the top element from the stack; an
error occurs if the stack is empty

25
Q

stack operation:
top()

A

Return a reference to the top element on the
stack, without removing it; an error occurs if the
stack is empty

26
Q

stack operation:
size()

A

Return a reference to the top element on the stack, without removing it; an error occurs if the stack is empty

27
Q

stack operation:
empty()

A

Return true if the stack is empty and false
otherwise

28
Q

Tree

A

an abstract data type that stores elements
hierarchically.

29
Q

With the exception of
the top element, each
element in a tree has a
____ element and
zero or more _____
elements. Typically, the
top element is called
the _____ of the tree.

A

parent
children
root

30
Q

We define a (general) tree to be a set of nodes storing elements in a parent-child relationship with the following properties:

– If a tree T is nonempty, it has a special node, called the root of T, that has no parent.

– Each node v of T different from the root has a unique parent node w; every node with parent w is a ___ of w.

A

child

31
Q

siblings

A

nodes that are children of the same parent

32
Q

A node v is _____ if v has no children.

A

external

33
Q

A node is ____ if it has one or more children.

A

internal

34
Q

External nodes are also known as _____.

A

leaves

35
Q

A graph G is simply a set V of ____ and a collection of E of pairs of vertices from V, called _____.
G = {V, E}, where
V = {V1, V2, …, Vn}
E = E{ij} = (Vi, Vj), 1 <= i <= n, 1 <= j <= n}

A

vertices
edges

36
Q

Directed graph (digraph)

A

set of vertices and a
collection of directed edges that each connects an
ordered pair of vertices.
X -> X
| ^
▼ |
X <- X

37
Q

undirected graph

A

set of vertices and a collection of
undirected edges that each pair of vertices is not ordered.

38
Q

mixed graph

A

has both directed and undirected edges.

39
Q

End vertices (_____) are the two vertices joined by an edge.
– If an edge is directed, its first endpoint is its ____ and the other is the destination of the edge.

A———–B
A and B are endpoints

A

endpoints
origin

40
Q

When an edge connects two vertices, we say that the vertices are _____ to one another and that the edge is _____ on both vertices

A

adjacent
incident

41
Q

Adjacency matrix

Let the vertices of graph G be labeled V1, V2, …, Vn. The Adjacency Matrix A(G) is the n x n matric:
a{ij} = 1 if v[i]v[j] is an edge of G; 0 otherwise

Sine a vertex is never adjacent to itself, A(G) has 0’s on the diagonal.

A

A matrix each of whose entries is 0
or 1.
* Examples are the identity matrix and the zero matrix.

42
Q

Adjacency List structure

A

A graph G has vertex set V(G)={v1, v2, …, vn} and edge set E(G) = {e1, e2, … em}. The adjacency list structure represents a graph by the adjacency lists of all the vertices

43
Q

Adjacency list of a vertex v is a sequence of vertices adjacent to ____

A

v

44
Q

The ____ _____ of a vertex are the directed edges whose origin is that vertex.

A

outgoing edges

45
Q

The ____ _____ of a vertex are the directed edges whose destination is that vertex.

A

incoming edges

46
Q

The _____ of a vertex v, denoted deg(v), is the number of incident edges of v.

A

degree

47
Q

The in-degree and out-degree of a vertex v are the incoming and outgoing edges of v and are denoted _____() and ____(), respectively

A

indeg(v)
outdeg(v)

48
Q

self-loop

A

an edge that connects a vertex to itself

49
Q

Two edges are ____ if they connect the same pair of vertices.

A

parallel

50
Q

A ____ in a graph is a sequence of vertices connected by edges. A ____ ____ is one with no repeated vertices.

A

path
simple path

51
Q

A _____ is a path (with at least one edge) whose first and last vertices are the same.

A

cycle

52
Q

A ____ _____ is a cycle
with no repeated edges or vertices (except the requisite repetition of the first and last vertices).

A

simple cycle

53
Q

the ____ of a path or a cycle is its number of edges

A

length

54
Q

A ______ G’ of a graph G is a graph G’
whose vertices and edges are subsets of those of G.

A

subgraph

55
Q

one vertex is ______ to another if
there exists a path that contains both of them.

A

connected

56
Q

A graph is connected if there is a path from every vertex to ____ other vertex.

A

every

57
Q

A graph that is not connected consists of a set of ____ _____, which are maximal connected subgraphs

A

connected components

58
Q

Acyclic graph

A

graph with no cycles

59
Q
A