Question: 1 Overview In this project, you will be practicing recursion. You will turn in two files. In annoying_recursion.py . you will write several recursive functions

 1 Overview In this project, you will be practicing recursion. You
will turn in two files. In annoying_recursion.py . you will write several
recursive functions - but you're going to write them in a very

1 Overview In this project, you will be practicing recursion. You will turn in two files. In annoying_recursion.py . you will write several recursive functions - but you're going to write them in a very strange form - the hannoying version! I'll describe the functions, and tell you exactly what I mean by annoying." later in this spec. In the second file, linked_list_recursion.py . you will write one function which is the replay of a function you wrote in a previous project - except that now, it will have to be recursive. Don't worry, though - this functions is not subject to the "annoying requirements! 1.1 Loops Banned In every function in this project (except for is_sorted(), where loops are re- quired) loops are banned! (You are allowed to use string/list multiplication, however.) 1.2 Helper Functions Banned In every function in this project - whether "annoying" or not. helper functions are banned. Every one of these functions can be completed with only a single, recursive function. (And you have to use exactly the parameters I require, or you won't pass the test cases.) Some of you may know about default arguments in Python (if not, that's OK) - these are banned as well! Default arguments are a cool feature - but they are basically just a way to write a helper function, so they aren't allowed in this project, either. 2 Make Recursion Annoying Again What's weird about the "annoying" functions? What's annoying is that you are going to have to implement lots of different cases for each one - and the various cases will have very specific limitations, For simplicity, every one of these functions will take exactly one integer ar ment, they will either print things to the screen or return something Everyone can be called with any nou-negative Integer (that is zero or mything positive And just to make clear that these are amoying functions that is you would never write them like this in the Real World!) the name of every one begins with annoying 2.1 1 Base Cases Every "annoying" function must have special cases for the values 0.1.2.3. For eacli of these values, you must implement it as a base case - that is simply return for print the answer - without any recursion at all. 2.2 3 Hard-Coded, but Recursive Cases Every "annoying" function must also have special cases for the values 4.5.6. These must be implemented recursively, but you must hard-code what you recursively enll. That is, don't ne the value 11 in those cases at all (except to figure out that you are in that case). So, for instance, the factorial function might include this snippet: if ne 5: return 5 * annoying_factorial (4) 2.3 The General-Purpose Case Finally, every "annoying function must have a general case. (This is what would be the body of the recursive in a more typical solution.) This general CES: Must not execute except for a > 7. (But it must work properly for all such large values!) Must recurse 3 annoying factorial(n) In annoying racursion.py write the function annoying factorial(n) which takes a single integer parameter (which must be non-negative). Il must return that is, 1.2.3.4...n It must obey the Annoying Requirements. REMEMBER: O! (that is, were factorial") is equal to 1. 4 annoying fibonacci(n) In annoying. recursion,py write the function annoying fibonacci(n) which takes a single integer parameter (which must be non-negative) It must return the Fibonacci Number (https://en.wikipedia.org/wiki/Fibonacci. number): The first two Fibonacci Numbers are fixed; Fo=0 F-1 and from then on, all Fibonacci Numbers are defined recursively: F -F-+ F However, your function must obey the Annoying Requirements. This means that you must hardcode the answer for 0.1.2.3. For 4,5,6 you must recurse. but you must hardcode the arguments that you pass to the recursive calls. Of course, you will use the general formula, as well - but only on the last case! 5 annoying-climbUp (n), annoying-climbDownUp (n) These two functions each return an array, which contains a sequence of intgers in = 0, then they return an empty array, and if n = 1 they return a single value. [1] However, if n is larger, they return a sequence that counts through the nub- mers 1 to n. In climbup(), the sequence simply counts ups in climbDownUpO. It starts at n, counts down to 1, and then counts back up to n. For example, if n = 4. then annoying-climbUp() will return [1,2,3,4), while annoying.climbDownUp will return (4,3,2,1,2,3,4) REMEMBER: Helper functions are banned! Thus, while it would be easy to solve the climbDownUp problem by calling climbDown() and then doing a little slicing, this isn't allowed! 6 is sorted (head), is_sorted recursive (head) In linked list recursion.py . you will write two functions, both of which do exactly the same thing but one must be recursive, and the other must not be (The recursive problem is not required to follow the Annoying Requirements, though.) Each of these functions take a linked list (which might be empty) and checks to see if the values are sorted: if so, it returns True: if not, it returns False. (If the list is empty or has a single node, they must return True

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!