Question

In: Computer Science

Given the following program below answer the following questions. 1.Draw a program flow graph for the...

Given the following program below answer the following questions.

1.Draw a program flow graph for the binsearch() function
2. Find the Define and Usage node, du-paths and dc-paths for all the variables

int binsearch(int x,int v[],int n)
{
    int low,high,mid;

    low=0;
    high=n-1;

    while(low<high)
    {
        mid = ( low + high ) / 2;

        if( x < v[mid])
            high  = mid - 1;
        else if ( x > v[mid])
            low = mid + 1;
        else
            return mid;
    }
    return -1;
}

Solutions

Expert Solution

Flowgraph:All the usage node are efine in above flow graph and usage node are N1,N2,N3,N4,N5,N6,N7,N8

du-paths and dc-paths for all the variables

du-paths and dc-paths for Low variable

du-paths= <1, 2,4>

dc-paths=<1,2,4,6,7>

du-paths and dc-paths for mid variable

du-paths= <1, 2,4, 6>

dc-paths=<1,2,4,6,7,8>

du-paths and dc-paths for high variable

du-paths= <1, 2,3>

dc-paths=<1,2,4,5>


Related Solutions

Answer the following questions and draw the cash flow diagrams for each:
Answer the following questions and draw the cash flow diagrams for each: (a) What are the equivalent annual payments over a 15-year period for a present value of $14,500 and a compound interest rate of 6% per year. (b) What are the annual equivalent payments for a present value of $445,000 in perpetuity and a compound interest rate of 6% per year.  (c) What is the present worth of $15,000/year for 30 years at a compound interest rate of 6% per year?
Draw a graph having the given properties stated below, or explain why no such graph exists:...
Draw a graph having the given properties stated below, or explain why no such graph exists: In each case assume simple graphs (no self loops and no parallel edges) a. Six vertices each with degree 3 b. Five vertices each with degree 3. c. Four vertices each with degree 1. d. Six vertices and four edges. e. Four edges; four vertices having degrees 1, 2, 3, and 4.
Create a separate file to answer the following questions and then submit it below. Draw the...
Create a separate file to answer the following questions and then submit it below. Draw the complete graph for each question. a. Draw a graph of the market for jalapeno peppers. Be sure to label everything. b. Draw a new graph that shows what changes would occur to your graph in part ‘a’ if there was bad weather and the jalapeno pepper crop was severely damaged. Explain why you made these changes to the graph. c. Redraw the graph you...
1.) Use the given information below to answer the following questions. a.) A sample of 25...
1.) Use the given information below to answer the following questions. a.) A sample of 25 lightbulbs was taken and it was found that the mean lifetime of a certain bulb for a movie projector is 520 hours with a standard deviation of 50 hours. The standing assumption of the manufacturing company is that the lifetime of this type pf bulb is no more than 500 hours. Assume a normal distribution. Does the data support the company’s claim at a...
Please answer the following questions based on the given graph YEAR Year Number Domestic 1997 1...
Please answer the following questions based on the given graph YEAR Year Number Domestic 1997 1 3210113 1998 2 3294244 1999 3 3150826 2000 4 3244421 2001 5 3358399 2002 6 3289148 2003 7 3326111 2004 8 3423024 2005 9 3772952 2006 10 4349081 2007 11 4937099 2008 12 5106860 2009 13 4704189 (1) Create a Time Series (Trend)Model  for  passengers on Domestic flights. (To zero decimal places) The predicted amount of passengers for 2010 on Domestic flights is ________. (2) Create...
) Given the true statements as below, answer the following questions: (a) If Joe is not...
) Given the true statements as below, answer the following questions: (a) If Joe is not a French major and he is not happy, then he doesn’t like to travel. (b) The statement “If Joe knows Discrete Math or he is a CS major, then he is either happy or a CS major.” is false . (c) If Joe is a Math major, then he does not know Discrete Math. (d) If Joe is not a CS major, then he...
QUESTION 1 Study the information given below and answer each of the following questions independently: •          ...
QUESTION 1 Study the information given below and answer each of the following questions independently: •           Calculate the margin of safety (as a percentage). •           Calculate the number of units that must be sold if the company desires an operating profit of $1 350 000. •           Suppose the company wants to spend $120 000 more on advertising and reduce the selling price by $4 per unit, with the expectation that the sales volume will increase by 20%. Is this a...
Questions in Graph Theory: In the subject of the degree sequence of graph, answer the following:...
Questions in Graph Theory: In the subject of the degree sequence of graph, answer the following: When does a d-regular graph have an Eulerian trail? and When does it have an Eulerian circuit? Note: a d-regular graph is one with degree sequence (d, d, d, . . . , d) for example. Can a tree be a regular graph? Why or why not
QUESTION 1 (20 Marks) REQUIRED In view of the information given below, answer the following questions:...
QUESTION 1 REQUIRED In view of the information given below, answer the following questions: 1.1 Explain THREE (3) costs or risks to businesses of holding little or no cash. 1.2 Explain THREE (3) motives for holding cash. 1.3 What advice would you offer financial managers to ensure the effective of cash?
3.2 Discounted Cash Flow For the project below, please answer the following questions: (a) What are...
3.2 Discounted Cash Flow For the project below, please answer the following questions: (a) What are the NPVs for 11%, 13% and 15% respectively? (b) Based on your results above; what is the approximate IRR (and why)? (c) Calculate the exact IRR with Excel (to 1 decimal place) Year (n) 0 1 2 3 4 Undiscounted cash flow -$600,000 $200,000 $200,000 $200,000 $200,000 DCF @ 11% ∑DCF @11% DCF @ 13% ∑DCF @13% DCF @ 15% ∑DCF @15% Notes: DCF...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT