Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the target node, and w is the time it takes for a signal to travel from source to target.
Now, we send a signal from a certain node K. How long will it take for all nodes to receive the signal? If it is impossible, return -1.
In this problem, a tree is an undirected graph that is connected and has no cycles.
The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, …, N), with one additional edge added. The added edge has two different vertices chosen from 1 to N, and was not an edge that already existed.
The resulting graph is given as a 2D-array of edges. Each element of edges is a pair [u, v] with u < v, that represents an undirected edge connecting nodes u and v.
Return an edge that can be removed so that the resulting graph is a tree of N nodes. If there are multiple answers, return the answer that occurs last in the given 2D-array. The answer edge [u, v] should be in the same format, with u < v.
Example 1:
1 2
Input: [[1,2], [1,3], [2,3]] Output: [2,3]
Explanation: The given undirected graph will be like this: 1 / 2 - 3 Example 2:
Explanation: The given undirected graph will be like this: 5 - 1 - 2 | | 4 - 3 Note: The size of the input 2D-array will be between 3 and 1000. Every integer represented in the 2D-array will be between 1 and N, where N is the size of the input array.
Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return -1.0.
Example: Given a / b = 2.0, b / c = 3.0. queries are: a / c = ?, b / a = ?, a / e = ?, a / a = ?, x / x = ? . return [6.0, 0.5, -1.0, 1.0, -1.0 ].
The input is: vector<pair<string, string>> equations, vector& values, vector<pair<string, string>> queries , where equations.size() == values.size(), and the values are positive. This represents the equations. Return vector.
Task: Paste the contents of lab3_ex1.s in Venus and Record your answers to the following questions. Some of the questions will require you to run the RISC-V code using Venus’ simulator tab.
What do the .data, .word, .text directives mean (i.e. what do you use them for)? Hint: think about the 4 sections of memory. .data: subsequent items put in user data segment; .word: Store the n 32-bit quantities in successive memory words; .text: subsequent items put in user text segment(machine code)
Run the program to completion. What number did the program output? What does this number represent?
34, the number represents the 9th fibonacci number
At what address is n stored in memory? Hint: Look at the contents of the registers.
at address 0x10000010
Without using the “Edit” tab, have the program calculate the 13th fib number (0-indexed) by manually modifying the value of a register. You may find it helpful to first step through the code. If you prefer to look at decimal values, change the “Display Settings” option at the bottom.
We can achieve this by mannualy manipulate the value of counter register t3 to 13
Translating from C to RISC-V
Task: Find/explain the following components of this assembly file.
The register representing the variable k. The registers acting as pointers to the source and dest arrays. The assembly code for the loop found in the C code. How the pointers are manipulated in the assembly code.