CSIT Quiz 8 Exam Questions with Correct Answers
CSIT Quiz 8 Exam Questions with Correct Answers What is recursion? - Answer-a well-known programming technique where a method calls itself How can repetition be implemented with recursion? - Answer-by calling, from within itself, the method containing an instruction wished to be repeated When writing methods where repetition is implemented through recursion, what control structure would most likely be used? - Answer-If Any method which implements repetition through recursion is most concerned with ____________. - Answer-a tested condition which signals the recursion to end What is the smallest problem solved by recursion most commonly known as? - Answerbase case What phrase describes the action of the method calls after the base case has been reached in the recursion process? - Answer-"the solution of the base case is passed up the line" The collective goal of recursion typically is to ___________. - Answer-solve an entire problem A penguin is 3 meters away from a kangaroo. The following method, foo, is written. When the world starts, " first method" is called, which is empty. How far does the penguin move when the world is run? - Answer-0 meters - the penguin does not move A penguin is 3 meters away from a kangaroo. The following methods are written. How far does the penguin travel? - Answer-2 meters A penguin is 3 meters away from a kangaroo. The following methods are written. How far away from each other are the penguin and the kangaroo after the following code is run? - Answer-1 meter A penguin is 3 meters away from a kangaroo. The following methods are written. How many times will the "foo" method be called when the following code is run? - Answer-2 times A penguin is 3 meters away from a kangaroo. The following methods are written. How many methods are called as a result of the event "when the world starts"? - Answer-7 methods A penguin is 3 meters away from a kangaroo. The following methods are written. How many times is the "turn to face" method called when the following program is run? - Answer-2 times In the following code, what control structure contains the recursive call? - Answer-If/Else A penguin is 4 meters away from a kangaroo. The following methods are written. How far does the penguin walk when the following code is run? - Answer-the code is an infinite loop A penguin is 2 meters away from a kangaroo. The following methods are written. How far does the penguin walk when the following code is run? - Answer-the code is an infinite loop A penguin and kangaroo are standing in the same place. The following methods are written. How far does the penguin walk when the following code is run? - Answer-the code is an infinite loop Do the following pieces of code achieve the same functionality, no matter where the penguin and kangaroo are initially position when the world starts? - Answer-No Which of the following choices describes all states in which the following code would result in an infinite loop? - Answer-if the penguin and kangaroo are initially separated by less than 5.5 meters Which of the following choices describes all states in which the following code would result in an infinite loop? Turn right 0.5 revolutions - Answer-none of the above Initially, the penguin is 4 meters away from the kangaroo. Will a recursive call be made when the following code is run? - Answer-Yes Initially, the penguin is 2.5 meters away from the kangaroo. How far will the penguin move when the following code is run? - Answer-1.5 meters Initially, the penguin is 3.5 meters away from the kangaroo. How many times will the method "" be called when the following code is run? - Answer-1 time What is the result of the following code? - Answer-the penguin and chicken swap places with each other For the function call below, what number is returned by the function "mystery"? n=1 - Answer-1 Initially, the penguin is 2.5 meters away from the kangaroo. How many times will the method "" be called when the following code is run? - Answer-4.5 meters For the function call below, what number is returned by the function "mystery"? n=2 - Answer-5 In this code, the function "bar" recursively calls itself. When the code is run, the penguin walks _____________. - Answer-0 mete
Written for
- Institution
- CSIT
- Course
- CSIT
Document information
- Uploaded on
- April 9, 2024
- Number of pages
- 5
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
csit quiz 8 exam questions with correct answe
-
csit quiz 8 exam questions with correct answers
Also available in package deal