Analyze the time complexity of the following segments
Program:
sum1=0;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
sum1++
sum2=0;
for(i=1;i<=n;i++)
for(j=1;j<=i;j++)
sum2++
Write down the Boolean Table AND the Boolean Expression that models
the circuit that engineers two light switches A and B at the two EXITS
of a huge conference center. The specifications are as follows:
(a)Both light switches operate the one common light in the room.
(b) The light is off when both switches A and B are OFF. That would
mean that A = B = 0 implies the light is OFF = 0.
(c) Flipping either switch will turn the light ON = 1.
(d) Following (c) flipping either switch will turn the light OFF = 0.
(e) We can go back and forth between (c) and (d). Flipping either
switch A or B will turn the light OFF = 0 if it is ON = 1 and ON = 1
if it is OFF = 0
Find an optimal solution for the knapsack instance n (number of objects) =7 and
W ( totalweight) =15. Profits and weights of each object are shown below:
(p1, p2………..p7) = (10, 5, 15, 7, 6, 18, 3)
(w1, w2………w7) = (2, 3, 5, 7, 6, 4, 1)
Show all the steps.
Consider Following list of elements, Show arrangement of elements until four numbers of iterations
while applying Selection, Insertion, and Bubble Sort Algorithms.
2, 6, 1, 8, 9, 7, 10, 24
Solve the following time complexity
T(n) = ∑ ∑ 1
𝑖
𝑗=0
𝑛−1
𝑖=1
b. Write an algorithm/pseudocode for a movie rental company that wants to screen their customers from 18years and above. The system should be able to deny access to customers that appear below 18. (8pts)
c. Draw a Flowchart to illustrate the above program.
b. Write an algorithm to determine the average of any six (5) numbers and display the below after: The sum, the product and the average.
c. Describe what is a variable and how is it used in a program.
b. Write an algorithm/pseudocode for a movie rental company that wants to screen their customers from 18years and above. The system should be able to deny access to customers that appear below 18. (8pts)
c. Draw a Flowchart to illustrate the above program
If you want to handle 30 interrupts, how many 8259A PIC will you need?
Assume variables A, B, C, D, and E are stored in memory locations 100, 101, 102, 103, and 104, respectively. Using any of the sample machine language instructions given in this section, translate the following pseudocode operations into machine language instruction sequences. Have your instruction sequences begin in memory location 50:
(a) Set A to the value of (B x C) – (D x E) (that is A = BC - DE). You can use a MULTIPLY and SUBTRACT command for the multiplication and subtraction, respectively.
(b) Set A to the value of (B + C) – D/E (that is A = B + C – D/E). You can use an ADD and DIVIDE command for the addition and division, respectively.