Question

In: Computer Science

Identify the define node, usage node, du-paths and dc-paths for all the variables. int binsearch(int x,int...

Identify the define node, 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

  • Node: A node is a point, like a center or linking point, at which lines or paths converge or branch.
    • In this Program node Usage as follows: |_Low_|---> |_Mid_|--> |_High_|
  • Du-paths: A definition-use path with respect to a variable v (denoted du-path) is a path in the set of all paths in P, PATHS(P), such that for some v ∈ V, there are define and usage nodes DEF(v, m) and USE(v, n) such that m and n are the initial and final nodes of the path.
    • Du-Paths in this program are int x, int v[], and int n.
    • Low Mid High( V, X ) and Usage Nodes: Low Mid High( V, N).
  • Dc-paths: A definition-clear path with respect to a variable v (denoted dc-path) is a definition-use path in PATHS(P) with initial and final nodes DEF (v, m) and USE (v, n) such that no other node in the path is a defining node of v.
    • A du-path with no other defining node for v is a definition-clear path.
    • .

Related Solutions

Question 1 ) Briefly define binary variables and discuss the purpose of their usage in mathematical...
Question 1 ) Briefly define binary variables and discuss the purpose of their usage in mathematical models. Question 2 ) Discuss the importance of mathematical modeling in business problems and point out the limitations of linear programming in modeling actual business
Write a Java program to move data among variables: (1) define 4 int variable pos1, pos2,...
Write a Java program to move data among variables: (1) define 4 int variable pos1, pos2, pos3, pos4, input 4 integer numbers from console and assign them to these variables; display message in the following format: “pos1=a-number; pos2=a-number; pos3=a-number; pos4=a-number”. “anumber” is replaced with real number. (2) Left shift data in these variables: for each variable to get the value of the successive variable, with pos4 getting pos1's value. Display pos1, pos2, pos3, and pos4 (3) Right shift data in...
Let X and Y be independent Gaussian(0,1) random variables. Define the random variables R and Θ,...
Let X and Y be independent Gaussian(0,1) random variables. Define the random variables R and Θ, by R2=X2+Y2,Θ = tan−1(Y/X).You can think of X and Y as the real and the imaginary part of a signal. Similarly, R2 is its power, Θ is the phase, and R is the magnitude of that signal. (b) Find the probability density functions of R and Θ. Are R and Θ independent random variables?
Explain what is Poisson’s ratio, and define all the variables in the definition. What is the...
Explain what is Poisson’s ratio, and define all the variables in the definition. What is the maximal (minimal) value of the Poisson’s ratio? Does the volume change in compression and expansion depend on the Poisson’s ratio (explain why and how)?
Write the equilibrium equations, identify the equilibrium variables such as x +/- y, and calculate the...
Write the equilibrium equations, identify the equilibrium variables such as x +/- y, and calculate the pH of a 0.600 liter solution made up as 1.14 M diprotic base B(aq). Kb1=6.87x10^-6; Kb2=7.15x10^-8
Explain the theory of labor supply and define all the important assumptions, functions, and variables that...
Explain the theory of labor supply and define all the important assumptions, functions, and variables that are important for the theory. Use a graph to describe the optimal choice. What determines the numbers of hours worked or whether a worker enters the labor force at all? How would you expect the work behavior of lottery winners to change based on the theory of labor supply? Describe/Illustrate changes in the graph.
2 .Define the probability density functions (pdfs) of the independent random variables X and Y as:...
2 .Define the probability density functions (pdfs) of the independent random variables X and Y as: fX(x)={ (1/5).(1-(x/10)), 0≤x≤10 fY(y)={ (1/5).(y/10) , 0≤y≤10 0 , otherwise for both fX(x) and fY(y) (a) Suppose that you are playing a game where you want to maximize your number of points , and you can have your score be X or Y . Which would you choose? (b) Suppose I am confused in part (a), so I flip an unfair coin, with P...
Problems create a C++ program that will do the followings - define 3 double variables x,...
Problems create a C++ program that will do the followings - define 3 double variables x, y, z - calculate the value of y as the following formula: y = 2*x*x+4*x+5 and print x and y; - assign a new value to x: x=5.6 - calculate the value of z as the following formula z = (y*y)/4 + (x*x)/5 - print x, y,x
Define d to be the set of all pairs (x,y) of natural numbers such that x...
Define d to be the set of all pairs (x,y) of natural numbers such that x divides y. Show that N is partially ordered by d. Define d analogously on Z. Is then d also a partial order on Z?
Define and defend all variables, including the dependent variable, in a single paragraph for each variable....
Define and defend all variables, including the dependent variable, in a single paragraph for each variable. Also, state the expectations for each independent variable. These paragraphs should be in numerical order, i.e., dependent variable, X1, then X2, etc. Dependent Variable: Players Annual Pay Independent Variables: Batting average, Stolen bases, Home Runs, and RBIs. In each paragraph, the following should be addressed: How is the variable defined in the data source? Which unit of measurement is used? For the independent variables:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT