Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A. Implement the following functions of recursion in Python. 1. A function Write() that takes an argument n and prints the numbers in reverse order
A. Implement the following functions of recursion in Python.
1. A function Write() that takes an argument n and prints the numbers in reverse order recursively. def Write(n): // your code goes here Example: Write (5) #The result should be like this: 5 4 3 2 1 2. Add a function Factorial() that returns the factorial of a number. def Factorial (n): // your code goes here Example: Factorial(5) #The result should be like this: 5! = 5x4x3x2x1 = 120 3. A function GCDC) that takes two numbers and returns their greatest common divisor. def GCD (a,b): // your code goes here Example: GCD (8,12) #The function should return 4 Algorithm: GCD (a,0) = a GCD (a,b) = GCD (b, a mod b) Recursive case Base Case 4. A function BinarySearch() that implements the binary search algorithm for non-empty sorted array using recursion. The function should take the arguments List, value, low, high and returns the location of the searched value. def BinarySearch (List, low, high, value): // your code goes here 5. A function QuickSort() which sorts the list in ascending/descending order. def QuickSort(): // your code goes here function partition Func(left, right, pivot) leftPointer = left rightPointer right 1 while True do while A[++left Pointer]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started