Answers must be written in capital letter and put in answer box (in front of eac
ID: 3840335 • Letter: A
Question
Answers must be written in capital letter and put in answer box (in front of each question). ___ If there is no base case coded in a recursive program, the program will a) execute until all conditions match b) not be executed c) run infinitely d) execute until crush occurred ___ Which of the following is characteristics of greedy algorithms definition? a) make a sequence of choices b) each choice is the one that seems best so far, only depends on what's been done so far d) choice produces a smaller problem to be solved d) All of the above ___ Which of the following is not the component of data structure? a) Algorithms b) Storage Structures c) Operations d) None of above Find the output of the following code segment public class test {public static void main(String[]ags) System.out.println(fun(5)); public static int fun(int n){if (n == 0) return 1; else return n + fun(n/2);}}} a) 9 b) 6 c) 7 d) 8 ___ Dynamic programming approach can break down an original problem into number of ___.Explanation / Answer
1 . c . The base case is used to terminate a recursive program. It consists of a return statement and returns value to the built up stack of function call to the same function.
2. d .At each step you have to make a choice to get to the optimum solution.
3. a . Data structure as representations of Data. Data Structures are components of Algorithms not the other way round.
4. a. function stack looks like following.
func(5) -> func(2) -> func(1) -> func(0)
5 + 2 + 1 + 1 (base case)
Final Value is 9.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.