DECISION Flashcards
A list of n items needs to be sorted into descending order starting at the left-hand entry. Describe how to carry out the first pass of a bubble sort on the numbers in the list.
-In the first pass, we compare the first number with the second and swap them if the second is larger than the first
-We now compare the second number with the third and swap them if the third number is larger than the second number
-We continue this untill we reach the end of the list
What is the final step of a sort?
Writing “sort complete”
How do you approximate time of an algorithm?
And why is it an approximation
Time = t x f(n2)/f(n1)
The runtime is not exactly proportional to …
Graph
A set of vertices connected by edges
Degree of a vertex
Number of edges coming out of it
Isomorphic
Two graphs are isomorphic if there is a 1:1 correspondance between their vertices which preserve adjacency
Subgraph
A graph whose edges and vertices are contained within the original graph
Walk
A sequence of connecting edges
Trail
A walk in which no edge is listed more than once
Path
A walk in which no vertex is visited more than once
Cycle
A path that finishes where it started
Connected graph
A graph where there is a path between any pair of vertices
Simple graph
-no edge begins and ends at the same vertex (no loops)
-no two edges connect the same pair of vertives (no repeated edges)
Tree
A conected graph with no cycles
Spanning tree
A subgraph that includes all the vertices of the original graph, and is also a tree