PLEASE ANSWER ALL 4 QUESTIONS CORRECTLY 1) A(n) ________________ connects two no
ID: 3581220 • Letter: P
Question
PLEASE ANSWER ALL 4 QUESTIONS CORRECTLY
1) A(n) ________________ connects two nodes in a graph.
A) object
B) linkage
C) edge
D) node
2) A queue should not be built with an array. A circular array would be a better implementation choice for this data structure.
A) True
B) False
3) Consider the following function. The line numbers are indicated on the left side for reference only and are not part of the code.
1 float p( float x, int n )
2 {
3 if ( n == 0 )
4 return 1;
5 else
6 return x * p( x, n – 1 );
7 }
The recursive case is shown on:
A) line 1
B) lines 3-6
C) lines 3-4
D) lines 5-6
4) Consider the following function:
void test_a(int n)
{
cout << n << " ";
if (n>0)
test_a(n-2);
}
Which function call will result in the output: 4 2 0
A) test_a(4);
B) test_a(2);
C) test_a(0);
Explanation / Answer
1) C
Edge is used to connect two nodes.
2) A
Circular arrays are better for implementing queues because, If we remove an element just we need to increase the pointer where as in regular arrays, we need to rearrange the elements.
3) D
If a function calls it self, it is called as recursion.
4) A
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.