Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

An appropriate structure for large-scale distributed systems is as multiple, independently administered, firewall-protected, domains. Examples are a national health service, a national police service and

An appropriate structure for large-scale distributed systems is as multiple, independently administered, firewall-protected, domains. Examples are a national
health service, a national police service and a global company with worldwide branches. Communication must be supported within and between domains and
external services may be accessed. For example, health service domains may all access a national Electronic Health Record service; police service domains may all access a national Vehicle Licensing service.
(a) (i) Define publish/subscribe communication.
(ii) What are the advantages and disadvantages of offering publish/subscribe as the only communication service?
answer all questions
(a) Explain how a Boolean matrix can be used to represent the edges of a finite
directed graph whose vertices are numbered 1 to n. [2 marks]
(b) Describe Warshall's algorithm to convert the matrix representing a graph
to one that represents its transitive closure, and carefully explain why the
algorithm works. [6 marks]
(c) Outline Floyd's algorithm, without proof of correctness, to find the cost of the
cheapest path between any two vertices of a directed graph where the edges
carry non-negative costs
(d) It is required to construct a matrix R that encodes a path with the minimum
number of edges from any vertex i to any other vertex j. Rij will be zero if
no path exists from vertex i to vertex j; otherwise, Rij will hold the vertex
number of the next vertex of a minimal path from i to j. Suggest an algorithm
to compute R from a given Boolean matrix M. [8 marks]
2 Computer Design
(a) What is the difference between a control hazard and a data hazard? [4 marks]
(b) How are data and control hazards handled for the following two processors
with their respective pipelines?
The N-105 processor pipeline:
instruction register fetch, decode, execute
fetch memory access and write back
The ARM9 processor pipeline:
instruction decode execute memory write
fetch access back
[8 marks]
(c) If a load instruction causes a cache miss, what impact does it have on the
pipeline? [3 marks]
(d) What is the structure of a TLB (Translation Lookaside Buffer)? [2 marks]
(e) What impact does a TLB miss have on the pipeline?
It is proposed to send information across a fixed delay channel using a simple
(window of 1) ARQ protocol with a transmitter timeout of T. That is, if the
transmitter does not receive an acknowledgement for a packet within time T of
sending the packet, it retransmits.
The delay of the underlying channel is τ , the data rate is B and the packet size is p
bits. Bit errors in the channel are independent and packets of size p have a packet
error rate of e. Errors in the small acknowledgement packets are rare enough to be
discounted in this analysis.
(a) What is the expected throughput of the ARQ protocol if e is zero? [4 marks]
(b) What is the expected throughput if e is non-zero, but small enough that e
2
is
negligibly small? [4 marks]
(c) How could a forward error code help the throughput of the ARQ scheme?
[2 marks]
(d) What is meant by the term code rate of a forward error code? [2 marks]
(e) What code rate must a code which squared the error rate have in order to
improve throughput of the ARQ scheme? [4 marks]
(f ) If the forward error coder adds delay, how will this affect performance?
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
public static final BigDecimal TAX_RATE = new BigDecimal(0.13);
private Map items = new HashMap();
/**
* Update the quantity of a particular MenuItem in an order.
*
* @param item     The MenuItem to purchase - the HashMap key.
* @param quantity The number of the MenuItem to purchase - the HashMap value.
*/
public void add(MenuItem item, int quantity) {
// your code here
}
* @return the total price for the MenuItems ordered.
*/
public BigDecimal getSubTotal() {
// your code here
return null;
}
/**
* Calculates and returns the total taxes to apply to the subtotal of all
* MenuItems in the order. Tax rate is TAX_RATE.
*
* @return total taxes on all MenuItems
*/
public BigDecimal getTaxes() {
code here
return null;
}
/**
* @return total price
*/
public BigDecimal getTotal() {
code here
return null;
}
/**
@Override
public String toString() {
code here
return null;
}
* @param item The MenuItem to update
* @param quantity The quantity to apply to item
*/
public void update(MenuItem item, int quantity) {
// your code here
}
/*
* Implements the Printable interface print method. Prints lines to a Graphics2D
* object using the drawString method. Prints the current contents of the Order.
*/
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
int result = PAGE_EXISTS;
if (pageIndex == 0) {
Graphics2D g2d = (Graphics2D) graphics;
g2d.setFont(new Font("MONOSPACED", Font.PLAIN, 12));
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
/ code here - write the contents of Order using drawString
} else {
result = NO_SUCH_PAGE;
}
return result;
}
}
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.print.PrinterJob;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
* The GUI for the Order class.
*
*/
@SuppressWarnings("serial")
public class OrderPanel extends JPanel {
/**
* Implements an ActionListener for the 'Print' button. Prints the current
* contents of the Order to a system printer or PDF.
*/
private class PrintListener implements ActionListener {
@Override
public void actionPerformed(final ActionEvent e) {
final PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(order);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (final Exception printException) {
System.err.println(printException);
}
}
}
}
private class QuantityListener implements FocusListener {
// your code here
@Override
public void focusGained(final FocusEvent evt) {
code here
}
@Override
public void focusLost(final FocusEvent evt) {
// your code here
}
}
// Attributes
private Menu menu = null;
private final Order order = new Order();
private final JButton printButton = new JButton("Print");
private final JLabel subtotalLabel = new JLabel("0");
private final JLabel taxLabel = new JLabel("0");
private final JLabel totalLabel = new JLabel("0");
/**
* Displays the menu in a GUI.
*
* @param menu The menu to display.
*/
public OrderPanel(final Menu menu) {
this.menu = menu;
this.layoutView();
}
/**
* Uses the GridLayout to place the labels and buttons.
*/
private void layoutView() {
this.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
// Number of rows of GridLayout must be updated to accommodate all MenuItems,
// totals, and Print button
this.setLayout(new GridLayout(3, 4));
this.add(new JLabel("Item"));
this.add(new JLabel("Price"));
this.add(new JLabel("Quantity"));
// your code here
// Add all other JLabels, JTextFields, and JButtons here
// Register listeners here
// Register the PrinterListener with the print button.
this.printButton.addActionListener(new PrintListener());
this.add(this.printButton);
return;
}
Given the GUI, text
import java.io.FileNotFoundException;
import javax.swing.JFrame;
/**
* Executes the GUI interface for this program.
*/
public class RestaurantGUI {
/**
* @param args Unused.
*/
public static void main(String[] args)  {
try {
Menu menu = new Menu("menu.txt");
JFrame frame = new JFrame("WLU Foodorama");
frame.setContentPane(new OrderPanel(menu));
frame.setSize(280, 340);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} catch (FileNotFoundException e) {
System.out.println("Cannot open menu file");
}
}
}
import java.io.FileNotFoundException;
/**
* Executes the text-based interface for this program.
*
*/
public class RestaurantText {
/**
* @param args Unused.
*/
public static void main(String[] args)  {
try {
Menu menu = new Menu("menu.txt");
Cashier cashier = new Cashier(menu);
cashier.takeOrder();
} catch (FileNotFoundException e) {
System.out.println("Cannot open menu file");
}
System.exit(0);
}
}
Write  Java program that prompts the user to enter a password that matches a specific pattern. Your program must approve the user's entry
: Write a program that first gets a list of six integers from input. The first five values are the integer list. The last value is the upper threshold. Then output all integers less than or equal to the threshold value.
Write recursive function that takes positive int n as its input and returns sum of the first n squares
(a) Explain how a parse tree representing an expression can (i) be converted
into stack-oriented intermediate code and then (ii) be translated into simple
machine code for a register-oriented architecture (e.g. ARM or IA32) on
an instruction-by-instruction basis. Also indicate how this code might be
improved to remove push-pop pairs introduced by (ii). Your answer need
only consider expression forms encountered in the expression:
h(a, g(b), c) * 3 + d
[12 marks]
(b) In Java, expressions are evaluated strictly left-to-right. Consider compiling
the function f in the following Java class definition:
class A
{
static int a,b;
void f() { ... ... }
int g(int x) { ... a++; ... }
};
Indicate what both the intermediate code and (improved as above) target code
might be for for the cases where is:
(i) b = g(7) + a;
(ii) b = a + g(7);
(iii) b = (-g(7)) + a;
(iv) b = a - g(7);
Comment on any inherent differences in efficiency at both the intermediate
code and target code levels.
Most large programs that have been written with considerable care and thoroughly
checked still seem to contain bugs at a rate of over one per 3000 lines of source
code. Systems involving hundreds of millions of lines of code can thus be expected
to contain tens of thousands of potentially catastrophic errors.
(a) List several kinds of programming errors that can appear in programs and
discuss their relative importance in relation to the long-term reliability of a
large application program.
(b) Suggest potential ways by which programmers may reduce the number of
programming errors they make, paying particular attention to language
features that might help, extra features in program development systems and
possible changes in overall system architecture. [8 marks]
(c) In what ways would you expect languages 25 years from now to differ from
those that are currently popular?






2. Programs A and B are analyzed and found to have worst-case running times no greater than 150 N/og2N and N






3. Programs A and B are analyzed and found to have worst-case running times no greater than 150 N log2 N and

2. Programs A and B are analyzed and found to have worst-case running times no greater than 150 N/og2N and N 2 respectively. Answer the following questions, if possible: (a) Which program has the better guarantee on the running time for large values of N (N> 10, 000)? (b) Which program has the better guarantee on the running time for small values of N (N

Step by Step Solution

3.48 Rating (164 Votes )

There are 3 Steps involved in it

Step: 1

1 Distributed Systems a i Define publishsubscribe communication Publishsubscribe communication is a messaging paradigm where senders publishers produce messages without specifying the recipients and s... blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Cost Accounting Foundations and Evolutions

Authors: Michael R. Kinney, Cecily A. Raiborn

8th Edition

9781439044612, 1439044619, 978-1111626822

More Books

Students explore these related Computer Network questions

Question

Difference between truncate & delete

Answered: 3 weeks ago