Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE ANSWER ALL 3 QUESTIONS CORRECTLY 1) int mysteryFunction(vector vec, int l

ID: 3581203 • Letter: P

Question

PLEASE ANSWER ALL 3 QUESTIONS CORRECTLY

1) int mysteryFunction(vector vec, int low, int high, int key)
{
if ( low > high )
{
return -1;
}
int mid = (low + high)/2;
if ( vec[mid] == key )
return mid;
else if ( vec[mid] > key )
return mysteryFunction(vec, low, mid-1, key);
else
return mysteryFunction(vec, mid+1, high, key);
}
What is this an example of?

in-order traversal of a binary search tree

binary search tree insert function

binary search function

circular array pop function

2) Which of the following statements is true?

A) Graph vertices may be linked in any manner.

B) A graph can drawn on paper in only one way.

C) A graph must have at least one vertex.

D) A graph must have at least one edge.

3) Consider the following function. How would the output that is generated with the call test_a(4) be

different if the cout line were listed after the recursive call in this function?
void test_a(int n)
{
cout << n << " ";
if (n>0)
test_a(n-2);
}

A) The recursive call would never execute because the base case would be true immediately.

B) The integers would print in descending order instead of in ascending order.

C) There would be no difference in the output of this function.

D) The integers would print in ascending order instead of in descending order.

A)

in-order traversal of a binary search tree

B)

binary search tree insert function

C)

binary search function

D)

circular array pop function

Explanation / Answer

1)option C ,binary search function is the one where we search for a key by reducing the number of comparison elements after each iteration within an array.

2)option C,a graph must have at least one vertex

3)option B ,the integers would be printed in descending order instead of ascending...due to recursive calls and decrement of number by 2 upto 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote