logo

Understanding Recursion and Data Structures

   

Added on  2019-09-25

6 Pages1265 Words171 Views
 | 
 | 
 | 
16. What is recursion?a. It's when a function outputs a pointer.b. It's when a function calls itself.c. It's when a function calls another function.d. It's when a function outputs a null value.17. What would the output for this loop be?for(int i=1; i<3; i++) { cout << "The number is: " << i << endl;}a.The number is: 1The number is: 2b.The number is: 1The number is: 2The number is: 3c.The number is: 0The number is:1The number is:2d.The number is:3The number is: 2The number is:118. Look at the following code. (Note the numbers are not the same as in question 17)How many times will the function "numberFunction" call itself from within itself?#include <iostream>using namespace std;void numberFunction(int i) { cout << "The number is: " << i << endl; i++; if(i<10) { numberFunction(i); }}
Understanding Recursion and Data Structures_1

int main() {int i = 0;numberFunction(i);return 0;}a.0b.9c.1d.1019. Look back at the code in Question 18.How many times is NumberFuncition called in the main program?a.1b.10c.2d.020. Here is some code similar to the code in Question 18. But the value of initial value of i is set to 11 instead of 0.What would be the output of this program?#include <iostream>using namespace std;void numberFunction(int i) { cout << "The number is: " << i << endl; i++; if(i<10) { numberFunction(i); }}
Understanding Recursion and Data Structures_2

int main() {int i = 11;numberFunction(i);return 0;}a.The number is: 11b.The number is: 12c.The number is: 0d.There would be no output because 11 > 10.21. What does this constructor do?Graph()a.returns the number of nodes in a Graph imageb.Creates an empty Graph objectc.Creates a BasicGraph templated.Creates a svg image22.What does this code do?Graph<NodeType,ArcType> h;a. Creates an empty Graph object named h.b. Creates a default Graph object named h, with 3 nodes and 3 arcs.c. Returns the number of nodes in h.d. Returns a null value if h is empty.23.What is an important difference between the BasicGraph and Graph classes?a. The edge type has been preset to "bubble".b. The vertex type has been preset to "point".c. You do not need to supply the vertex and edge types.d. Trick question, there is no important difference between the two.24.In this bit of codebool isEmpty() const;"bool" indicates that isEmpty ____.
Understanding Recursion and Data Structures_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Simulation Analysis of Packet Delivery Probability
|7
|764
|10

new features of this C++ programming
|12
|1032
|16

OOPS Concepts: C++
|10
|1216
|314

ROBOTICS C++. 1. Robotics C++ Name of Student Instituti
|5
|482
|24

Designing a Queue Management System
|10
|2062
|432

Fundamentals of Programming
|9
|1287
|62