Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with these questions I don't get how I am meant to use recursion for these in python no loops Q1: Q2: A
I need help with these questions I don't get how I am meant to use recursion for these in python no loops
Q1:
Q2:
A palindrome is a sentence in which the letters appear in the same order when the sentence is reversed. For example: "Madam, I'm Adam" A Toyota's a Toyota Write a recursive function named remove_non_alphabetic(sentence) function which takes a string as a parameter and returns the same string in lowercase with all non-alphabetic characters removed. Not complete Then write a recursive function named is_palindrome ( sentence) which takes a string as a parameter and returns True if the string is a palindrome, and False otherwise. For example: print(palindrome_filter("Able was I ere I saw Elba.")) print(is_palindrome (remove_non_alphabetic("Able was I ere I saw Elba."))) prints ablewasiereisawe lba True Note: you may not use loops of any kind. You must use recursion to solve this problem. You can assume that the parameter string is not empty. For example: Test Result print(is_palindrome (remove_non_alphabetic("Able was I ere I saw Elba."))) print(is_palindrome (remove_non_alphabetic("Ebla was I ere I saw Elba."))) True False Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) 1 def remove_non_alphabetic(sentence): #use recursion 2, 3 4 def is-palindrome (sentence): # use recursion 5 Write a recursive function named binary_search_descending (numbers, item) which takes a list of DESCENDING numbers and an integer as parameters and performs a recursive binary search on the list of numbers. Note that the list of numbers is in descending order. The function should return True if item is in the list, and False otherwise. Each time the function is called with a non-empty list, it should print the list being searched in the following format:- Note: you may not use loops of any kind. You must use recursion to solve this problem. You can assume that the parameter list is not empty. Hint: For this recursive implementation of binary search you may want to consider computing the mid index using len(numbers) // 2. For example: Test Result [42, 32, 19, 17] 13 [8, 2, 1, 0] True test_list = [42, 32, 19, 17, 13, 8, 2, 1, 0] print (binary_search_descending(test_list, 13)) test_list = [42, 32, 19, 17, 13, 8, 2, 1, 0] print(binary_search_descending(test_list, 3)) [42, 32, 19, 17] 13 [8, 2, 1, 0] [8, 2] i [0] [8] 2 [] [] 80 False Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) 1 def binary_search_descending numbers, item): #use recursion
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