In: Computer Science
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; }
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>