This assignment is a mix of programming concepts and data structures. It includes questions on recursion, loops, functions, arrays, linked lists, stacks, queues, trees, and more.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
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: 1 The number is: 2 b.The number is: 1 The number is: 2 The number is: 3 c.The number is: 0 The number is:1 The number is:2 d.The number is:3 The number is: 2 The number is:1 18.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); } }
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
int main() { int i = 0; numberFunction(i); return 0; } a.0 b.9 c.1 d.10 19.Look back at the code in Question 18. How many times is NumberFuncition called in the main program? a.1 b.10 c.2 d.0 20.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); } }
int main() { int i = 11; numberFunction(i); return 0; } a.The number is: 11 b.The number is: 12 c.The number is: 0 d.There would be no output because 11 > 10. 21.What does this constructor do? Graph() a.returns the number of nodes in a Graph image b.Creates an empty Graph object c.Creates a BasicGraph template d.Creates a svg image 22.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 code bool isEmpty() const; "bool" indicates that isEmpty ____.
a.can only return 0 b.can only return a value of true or false c.can return any integer between -8 and 8 d.can return any type of data 25.Graph r has 4 nodes and 3 arcs. int size = r.size(); would set "size" to a.1, because 4-3=1 b.7, because 3+4 = 7 c.3 d.4 26.For questions 26-29 look at this bit of code: struct animal { int legs; string genus; bool cute; } cat, dog, mouse ; Which of the following declarations would NOT be legitimate? (Scientific accuracy isn't an issue.) a.mouse.cute = yes; b.cat.legs = 10; c.They are all legitimate. d.dog.genus= "canine"; 27.Look back at question 26, same question, Which of the following declarations would NOT be legitimate. (Scientific accuracy isn't an issue.) a.mouse.cute = true; b.mouse.genus = "rodentia"; c.cat.family = "feline"; d.dog.legs=4; 28.Look back at the code in Question 26 again. What would the following bit of code do? animal lizard; a.Create a variable of type int named animal;
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
b.Create a function named lizard. c.Create a structure of type lizard named animal. d.Create a structure of type animal named lizard. 29.One more time, look back at question 26, well, and question 13 also. Which would NOT be a member of "lizard"? a.lizard.animal b.They would all be members of "lizard". c.lizard.cute d.lizard.legs 30.(class Edge) The following bit of code Edge long1(vxa, vxa); would: a.Create an edge between vertexes vxa and vxb b.Return the values of vxa and vxb c.Return the length of long1 d.Create two edges, one starting at vxa, the other at vxb, both ending at the default vertex 31.For help with questions 31 and 32, look at the file "main - Copy.lua" Assume the same values unless otherwise stated. The following bit of code local bkg = display.newImage( "night_sky.png", halfW, halfH ) would: a.use a file called "night_sky.png" and center it as the background. b.draw a night sky using the function "night_sky". c.use half of the image "night_sky.png" as the background d.have the file "night_sky.png" appear after the game ends 32.This bit of code if (score >=0) then if (score < 500) then score = score +20 would a.add 20 points to "score" if it is less than 0 b.only change the value of "score" it is 0 c.add 20 points to "score" if "score" is over 500.
d.add 20 points to "score" if the game is still in play. 33.What doArrays, Linked Lists, Stack and Queues have in common? a.They are linear data structures. b.They are hierarchical data structures. c. Trick question, they have nothing in common at all. d. They have nothing in common other than the are data structures. 34.How are TreesunlikeArrays, Linked Lists, Stack and Queues? a.Trees cannot be defined by theprogrammer. b. Trees can be used to manipulate data. c. Trees are hierarchical data structures d. Trick question, a tree is just a type of stack. 35. The code below would help create a tree with which kindof data? structnode { chardata; structnode *left; structnode *right; }; a.a word with 8 characters or fewer b.only the values "true" or "false" c.pointers d.a single letter