UW-Madison CS 400 Final Exam (Fall 2024)

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/123

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

124 Terms

1
New cards

Prim's Algorithm Runtime Complexity

O(E * log(v))

- E = number of edges in the graph

- v = number of nodes in the graph

2
New cards

Kruskal's Algorithm Runtime Complexity

O(E * log(v))

- E = number of edges in the graph

- v = number of nodes in the graph

3
New cards

Neighbors/Adjacent Nodes

Two nodes connected with an edge.

4
New cards

Undirected Graph

You can move through the graph in either direction. The edges do NOT have arrowheads.

<p>You can move through the graph in either direction. The edges do NOT have arrowheads.</p>
5
New cards

Directed Graph

You can only cross each edge in one direction. The edges DO have arrowheads.

<p>You can only cross each edge in one direction. The edges DO have arrowheads.</p>
6
New cards

Degree (of a Node)

The number of edges connected to a node.

7
New cards

In-Degree (of a Node)

The number of edges pointing towards a node.

8
New cards

Out-Degree (of a Node)

The number of edges pointing away from a node.

9
New cards

Cycle

A path in a graph that returns to a previously visited node.

10
New cards

Cyclic Graph

A graph that contains at least one cycle.

- Every undirected graph with at least 1 edge is a ________ graph.

11
New cards

Acyclic Graph

A graph that contains no cycle.

- No path that we could possibly take returns to a duplicate node.

12
New cards

Adjacency Matrix

A matrix that holds nodes and their connections.

13
New cards

Adjacency List

Lists outgoing edges for each node.

14
New cards

Spanning Graph

A subgraph of a graph that has all of the nodes of the original graph.

15
New cards

Under what condition will a target of a Makefile be achieved?

- The dependency is younger than the target.

- Both the dependency and target are files.

16
New cards

Depth First Traversal (DFT)

Go as deeply into the graph as we can.

17
New cards

Breadth First Traversal (BFT)

Exhaustively visit all neighbors of a node before moving on.

18
New cards

document.querySelector(

Selects one matching element in the HTML document based on the ID, class, or element.

19
New cards

document.querySelectorAll(

Selects all of the matching elements in the HTML document based on the ID, class, or element.

20
New cards

innerHTML

A field of an element. A String representing an HTML element.

- Can also change the contents of an element.

21
New cards

getBytes()

A method that gets the decimal values of each character in the response.

22
New cards

write()

Converts the decimal values into a character.

23
New cards

fetch("http:///?")

A globally available method for .html files.

- Represents the request

24
New cards

Promise

An object returned by a call to fetch().

- Represents the future results from the web server.

25
New cards

then()

Does something with the object/Promise we're getting back (i.e. the response).

- The parameter is a lambda expression that implements what we want to do with the Promise.

26
New cards

encodeURIComponent()

Takes a String and encodes it into a URI form.

- Deals with special characters

- Ex: spaces become %20

27
New cards

Lambda Expression Syntax for JavaScript

(parameter) =>

28
New cards

Lambda Expression Syntax for Java

(parameter) ->

29
New cards

Depth First Traversal Runtime Complexity (Adjacency Matrix)

O(v^2)

- v = number of nodes in the graph.

30
New cards

Depth First Traversal Runtime Complexity (Adjacency List)

O(v + e)

- v = number of nodes in the graph.

- e = number of edges in the graph

31
New cards

Breadth First Traversal Runtime Complexity (Adjacency Matrix)

O(v^2)

- v = number of nodes in the graph.

- e = number of edges in the graph

32
New cards

Breadth First Traversal Runtime Complexity (Adjacency List)

O(v + e)

- v = number of nodes in the graph.

- e = number of edges in the graph

33
New cards

Weighted Edge

Assigns a cost to each edge.

34
New cards

Cost of a Path (Weighted Edges)

Sum of edge weights along a path.

35
New cards

Cost of a Path (Unweighted Edges)

Length of the path (# of edges along the path).

36
New cards

Connected Graph

A path exists between every pair of nodes.

- From any node, you can get to any other node using edges.

37
New cards

Strongly Connected Graph

A path exists between every pair of nodes with edge directions respected.

- Any node in a graph can get to any other node, respecting directionality.

38
New cards

Weakly Connected Graph

A path exists between every pair of nodes with edge directions ignores.

- Change edges to undirected. If the new graph is connected, the original graph is _______ _____________.

39
New cards

Subgraph

G' is a ________ of G if:

- The set of nodes of G' is a subset of the nodes of G, AND

- The set of edges of G' is a subset of the edges of G

40
New cards

Dijkstra's Algorithm

Finds the shortest path between two nodes in a graph.

41
New cards

Web Server

A piece of software that allows us to publish our HTML pages and point a browser to the address of the machine running the server (and to the HTML document on there) so that we can access it from anywhere on the Internet.

42
New cards

Order of the Insets Constructor Parameters

Top, Right, Bottom, Left

43
New cards

consume()

A JavaFX method that prevents the event from moving further upwards.

- The code in the EventHandler with the consume() call will still run in entirety.

44
New cards

Data Source Operation

Puts data onto a Stream.

- T represents the type of data we want to process on that Stream.

45
New cards

Intermediate Operations

Do some sort of operation on a Stream

- Requires a terminal operation to run in the first place.

- Called on the initial stream being created by the data source operation

- Usually instance methods of type Strema

46
New cards

Terminal Operation

Generally returns a different object representing the results (rather than another Stream).

- Usually instance methods of type Stream.

47
New cards

java.util.stream.Stream.generate(Supplier )

Every object returned by the get() method of the parameter interface will be put onto the Stream

- Data source operation

48
New cards

java.util.stream.Stream.of(T ... items)

Puts all items passed as arguments onto the Stream.

- Data source operation

49
New cards

java.util.stream.Stream.concat(stream1, stream2)

Allows us to combine multiple Streams.

- The first parameter's contents is added to the Stream, then the second parameter's contents

- Data source operation

50
New cards

java.util.stream.Stream.empty()

Returns a stream with no contents.

- Data source operation

51
New cards

java.nio.file.Files.lines(path)

Returns a new Stream of type Integer, onto which it will put the lines in a given file (as Strings).

- Useful for reading in and processing text files

- Data source operation

52
New cards

filter(Predicate )

Filters the incoming Stream based on a certain criteria. The interface parameter ahas one boolean method that is called on each data item.

- True: data moves onto the outgoing stream

- False: data does NOT move onto the outgoing stream

- Intermediate Operation

53
New cards

map(Function

Applies a transformation to the data passed as input.

- T: type of data on the incoming Stream

- R: type of data on the outgoing Stream

- Intermediate Operation

54
New cards

limit(n)

Processes the first n items on the input Stream.

- Closes the Stream after the first n items.

- Intermediate Operation

55
New cards

skip(n)

Bypasses the first n data items on the input stream, and then processes the rest.

- Intermediate Operation

56
New cards

findFirst()

Waits until the first data item coming out of the Stream arrives, and returns the first data item.

- The Stream is then closed.

- Terminal Operation

57
New cards

forEach(Consumer )

Takes every item coming out of the Stream and calls the interface parameter's method on each.

- Useful for doing something (i.e. printing) with every data item.

- Terminal Operation

58
New cards

count()

Returns an int telling us how many data items from the Stream reached the terminal operation.

- Terminal Operation

59
New cards

min(Comparator )

Returns the minimum of the data items as a result of the Stream

- Terminal Operation

60
New cards

max(Comparator )

Returns the maximum of the data items as a result of the Stream

- Terminal Operation

61
New cards

Redirection Operator (>)

Overwrites the contents of a file (after the >) with the result of the command before the >.

62
New cards

Redirection Operator (>>)

Preserves the old contents of a file (after the >), appending the result of the command (before the >) to the end of the file.

63
New cards

wc .txt

A Bash command giving us three different numbers related to the file.

- First number: # of lines

- Second number: # of words

- Third number: # of characters

64
New cards

grep "" .txt

Uses regular expressions to filter through a file.

65
New cards

sort .txt

Sorts the lines of a file in alphabetically ASCENDING order.

- Case sensitive (capital letters come first, lowercase letters come second)

66
New cards

sort -f .txt

Sorts the lines of a file in alphabetically ASCENDING order.

- NOT case sensitive

67
New cards

sort -r .txt

Sorts the lines of a file in alphabetically DESCENDING order.

- Case sensitive (capital letters come first, lowercase letters come second)

68
New cards

head -n .txt

Allows us to to look at the the top n lines of a file.

69
New cards

tail -n .txt

Allows us to look at the bottom n lines of a file.

70
New cards

Pipe Redirection Operator (|)

Takes the output of the command on the left side and uses it as the input of the command on the right side.

71
New cards

Contains/Search (Balanced BST) Runtime Complexity

O(log(n))

72
New cards

Add/Insert (Balanced BST) Runtime Complexity

O(log(n))

73
New cards

Remove (Balanced BST) Runtime Complexity

O(log(n))

74
New cards

Contains/Search (General BST, not necessarily balanced) Runtime Complexity

O(n): Linear Time

75
New cards

Add/Insert (General BST, not necessarily balanced) Runtime Complexity

O(n): Linear Time

76
New cards

Remove (General BST, not necessarily balanced) Runtime Complexity

O(n): Linear Time

77
New cards

Red Black Tree Properties

1. Each node is either red or black

2. The root node is black

3. No red nodes have red children

4. Every path from root to null child has the same number of black nodes (black height of the tree)

- Null children are black

78
New cards

Red Black Tree Insertion Repair #1 Runtime Complexity

O(1): Constant Time

79
New cards

Red Black Tree Insertion Repair #2 Runtime Complexity

O(H): Linear Time

- H = height of the tree

80
New cards

Red Black Tree Deletion Repair #1 Runtime Complexity

O(1): Constant Time

81
New cards

Red Black Tree Deletion Repair #2 Runtime Complexity

O(H): Linear Time

- H = height of the tree

82
New cards

Red Black Tree Deletion Repair #3 Runtime Complexity

O(1): Constant Time

83
New cards

Red Black Tree Search Runtime Complexity

O(log(N))

- N = number of nodes in the tree

84
New cards

Red Black Tree Insert Runtime Complexity

O(log(N))

- N = number of nodes in the tree

85
New cards

Red Black Tree Delete Runtime Complexity

O(log(N))

- N = number of nodes in the tree

86
New cards

JUnit Test Properties

1. @Test annotation above the method header

2. Public method

3. Void return type

4. Instance (non-static) method

87
New cards

Unit Test

A test that focuses on a single unit of code (i.e. a single method/class block)

- Advantage: easy to isolate bugs

- Disadvantage: bugs can also develop when we use other Java structures

88
New cards

Integration Test

Taking 2+ units of code and seeing if they run together as expected.

89
New cards

Opaque-Box Test

Focuses solely on publicly available methods/fields.

- Advantage: we can use the exact same test code for any implementation (portability)

- Disadvantage: the test cases may not be as fine-grained as we'd like them to be.

90
New cards

Clear Box Test

Accessing the internals of the class we're testing.

- Advantage: very in-depth and fine-grained tests

- Disadvantage: not as portable across different implementations

91
New cards

Input-Output Test

Testing specific inputs for expected outputs

- Ex: testing insertions into BSTs

92
New cards

Property test

Generating random sequences of values and checking an implementation using those values.

- Advantage: looping the process allows us to gather a lot of data

- Disadvantage: it is hard to debug an implementation because we're using random values that only cause issues in very specific cases.

93
New cards

Securely copying a file from the local laptop to the VM

scp @:

94
New cards

Securely copying a file from the the VM to the local laptop

scp @:

95
New cards

Height of a B-Tree

H = logm(N)

- N = number of nodes

- m = branching factor (the number of children nodes have in a given tree)

96
New cards

.

Indicates a class in HTML

97
New cards

#

Indicates an ID in HTML

98
New cards

Indicates an element in HTML.

99
New cards

InetSocketAddress()

Specifies the port number to use with a web server.

100
New cards

HttpServer server = new HttpServer(new InetSocketAddress(8080), 0)

Creates a new instance of HttpServer.

- The first parameter specifies the port that we want to use.

- The second parameter specifies the length of the request queue (0 for OS default)