Question
Question1 if possible, could anyone do with explanation For each of the following code snippets, give both of the following: a. Give the overall T(n)
Question1
if possible, could anyone do with explanation For each of the following code snippets, give both of the following: a. Give the overall T(n) run me analysis expression for the code. b. Describe the worst case running me of the code snippet in BigOh notation.
1.for (int i=0;i { for (int j=0;j { sum++;} } 2.void silly(int n,int x,int y) { for (int i=0;i { if (x { for (int j=0;j<100*n*n;j++) { cout<< "j="< else {cout <<"i="< 3.void silly(int n,int m) { if (n<1) { return ;} if (n { silly(n/2,m+1); } else { silly (n/2, m); }} 4.for (int i=0;i<3*n;i++) { sum++; } for (int i=1;i { for (int j=0;j { sum++; }}} 5. for (int i=0;i { for (int j=0;j { sum++;}} Question 2 Given the following list of values, perform a binary search for the indicated search item. Show the values of rst, last and middle, and the number of comparisons made after each iteration of the loop. Your should create a table like the following to show your work, where rst and last are the values of the variables at the beginning of the loop, and mid is the midpoint used during that iteration, list[mid] is the value in the list at the midpoint, and No. of key comparisons should be the number of comparisons made during this iteration by the algorithm: Iteration first last mid list[mid] no of key comparisons 1 0 12 ? ? ? list [7,9,9,9,10,12,19,20,22,28,28,29,29] Searching for value:22
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started