QUESTION 1 (10 Marks) A) Given the following recursive method definition, analyse the coding. static int leng (String st
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
QUESTION 1 (10 Marks) A) Given the following recursive method definition, analyse the coding. static int leng (String st
QUESTION 1 (10 Marks) A) Given the following recursive method definition, analyse the coding. static int leng (String str) i if (str == null || str. equals ("")) return 0 ; else return 1+ leng(str.substring (1); \} Show the tracing and the value returned from this method, if the following call is made. (4 marks) a) leng ("0") b) leng ("Ace") B) Given the following recursive definition for foo(n) where n is a non-negative integer. (6 marks) f∘o(n)=⎩⎨⎧23foo(n−1)+foo(n−2),n=1,n=2,n>=3 a) Write the definition of the recursive function foo(n) in JAVA. b) Trace and show the output for function foo(3). Show all steps taken
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!