Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
The function f is defined for non-negative integers a and b recursively as follows:
f(a, b) ={
0 if a = 0 or b = 0
f(a − 1, b − 1) + 2a − 1 if a = b
f(a − b, b) + f(b, b) if a > b
f(a, a) + f(b − a, a) if a < b
}
Compute f (3, 2) by drawing a recursion tree showing all of the computation
required and then use your tree to compute the answer.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
Knowledge Booster
Similar questions
- 6) If L is RE but not recursive, then its complement cannot be RE (true or false).arrow_forwardAssume the following scoring matrix. A T C G - A 1 -1 -1 -2 -1 T 1 -1 -1 -1 C 2 -1 -1 G 1 -1 Fill out the dynamic programming table for the global alignment between sequences v = TAGCTCCG and w = GCATCCA using the scoring matrix above. Use the following recursive scoring formula. w= G C A T C C A 0 1 2 3 4 5 6 7 v= 0 T 1 A 2 G 3 C 4 T 5 C 6 C 7 G 8 What is the score and global alignment between v and w?arrow_forwardIn C programming Mathematically, given a function f, we recursively define fk(n) as follows: if k = 1, f1(n) = f(n). Otherwise, for k > 1, fk(n) = f(fk-1(n)). Assume that there is an existing function f, which takes in a single integer and returns an integer. Write a recursive function fcomp, which takes in both n and k (k > 0), and returns fk(n). int f(int n);int fcomp(int n, int k){arrow_forward
- 8- Determine if each of the following recursive definition is a valid recursive definition of a function f from a set of non-negative integers. If f is well defined, find a formula for f(n) where n is non- negative and prove that your formula is valid. a. f(0) = 2,f(1) = 3, f(n) = f(n-1)-1 for n ≥ 2 b. f(0) = 1,f(1) = 2, f(n) = 2f (n-2) for n = 2arrow_forward= = 2×2 and 6 = (a) A composite number is a positive integer that has at least one divisor other than 1 and itself. For example, 2 1×2 is not a composite number but 4 2 × 3 are composite numbers. A logic circuit has four binary input variables, A, B, C and D. The output Z of the logic circuit is 1 if the unsigned integer represented by the binary number ABCD is a composite number. Using variables A and B for the select inputs S1 and S0 of a 4-to-1 multiplexer, implement the logic function Z(A, B, C, D) using this multiplexor and other logic gates.arrow_forwarda. Correctness of dynamic programming algorithm: Usually, a dynamic programming algorithm can be seen as a recursion and proof by induction is one of the easiest way to show its correctness. The structure of a proof by strong induction for one variable, say n, contains three parts. First, we define the Proposition P(n) that we want to prove for the variable n. Next, we show that the proposition holds for Base case(s), such as n = 0, 1, . . . etc. Finally, in the Inductive step, we assume that P(n) holds for any value of n strictly smaller than n' , then we prove that P(n') also holds. Use the proof by strong induction properly to show that the algorithm of the Knapsack problem above is correct. b. Bounded Knapsack Problem: Let us consider a similar problem, in which each item i has ci > 0 copies (ci is an integer). Thus, xi is no longer a binary value, but a non-negative integer at most equal to ci , 0 ≤ xi ≤ ci . Modify the dynamic programming algorithm seen at class for this…arrow_forward
- Let recursive algorithm F be defined as follows: F(int n):if n=1 then return 1else return F(n-1)*n (a) i. Assuming x is a positive integer, what mathematical expression is returned by F(x)?ii. Repeat (i) but assume the line “return 1” is replaced by “return 0”? (b) Which of the following replacements for the last line will yield a function guaranteed to terminate for all valid inputs? i. return F(n-2)+2ii. return F( )*2iii. return F( )*2arrow_forwardUsing recursion, write a Python function def before(k,A) which takes an integer k and an array A of integers as inputs and returns a new array consisting of all the integers in A which come before the last occurrence of k in A, in the same order they are in A. For example, if A is [1,2,3,6,7,2,3,4] then before(3,A) will return [1,2,3,6,7,2]. If k does not occur in A, the function should return None.arrow_forwardProgram #2 Define a sequence of numbers recursively Define a sequence ao, a1, az, a3, where ao = 1 an = (an -1+ 1) * 2 an = (2* an - 2+ an-1) ifn is even So for instance: (n = 0) ao = 1 (n = 1) ai = (ao + 1) *2 = (1+ 1) *2= 4 (n = 2) az = (2* ao + ao) = 2*1+4 = 6 (n = 3) az = (az + 1) *2 = (6 + 1) *2 =14 The resulting sequence is 1, 4, 6, 14, . if n is odd !3! %3D You will write a function that returs the nth term of the sequence. You must do this by using a recursive function. The function will NOT print out any values. Rather, the function will return the nth term of the sequence using a recursive algorithm. In the main part of the program: 1. Input the number of terms of the sequence to output. 2. In a for loop, call the function repeatedly to get the desired number of terms. The function will take i (assuming the for index is called i) as the argument and return the ith term of the sequence. 3. In the for loop, print out each term as it is returned. Figure out the necessary prompts…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY