Question

Java

1. Write a function that takes as input three variables a, b, and c and returns as output the solutions to the quadratic equation ax² + bx + c = 0. Test your function on a couple of examples.

2. Stability of an algorithm. Use your function from problem 1 to compute the roots of teh quadratic expression x - (10-° + 10°) x + 1. This equation can be factored as (x - 10-6) (x- 10°), so the roots are 10- and 10°. Is this what you see as the output of your function?

The difference between the actual solution and the computed solution that your function gives is caused by the fact that the arithmetic done by a computer is not exact. To overcome this issue, an alternate form of the quadratic equation can be written:

x=\frac{2 c}{-b \pm \sqrt{b^{2}-4 a c}}

= 0. Find the roots of our Write a function that solves a quadratic equation using this alternative form. Test the function on the quadratic equation x"problem" quadratic above.

3. An even better quadratic method. Even the method above is not optimal in finding the roots of a quadratic. Instead, you can compute the largest root by using the formula

Write a function that solves a quadratic equation using this alternative form. Test the function on the quadratic equation x2 – 1 = 0. Find the roots of our"problem" quadratic above.

3. An even better quadratic method. Even the method above is not optimal in finding the roots of a quadratic. Instead, you can compute the largest root by using the formula

x_{1}=\frac{-b-\operatorname{sign}(b) \sqrt{b^{2}-4 a c}}{2 a}

and then use the fact that x X2 = cla (where does this come from?). Here sign(b) is a function that returns -1 if b < 0 and 1 if b > 0. Type help sign for more information. Write a function that implements this method of solving the quadratic equation, and then test it on the quadratic quesitonx² – 2x + 1 = (x – 1)(x – 1) = 0. Now test it on x - 1 = 0, and explain the output. Finally, test it on oưt "problem quadratic" from problem 2.  Verified

### Question 33286  Java

3. Write behavioral code for up/down 2-bit binary counter (same as q2).Use state machine. Show the state machine diagram and implement code that reflects the state machine. Following is a template that you can use-

### Question 33285  Java

2. Write behavioral code for a 2-bit up/down counter. The counter should have synchronous reset. (State Machine is not needed)

### Question 33284  Java

1. Write behavioral Verilog code of 4-bit shift register with the functionalities: parallel load (select ==00), shift left (select ==01),shift right (select ==10), and no shift (select ==11). Consider serial input to be 0 in both shifts. Use two select line inputs. (State Machine is not needed)

### Question 28212  Java

Assuming a 1-KB page size, what are the page numbers and offsets for the following address references (provided as decimal numbers):
а. 3085
b. 42095
c. 215201
d. 650000

### Question 28211  Java

There exist 8 resources in the system. The current system state is as follows
Is this allocation safe, and if yes give one safe state and justify your answer?

### Question 28210  Java

The first known correct software solution to the critical-section problem for n processes with a lower bound on waiting of n -1 tums was presented by Eisenberg and McGuire. The processes share the following variables:
enumpstate idle, want_in, in_cs};
pstate flag[n];
int turn;
All the elements of flag are initially idle. The initial value of turn isimmaterial (between 0and n-1). The structure of process Piis shown in the following Figure. Prove that thealgorithm satisfies all three requirements forthe critical-section problem.

### Question 27578  Java

Consider the following weighted graph G on thirteen vertices:
Use either Kruskal's or Prim's algorithm to construct a minimum spanning tree for G. What is the weight of the minimum spanning tree?

### Question 27577  Java

Consider the following dependency graph:
Construct the component graph by identifying each of the strongly connected components (SCCS). Which of the following edges CAN be safely added to the dependency graph without reducing the number of strongly connected components?

### Question 27576  Java

What does it mean to say that an optimisation problem X is r-approximable, where r > 1?
Every polynomial-time approximate algorithm for X has an approximation ratio equal to r.greater than or
There is no exact algorithm for X that runs in polynomial-time.
There exists a polynomial-time algorithm for X than returns an approximate solution no worse than r times the global optimum.
These exists a polynomial-time algorithm for X than returns an optimal solution after at most r iterations.

### Question 27575  Java

Consider the following instance of the Travelling Salesman Problem:
Highlighted in bold is the following route of length62:
A → C → B → E → D → A
Using the 2-opt algorithm, which of the following modifications are valid swaps that can be made to the above route to obtain a shorter route?
Remove (A, D), (C, B)and Add(С, D), (A, B).
Remove (A, C'), (B, E)and Add(А, В), (С, Е)-
Remove (A, C'), (A, D)and add(C, D), (A, A).
Remove (A, D), (B, E)and add(А, В), (D, E).
Remove (A, D), (B,E)and add(А, E), (В, D).

### Submit query        