Graphs and Programgraphs Flashcards

1
Q

What is a directed graph?

A

A directed graph, also known as a digraph, is a set of nodes or vertices connected by edges, where the edges have a direction and connect one node to another.

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

What does a directed graph consist of?

A

A directed graph consists of a set of nodes or vertices (V) and a set of edges (E).

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

What is an edge in a directed graph?

A

An edge in a directed graph is a pair of nodes that shows the direction of the edge. The pair is written as (n, m), where n is the start node and m is the end node.

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

What is the difference between a directed graph and an undirected graph?

A

In a directed graph, edges have a direction, whereas in an undirected graph, edges have no direction.

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

What is the indegree of a node in a directed graph?

A

The indegree of a node in a directed graph is the number of edges that have the node as their end node.

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

What is the outdegree of a node in a directed graph?

A

The outdegree of a node in a directed graph is the number of edges that have the node as their start node.

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

Can a node in a directed graph have both indegree and outdegree?

A

Yes, a node in a directed graph can have both indegree and outdegree, or it can have only one of them depending on the graph structure.

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

What is a source node in a directed graph?

A

A source node is a node in a directed graph with an indegree of 0, meaning there are no edges pointing into that node.

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

What is a sink node in a directed graph?

A

A sink node is a node in a directed graph with an outdegree of 0, meaning there are no edges coming out of that node.

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

What is a transfer node in a directed graph?

A

A transfer node is a node in a directed graph with both an indegree and an outdegree that are greater than 0, meaning there are edges coming into and out of that node.

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

What is a directed path in a graph?

A

A directed path is a sequence of edges in a directed graph where each edge connects the end node of the previous edge to the start node of the next edge.

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

What is the empty sequence in a directed path?

A

The empty sequence, denoted by <>, is a valid directed path in a graph that consists of no edges and no nodes.

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

What is a cycle in a directed graph?

A

A cycle in a directed graph is a directed path that begins and ends at the same node, with at least one non-empty sequence of edges between the start and end nodes.

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

Is the empty sequence a cycle in a directed graph?

A

No, the empty sequence is not a cycle in a directed graph because it does not connect any nodes or edges.

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

What is control flow?

A

Control flow, also known as flow of control, refers to the order in which statements within a program are executed.

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

How is a Java program represented as a graph?

A

A Java program can be represented as a directed graph, where nodes represent statements or fragments of statements, and edges represent the flow of control between statements. An edge is drawn from node i to node j if statement j can be executed directly after statement i.

17
Q

What are the nodes and edges in a program graph?

A

Nodes in a program graph represent individual statements or fragments of statements in the Java program. Edges represent the flow of control between statements, indicating the order in which they are executed.

18
Q

What is manual program execution?

A

Manual program execution involves stepping through a program line by line, executing each statement in turn and observing the output or changes to program state.

19
Q

How can manual program execution help understand control flow?

A

By manually executing a program and observing the order in which statements are executed, one can gain a better understanding of the control flow of the program. This can help with debugging and identifying potential issues with the flow of control.

20
Q

What is the relation between the program graph and control flow?

A

The program graph is a visual representation of the control flow of a program. It shows the order in which statements are executed and the flow of control between them. Every path through the program graph corresponds to a possible execution of the program.

21
Q

What is the significance of the source node and sink node in a program graph?

A

The source node is the node in a program graph that represents the starting point of the program, while the sink node represents the end point of the program. Every terminating execution of the program corresponds to a path through the program graph that begins at the source node and ends at the sink node.

22
Q

Can there be multiple paths through a program graph that correspond to the same execution of a program?

A

No, every terminating execution of a program corresponds to exactly one path through the program graph. However, there may be multiple paths through the graph that represent different ways of reaching the same end result.

23
Q

How can program graphs be useful in testing and debugging?

A

Program graphs can help identify paths through the program that have not been executed or tested, allowing for more comprehensive testing. They can also help identify potential logic errors or issues with the flow of control in the program. By visualizing the control flow of the program, developers can better understand how the program works and identify areas for improvement.