Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Construct, with explanation, the SLR(1) action and goto matrices for the above grammar. [5 marks] Illustrate how the SLR(1) parsing algorithm works for this grammar

Construct, with explanation, the SLR(1) action and goto matrices for the above grammar. [5 marks] Illustrate how the SLR(1) parsing algorithm works for this grammar by showing the successive states of the parser stack and input stream while parsing b a b ( b a ) eof [5 marks] 3 [TURN OVER CST.95.3.4 5 Data Structures and Algorithms For each of the following situations identify one data structure or algorithm that it would be sensible to use, and another that would in principle achieve the desired result but which would have significant ects that have to be drawn with an ordering based on their distance from the viewpoint. Now the image has been changed slightly so that you can start to display the next frame of the video sequence, so all the distances ?

Numerical Analysis II Let n+ be the number of positive real roots of a polynomial pn(x). Let c be the number of changes of sign when the coefficients are taken in order. State Descartes' rule of signs. [2 marks] If p3(x) = x 3 − 8x 2 + 11x + 20 what does this rule say about the polynomials p3(x), p3(−x)? [2 marks] Newxk+1 = xk + hk+1. What is the formula for hk+1? [2 marks] Outline the damped Newton method in n variables. [4 marks] Apply the damped Newton method in one variable to find one root of the polynomial p3(x), using x0 = 1 as the starting value. Hence factorise p3(x) and draw a rough sketch e services of all European countries together decide to implement a new datacentre to host a shared database that holds human DNA fingerprints. The main operation that requires high-performance will be lookup by string matching. For each of the? following design considerations, write notes on the suitability of custom hardware accelerators in general and for the specific police DNA application. (i) The type of arithmetic and logic likely to be needed. [2 marks] (ii) The memory bandwidth and overall topology. [2 marks] (iii) The relative advantages of ASIC versus FPGA implementation. [3 marks] (iv) The likely energy and performance benefits. [2 marks] (b) An SSRAM is a static, synchronous random-access memory. (i) Draw a schematic symbol and/or describe the net-level connections to a typical SSRAM. [1 mark] (ii) Describe two ways in which an SSRAM may get instantiated in an RTL (Verilog or VHDL) design. [2 marks] (iii) What constraints does SSRAM have on its use in RTL? Give a conforming RTL fragment that increments one SSRAM location while obeying the constraints. [5 marks] (iv) In what stage of HLS do tools instantiate RAMs and how are constraints over port use overcome? [3 marks] 14 CST2.2018.9.15 14 Topical Issues (a) Explain the meaning of spread-spectrum as it applies to radio communications. Describe the principles of Frequency-hopping and Code-Division Multiple Access spread-spectrum techniques. Give an example consumer technology for each. [5 marks] (b) Explain what is meant by an underlay system in the context of radio systems. [3 marks] (c) Consider an automotive UWB pulsed radar system used to detect objects around a vehicle. (i) Describe the operating principles of UWB pulsed radar in this context. Your description should discuss range ambiguities, the effect of the Pulse Repetition Frequency (PRF), and how the distance to multiple objects can be determined. [6 marks] (ii) When multiple vehicles are equipped with UWB pulsed radars, the pulses can interfere. Discuss the effects this will produce for different PRFs.

 

 

public class Ballot {

 

public int id; // unique identifier of voting card

public String candidate;

public Ballot next;  

public Timestamp timestamp;

public boolean filled;  

 

/**

*

* @param id

* represents the official identity number of the Ballot

* @param next?

 

 

public Ballot(int id, Ballot next) {

// Provided - not to be changed

candidate = null;

this.id = id;

this.next = next;

this.filled = false;

this.timestamp = null;

}

 

 

 

/**

* Voting: the voting card is filled

*

* @param name of (possibly incorrect) candidate name

* @param time stamp of the vote

*

* need to fill the ballot: the vote

* need to check whether has been already filled (used for voting)

* and both name and time stamp are not null

*

* @return - true if ballot was successfully filled, false otherwise

*/

public boolean fill(String name, Timestamp time) {

 

 

if (this.candidate == name || this.timestamp == time ||this.filled == true) {

 

return false;

 

}

 

 

if(name != null && time != null) {

 

this.candidate = name;

this.timestamp = time;

this.filled = true;

return true;

 

} else {

 

return false;?

 

}

 

}

 

/**

*

* You may assume that the input array (String[] candidates) will

* not be null or empty.

*

* @param first - first valid id

* @param last  - last valid id

*

* A ballot is valid if it is: filled, time-stamped,

* and have an official id and a vote for one of the candidate listed

*

* @return true if the Ballot is valid based on the criteria listed above,

*         false otherwise

*/

public boolean isValid(int first, int last, String[] candidates) {

 

if(this.id <= last && this.id >= first) {

 

       if(this.timestamp != null && this.filled == true) {

   

           for(String valid: candidates) {

           

               if(this.candidate.equals(valid)) {

                   return true;

               }

           }

       }

   }

 

   return false;

 

}

 

 

 

}

 

PUBLIC CLASS EMPTYBALLOT which create empty ballot for the function

 

public class EmptyBallots {

 

public Ballot head;

 

 

 

*

* Create  list with n empty ballots, with id from 0 to n-1

*

* @param n - the number of empty ballots to create in the list

*/

public EmptyBallots(int n) {

 

int data[] = new int[n];

 

for(int x = 0; x < data.length; x++) {

 

Ballot empty = new Ballot(0, head);

 

head = empty;

 

empty.id = (n-x)-1;

 

head.id = empty.id;

}

 

}

 

/** 5 marks - Pass level

*

* Remove the first empty ballot from the list

*

* @return the removed ballot if there are still empty ballots

*         left in the list, null otherwise

*/

public Ballot remove() {

 

if(head == null) {

return null;

}

 

Ballot removed = head;

 

head = head.next;

 

return removed;

 

 

}

 

 

public boolean isValid() {

 

if (head == null) {

 

return true;

 }

 

 

 Ballot current = head;

 

 while (current.next != null) {

     if (current.id + 1 != current.next.id) {

         return false;

     }

     current = current.next;

 }

 return true;

}

 

 

}


 

 

 

how to make my addVote function more efficient

 

 

/**

*

*

* Add a vote (a ballot) for a candidate to the END of the Filled list.

*

* @param candidate - the name of the candidate voted for

    * @param ballots - the list of empty ballots where the official card comes from

    * @param a new time stamp

*

*/

 

FUNCTION

 

public void addVote(String candidate, EmptyBallots ballots, Timestamp time) {

 

Ballot now = head;

Ballot filled = ballots.remove();

 

if (filled != null) {

filled.fill(candidate, time);

}

 

if (head == null) {

 

filled.id = id;

 

head = filled;

 

filled.next = null;

 

id++;

 

return;

 

}

 

while (now.next != null) {

 

now = now.next;

 

id++;

}

 

now.next = filled;

 

id++;

 

filled.next = null;

 

 

}

 

Normal expected output (I pass it)

 

@Test

@Order(6)

@Timeout(1)

public void testFilledBallotsAddVote() {

 

assertTimeoutPreemptively(Duration.ofMillis(1000), () -> {

EmptyBallots e;

FilledBallots f;

 

// Case 1: Add one ballot

e = new EmptyBallots(100);

f = new FilledBallots();

assertNull(f.head);

f.addVote(candidates[0],e,new Timestamp());

assertNotNull(f.head);

assertEquals(candidates[0],f.head.candidate);

 

// Case 2: Add multiple ballots

e = new EmptyBallots(100);

f = new FilledBallots();

assertNull(f.head);

f.addVote(candidates[0],e,new Timestamp());

f.addVote(candidates[1],e,new Timestamp());

f.addVote(candidates[2],e,new Timestamp());

f.addVote(candidates[0],e,new Timestamp());

f.addVote(candidates[2],e,new Timestamp());

 

assertNotNull(f.head);

assertEquals(candidates[0],f.head.candidate);

assertEquals(candidates[1],f.head.next.candidate);

assertEquals(candidates[2],f.head.next.next.candidate);

assertEquals(candidates[0],f.head.next.next.next.candidate);

assertEquals(candidates[2],f.head.next.next.next.next.candidate);

assertNull(f.head.next.next.next.next.next);

});

currentMethodName = new Throwable().getStackTrace()[0].getMethodName();

}

 

 

 

 

 

@Test

@Order(12)

@Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)

public void testFilledBallotsAddVoteAdvanced() {

 

// Case 1: Medium size

assertTimeoutPreemptively(Duration.ofMillis(1000), () -> {

EmptyBallots e = new EmptyBallots(mLimit);

FilledBallots f = new FilledBallots();

for(String s : testcase3) {

f.addVote(s, e, new Timestamp());

}

assertNotNull(f);

Ballot cur = f.head;

for(int i = 0; i < 200; i++) cur = cur.next;

assertEquals(candidates[4],cur.candidate);

assertEquals(candidates[0],cur.next.candidate);

assertEquals(candidates[4],cur.next.next.candidate);

for(int i = 0; i < 500; i++) cur = cur.next;

assertEquals(candidates[3],cur.candidate);

assertEquals(candidates[3],cur.next.candidate);

assertEquals(candidates[0],cur.next.next.candidate);

});

 

// Case 2: Large size

assertTimeoutPreemptively(Duration.ofMillis(1000), () -> {

EmptyBallots e = new EmptyBallots(xLimit);

FilledBallots f = new FilledBallots();

for(String s : testcase5) {

f.addVote(s, e, new Timestamp());

}

assertNotNull(f);

Ballot cur = f.head;

for(int i = 0; i < 200000; i++) cur = cur.next;

assertEquals(candidates[2],cur.candidate);

assertEquals(candidates[2],cur.next.candidate);

assertEquals(candidates[4],cur.next.next.candidate);

for(int i = 0; i < 500000; i++) cur = cur.next;

assertEquals(candidates[0],cur.candidate);

assertEquals(candidates[3],cur.next.candidate);

assertEquals(candidates[2],cur.next.next.candidate);

});

 

currentMethodName = new Throwable().getStackTrace()[0].getMethodName();

}

 

 

Write  program that dynamically allocates an array in the freestore large enough to hold a user defined number of test scores as doubles. Once all the scores are entered, the array should be passed to a function that finds the highest score. Another

Write  program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage

Write a correct and complete C++ program that inputs 20 integer values from the user and performs three calculations. In the main function, input the values from the user.

 

Following a hardware practical class, an undergraduate comes across a tangle of n (single-strand) wires. After finding the 2n ends, he idly joins these ends together in pairs until there are no loose ends left. [At each joining, the first end is selected equiprobably from the unjoined ends and joined to a second end which is likewise selected equiprobably from the remainder.] Another undergraduate later comes across the handiwork of the first and decides to count the number of loops in the tangle. She reasons that there could be anything from one long loop to n separate loops. Let Xn (where n > 1) be a random variable whose value r (where 1 6 r 6 n) is the number of loops that result when the 2n ends of n wires are joined in pairs. Note the special case, P(X1 = 1) = 1. Write down a difference equation which expresses P(Xn = r) in terms of P(Xn−1 = r − 1) and P(Xn−1 = r) given 1 < r < n and (in consequence) n > 3. [8 marks] Write down the difference equations for the special cases P(Xn = 1) and P(Xn = n). These equations should hold for n > 2. [4 marks] Hence or otherwise, tabulate the distributions of the random variables X1, X2 and X3 expressing all values as fractions. [5 marks] What is the Expectation E(X3), again expressed as a fraction? [3 marks] 5 [TURN OVER CST.2002.2.6 5 Probability An engineer has been monitoring the performance of two communication channels and has established that, on average, channel A sustains λA faults each month and channel B sustains λB faults each month. In each case a Poisson distribution may be assumed. It may also be assumed that the channels are independent. (a) Let X and Y be random variables whose values, r and s, are the numbers of faults each month on channel A and channel B respectively. Show that the derived random variable X + Y is also Poisson distributed and determine the associated parameter. [6 marks] (b) Let n = r + s, the total number of faults in a given month. For given n, the engineer notes that any number from 0 to all n faults may be attributable to channel A and assumes that this number is Binomially distributed. Explain, informally, why this is a reasonable assumption. [4 marks] (c) Noting the result of part (a), derive the parameters of the Binomial distribution which governs the random variable X given that the total number of faults is n. [8 marks] (d) Supposing that λA = 4 and λB = 6, what is the expected number of faults attributable to channel A if, one month, 5 faults were recorded in total? (a) Characterise and distinguish between consequentialist ethical theories and deontological ethical theories. Give one example of each. [4 marks] (b) The first section of the new British Computer Society Code of Conduct sets out for BCS professionals six standards of how they should conduct themselves with respect to The Public Interest. State four of these standards. [4 marks] (c) Computer security is as much a matter of institutional safeguards as it is of technical safeguards.

answer every question

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

Concepts Of Programming Languages

Authors: Robert W. Sebesta

10th Edition

0131395319, 978-0131395312

More Books

Students also viewed these Computer Network questions

Question

What is Accounting?

Answered: 1 week ago

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Why are stocks usually more risky than bonds?

Answered: 1 week ago

Question

Describe three problems with Adas exception handling.

Answered: 1 week ago