Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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] 0 && A[--rightPointer] > pivot do //do-nothing end while if left Pointer >= right Pointer break else swap left Pointer, right Pointer end if end while swap left Pointer, right return left Pointer end function procedure quickSort (left, right) if right-left

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the two main types of consumer credit?

Answered: 1 week ago

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago