(a) A user complains that their web application Times Out after successfully connecting to a remote host, yet, an investigation with ping indicates the remote
(a) A user complains that their web application Times Out after successfully connecting to a remote host, yet, an investigation with ping indicates the remote host is alive. Propose a cause of this fault and outline a test-strategy that could be used automatically to detect such a fault. [4 marks] (b) A user would like to infer the path between two hosts; they suggest using the utility ping. Make your argument for why traceroute is the more appropriate utility, comparing and contrasting their operation
(a) Into what three cases can a linear program in standard form be classified? [3 marks] (b) Consider the (unweighted) vertex cover problem for the graph G = (V, E) with V = {1, 2, 3} and E = {{1, 2}, {2, 3}, {1, 3}}. (i) Write down the linear program relaxation for the vertex cover problem and solve the linear program. [6 marks] (ii) Based on the solution of the linear program in (b)(i), derive an integer solution using the rounding approach described in the lecture. [2 marks] (c) Consider the following randomised algorithm for the unweighted vertex cover problem: Initialize S to be the empty set For all edges e=(u,v) do If neither u nor v belongs to S Randomly choose u or v with probability 1/2 and add the vertex to S End If End For Return S Derive an upper bound, as tight as possible, on the approximation ratio of the algorithm. Hint: Try to find an invariant that bounds from below the size of the intersection of the current solution S = S(i) with the optimum solution, where S(i) denotes the set S after the i-th iteration of the FOR loop
ensure to answer all
With the growth of online shopping, Internet based companies are increasingly battling for sales. While price can be a factor, many companies such as Walmart and Amazon are now competing to find quicker ways to ship products to consumers. If one company can get you the product tomorrow, you are more likely to buy from them over another company that will only get it to you the day after tomorrow.
You have been hired by The Congo Company, a new start up online merchant that has ambitions to one day be larger than Amazon. First, they need to build out some warehouses and a back-end program that can find the closest warehouse to a customer and determine the number of days it takes for a package to reach them.
Program
You will be creating the back-end program for The Congo Compamny. Your program will consist of 3 classes:
GeoLocation - Calculates distance between two points Orders - Returns an ArrayList of orders MarketingRunner - Program to calculate shipping times The GeoLocation class is complete, however you will need to examine it to understand how it works. Your orders will be GeoLocation objects and you will make GeoLocation warehouses.
The Orders class is complete, but you will want to add addresses at the top for testing purposes.
In MarketingRunner you will need to make an ArrayList of warehouse locations. Right now, your company can only afford to build 4 warehouse locations, so you will need to think strategically about what cities you place them in. Keep in mind it is more important to have fast shipping to the most customers. Shipping slow to NYC is much worse than shipping slow to Billings, Montana.
When the program runs, you will import orders from the order class. Your job is to loop through these locations and figure out which warehouse is closest and how many days it will take to ship from that warehouse. You should print the results for each address.
Note: To calculate shipping times, estimate based on distance from the closest warehouse. For every 400 miles, add a day. For example, if an address is 387 miles away, it will take 1 day, 592 miles would take 2 days, 1438 would take 4, etc.
Finally, at the end of your program, print out the total number of days that it will take when adding up the shipping days for each address and the total number of miles that you will ship by adding up all the Distance to Closest Warehouse miles.
Implement the following functions in your class: getTotalWords (returns the amount of total words), getUniqueWords s), getMostUsedWord, (returns the word that is most used) getMaxOccurrence (returns how many times the most used word occured). Name them as indicated here.
The code to add the functions to:
import edu.princeton.cs.algs4.*; import edu.princeton.cs.algs4.LinearProbingHashST; import edu.princeton.cs.algs4.SeparateChainingHashST; import edu.princeton.cs.algs4.ST; import edu.princeton.cs.algs4.SequentialSearchST; import edu.princeton.cs.algs4.In; import edu.princeton.cs.algs4.StdOut;
public class TestPerf {
public static long LinearProbingHashST(String x[]) { LinearProbingHashST st = new LinearProbingHashST(); long start = System.currentTimeMillis(); for(int i = 0; i < x.length; i++){ String key = x[i]; if (!st.contains(key)) st.put(key, 1); else st.put(key, st.get(key) + 1); } long finish = System.currentTimeMillis(); return (finish - start); } public static long SeparateChainingHashST(String x[]) { SeparateChainingHashST st = new SeparateChainingHashST(); long start = System.currentTimeMillis(); for(int i = 0; i < x.length; i++){ String key = x[i]; if (!st.contains(key)) st.put(key, 1); else st.put(key, st.get(key) + 1); } long finish = System.currentTimeMillis(); return (finish - start); } public static long ST(String x[]) { ST st = new ST(); long start = System.currentTimeMillis(); for(int i = 0; i < x.length; i++){ String key = x[i]; if (!st.contains(key)) st.put(key, 1); else st.put(key, st.get(key) + 1); } long finish = System.currentTimeMillis(); return (finish - start); } public static long SequentialSearchST(String x[]) { SequentialSearchST st = new SequentialSearchST(); long start = System.currentTimeMillis(); for(int i = 0; i < x.length; i++){ String key = x[i]; if (!st.contains(key)) st.put(key, 1); else st.put(key, st.get(key) + 1); } long finish = System.currentTimeMillis(); return (finish - start); } public static void main(String[] args) { In in = new In(args[0]); String[] tale = in.readAllStrings(); StdOut.println(); StdOut.println("LinearProbingHashST time: " + LinearProbingHashST(tale) + " ms"); StdOut.println("SeparateChainingHashST time: " + SeparateChainingHashST(tale) + " ms"); StdOut.println("ST time: "+ ST(tale) + " ms"); StdOut.println("SequentialSearchST time: " + SequentialSearchST(tale) + " ms");
} }
(a) Moore's law and Dennard scaling both predict scaling properties of CMOS chips. What are the differences between these predictions and which predictions are valid today? [4 marks] (b) How is the critical path in a clocked digital CMOS circuit determined and how does it impact the maximum clock frequency? [4 marks] (c) What is a function calling convention and how does it impact the design of the RISC-V instruction set architecture (ISA)? [4 marks] (d) Consider the following C function that computes the greatest common divisor, and the assembler produced by the compiler. The assembler has been split into segments. Describe what function each segment performs. [8 marks] int gcd(int n1, int n2) { if (n2 == 0) return n1; else return gcd(n2, n1 % n2); } ##### Segment A ##### gcd: bne a1,zero,.L7 jr ra ##### Segment B ##### .L7: addi sp,sp,-16 sw ra,12(sp) ##### Segment C ##### mv a5,a1 rem a1,a0,a1 mv a0,a5 jalr ra, gcd ##### Segment D ##### lw ra,12(sp) addi sp,sp,16 jr ra (a) How are forwarding paths used in processor pipelines? What pipeline hazards can they mitigate and what are the limitations of the mitigations? Provide one or more examples to illustrate the challenges. [8 marks] (b) For a pipelined processor implementing the RISC-V instruction set, why might branches cause bubbles in the pipeline, why are they needed and what can be done to mitigate them? Provide one or more examples. [6 marks] (c) In detail, describe the hardware mechanisms that are required to support virtual memory for a pipelined processor implementing the 32-bit RISC-V ISA.
A processor contains two cores, each with an L1 cache connected via a shared bus to an L2 cache, which is then connected to main memory. Each L1 is a direct-mapped, 4 KiB, write-back cache. The L2 is a 4-way set-associative 16 KiB cache with the least-recently-used replacement policy. All cache lines are 16 B long. The hierarchy is inclusive, runs the MSI cache coherence protocol and is initially empty. (a) Considering this cache hierarchy, (i) Explain whether it would be suitable for a system-on-chip that is only running single-threaded applications. [2 marks] (ii) Explain whether it would be suitable for a system-on-chip where each core processes a small (e.g. 6 1 KiB) array of data at a time. [2 marks] (b) Show the cache contents and coherence state of cache lines after each access in the following sequence of physical addresses, stating any assumptions you have made. All accesses are 4 bytes long and entirely complete before the next one starts. Core 1: Read 0xab18 Core 2: Read 0xdb14 Core 1: Write 0x1b10 Core 1: Read 0xab14 Core 1: Read 0xbb1c Core 2: Write 0xa010 Core 1: Read 0x2b10 Core 2: Read 0x1b10 Core 1: Read 0xa018 Core 1: Write 0x1b14 [8 marks] (c) Describe the impact of each change below (in isolation) on the cache hierarchy. (i) Increasing the L1 cache size. (ii) Increasing the line size in all caches. (iii) Increasing the associativity of the L1 caches.
Write a program in C programming language to compute quadratic equation 1b. Write program in C programming language to calculate area and perimeter of a rectangle 1c. Write program in C programming language to compute area and circumference of a circle write c program to insert a c program into a linked list
(a) For IPv4 ISPs, each domestic installation typically gets a /32 network. You have a complicated configuration requiring NAT and multiple IPv4 subnets. (i) Why would an IPv6 based provider allocate four /64 networks for your premises when each /64 represents 264 addresses? [2 marks] (ii) A colleague has IPv6 with another provider; they only allow one /64 for each domestic installation. In the past your colleague has used a NAT and many IPv4 private address blocks, but keenly adopted IPv6 permitting them to upgrade their home network. They are now using blocks of the allocated /64 and a router in their home to interconnect the subnets. Not everything is working as they hoped; for example, sometimes IoT devices can't connect to the Internet to update and your colleague can not connect to their front-door camera when at work. Explain what sort of problems your colleague may face along with methods by which they could verify the root cause. [6 marks] (iii) Explain to your colleague why you might not be able to lend them one of your /64 allocations, even though the /64 blocks (provided to you by your ISP) are each globally routable addresses. [2 marks] (b) A local area network may carry several different LANs simultaneously; such a network would be designated for known sets of HomePlug devices. Describe a physical line coding approach for the HomePlug devices that: allows two or more simultaneous virtual local area networks to fairly share the same physical channel, but does not permit trivial interception of network traffic. Outline your approach along with its benefits and drawbacks, comparing it with the simplest use of VLAN tags in Ethernet.
(a) Explain what happens to the state space, the possible behaviours and the reachable state space when two automata are coupled. [3 marks] (b) The Banker's Algorithm can be viewed as a predicate over shared state. What state does it operate over and does this include the program counter of the participating threads? When does it return true or false? [6 marks] (c) What is the difference between strict and non-strict isolation in a transaction processing system? What do both approaches ensure? Which can lead to a transaction abort being forced by the system and why? [3 marks] (d) "Increment and decrement operations are freely commutable" what two assumptions are required for this statement to hold? Is it true that the effects of transactions containing increment and decrement operations are always serialisable? [3 marks] (e) Customers interact with a transaction processing system over a web interface but confirmations are also sent by email, such as 'please collect from your local branch'. Should the be generated before, during, or after the process of committing the order transaction? What are the advantages and disadvantages of different approaches? Fully justify at least two design decisions in terms of system complexity and durability over a system crash. You are developing a distributed system in which you want some task to be assigned to exactly one node at any given time. If that node crashes, the task must be automatically reassigned to a different node, but you also want to ensure that there are never two or more nodes executing the task at the same time. This is known as a lease. A lease is a concurrency primitive similar to a lock (only one node may hold a lease at any time); the difference is that a lease times out if it is not renewed for some time. After timing out, another node can acquire the lease. (a) Briefly summarise how leader election works in the Raft consensus algorithm, and discuss the commonalities and differences between leader election and a lease. (Focus only on leader election, and ignore the rest of the Raft algorithm. Include the role of the term number in your explanation.) [5 marks] (b) In a partially-synchronous system with crash-recovery failures, is it possible to guarantee that a lease is always held by exactly one node? Justify your answer. [5 marks] (c) You are asked to design a lease algorithm for a system in which the set of nodes is not known in advance, and may change over time. Can the Raft leader election algorithm be used here? Why/why not? [2 marks] (d) A colleague proposes the following lease algorithm: There are three servers, each storing a value that is initially null. Assume every client has a unique ID clientId 6= null. Every 10 seconds, each client that wants to acquire the lease, or currently holds the lease, sends a request (acquire, clientId) to all three servers. When a server with current stored value v receives (acquire, n): If v = null v = n, or if its value was last set more than 30 seconds ago, then it sets its value to n and replies true. This counts as "setting the value", even if the value does not change. If its value was last set to v 6= n less than 30 seconds ago, it leaves its value unchanged and replies false. If a client receives two or more true responses from the servers, it now holds the lease, otherwise it does not hold the lease. Discuss the strengths and weaknesses of this algorithm. What faults does it tolerate? What assumptions does it make for its correctness? How might the algorithm be improved to avoid some assumptions or weaknesses?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started