Question

In: Computer Science

1) Given the list of integers 1, -2, 3, -6, 7, -8, 9, 10, -11, indexed...

1) Given the list of integers 1, -2, 3, -6, 7, -8, 9, 10, -11, indexed from 1 to 9, the left-to-right linear scan algorithm (O(n) algorithm) will set as candidate start positions for a maximum contiguous sequence the elements at the index positions:

(a) 1,3,4,6

(b) 1,3,4,6,9

(c) 1,3,5,7

(d) none of the above

2)The Fibonacci sequence 1,1,2,3, ... can be generated iteratively by starting with the first two (0th and 1st) and generating every subsequent one by adding the previous two. In fact, the nth Fibonacci number can be generated by n − 1 additions for n ≥ 2. Thus we need 5 additions to generate the 6th Fibonacci number. However, a recursive program to generate the 6th Fibonacci number needs:

(a) 12 additions (b) 11 additions (c) 10 additions (d) None of the above

3)we can use a stack to check if a string made up of open, “(”, and closed, “)”, parentheses is balanced. Simulate this algorithm on the input string “((()))(())()” to determine if it is balanced or not. (this means you must explicitly write down the sequence of pushes and pops that the algorithm would generate

Solutions

Expert Solution

PLEASE FIND THE ANSWERS BELOW.

In the third problem, we got an EMPTY Stack in the end.

Hence, the input string is accepted.!!


Related Solutions

3 6 4 8 1 10 2 9 11 12 15 22 3 6 7 5...
3 6 4 8 1 10 2 9 11 12 15 22 3 6 7 5 8 1 12 14 Each column represents a different treatment given to sick rats. Each cell is a different rat. Use statistical analysis and use post hoc testing using contrasts to find the best treatment. Treatment 1: vitamins Treatment 2: prescription pills Treatment 3: brain surgery Treatment 4: shock therapy Treatment 5: dietary changes
Match No. 1 2 3 4 5 6 7 8 9 10 11 12 13 14...
Match No. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Player A 8 42 56 68 91 123 12 46 57 137 5 80 14 10 19 Player B 38 44 46 59 57 61 48 42 51 39 58 41 55 45 68 1. For the given data set representing the runs scored by two players in last 15 matches, conduct the following analysis: i. Which average you will use to summarize...
Period   0 1 2 3 4 5 6 7 8 9 10 11 PBP NPV IRR...
Period   0 1 2 3 4 5 6 7 8 9 10 11 PBP NPV IRR Project A $                       (1,000,000) $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 400,000 Project B $                       (1,000,000) $ 500,000 $ 500,000 $ 500,000 Project C $                             (80,000) $      1,040 $      9,456 $    11,405 $    18,567 $    47,453 $      6,394 $    45,727 $    51,933 $    85,625 Project D $                           (400,000) $      4,161...
Input Data Month 0 1 2 3 4 5 6 7 8 9 10 11 12...
Input Data Month 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Revenue $             -   $            -   $            -   $        -   $        -   $         -   $    2,500 $    2,875 $    3,306 $    3,802 $    4,373 $    5,028 $    5,783 $    6,650 $    7,648 $      8,795 $   10,114 $   11,631 $   13,376 $   15,382 $   17,689 $   20,343 $   23,394 $   26,903 Monthly Revenue Growth...
Input Data Month 0 1 2 3 4 5 6 7 8 9 10 11 12...
Input Data Month 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Revenue $             -   $            -   $            -   $        -   $        -   $         -   $    2,500 $    2,875 $    3,306 $    3,802 $    4,373 $    5,028 $    5,783 $    6,650 $    7,648 $      8,795 $   10,114 $   11,631 $   13,376 $   15,382 $   17,689 $   20,343 $   23,394 $   26,903 Monthly Revenue Growth...
Post Position 1 2 3 4 5 6 7 8 9 10 Wins 19 14 11...
Post Position 1 2 3 4 5 6 7 8 9 10 Wins 19 14 11 15 15 7 8 12 5 11 The table below lists the frequency of wins for different post positions in the Kentucky Derby horse race. Use a 0.05 significance level to test the claim that the likelihood of winning is the same for the different post positions. What is the critical value (the X2 value)? [Round to the nearest thousandths place]
Period   0 1 2 3 4 5 6 7 8 9 10 11 PBP NPV IRR...
Period   0 1 2 3 4 5 6 7 8 9 10 11 PBP NPV IRR Project A $                       (1,000,000) $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 200,000 $ 400,000 Project B $                       (1,000,000) $ 500,000 $ 500,000 $ 500,000 Project C $                             (80,000) $      1,040 $      9,456 $    11,405 $    18,567 $    47,453 $      6,394 $    45,727 $    51,933 $    85,625 Project D $                           (400,000) $      4,161...
Day 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15...
Day 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Number of Aides Absent 5 8 11 15 4 2 7 1 4 6 14 19 3 5 8 In which of the following ranges you can find the Upper Control Limit of the control chart? 0.1427 0.1536 0.1677 Not computable with information available In which of the following ranges you can find the Lower Control Limit of the control chart? Does not exit...
student 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15...
student 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Test score 67 67 87 89 87 77 73 74 68 72 58 98 98 70 77 Above we have the final averages of the last stats and I want to know if the class average falls within the boundaries of all my statistics classes for the past 20 years. Find the sample size, mean, and standard deviation of the data above (Table 1)....
Company ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14...
Company ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 5330 6352 6340 3399 6566 7376 6882 1842 7362 8205 6222 7695 1681 2283 2 7972 5941 2861 3290 1019 7399 6442 8003 5092 4634 7569 2538 2619 7932 3 8545 6667 2121 2339 4770 7296 3215 7919 2176 9129 1321 695 7945 1673 4 4578 466 4142 8350 7439 6085 8381 5872 2703 6974 702 5846 7176 9179 5 7302 2727 3103...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT