Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 12, Problem 4PE
Largest List Item
Design a function that accepts a list as an argument and returns the largest value in the list. The function should use recursion to find the largest item.
Expert Solution & Answer
Learn your wayIncludes step-by-step video
schedule03:36
Students have asked these similar questions
Question >
Not complete
Marked out of
1.50
Flag question
Previous page
Write a recursive function named get_palindromes (words) that takes a list of words as a parameter. The function should return a list of all the palindromes in the list. The function returns an
empty list if there are no palindromes in the list or if the list is empty. For example, if the list is ["racecar", "hello", "noon", "goodbye"], the function should return ["racecar", "noon"].
A palindrome is a word that is spelled the same forwards and backwards.
Note: The get_palindromes() function has to be recursive; you are not allowed to use loops to solve this problem.
For example:
Test
words = ["racecar", "hello", "noon", "goodbye", "test", 'aibohphobia'] ['racecar', 'noon', 'aibohphobia']
print (get_palindromes (words))
print (get_palindromes ([]))
print (get_palindromes (['this', 'is', 'test']))
Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %)
Result
Precheck Check
[]
[]
Next page
Design a function that accepts a list as an argument and returns the largest value in the list. The function should use recursion to find the largest item.
you must include a while loop in this function
you should not us any of the following:
dictionaries or dictionary methods
try-except
break and continue statements
recursion
map / filter
Chapter 12 Solutions
Starting Out with Python (4th Edition)
Ch. 12.2 - It is said that a recursive algorithm has more...Ch. 12.2 - Prob. 2CPCh. 12.2 - What is a recursive case?Ch. 12.2 - What causes a recursive algorithm to stop calling...Ch. 12.2 - What is direct recursion? What is indirect...Ch. 12 - Prob. 1MCCh. 12 - A function is called once from a program's main...Ch. 12 - Prob. 3MCCh. 12 - Prob. 4MCCh. 12 - Prob. 5MC
Ch. 12 - Prob. 6MCCh. 12 - Any problem that can be solved recursively can...Ch. 12 - Actions taken by the computer when a function is...Ch. 12 - A recursive algorithm must _______ in the...Ch. 12 - A recursive algorithm must ______ in the base...Ch. 12 - An algorithm that uses a loop will usually run...Ch. 12 - Some problems can be solved through recursion...Ch. 12 - It is not necessary to have a base case in all...Ch. 12 - In the base case, a recursive method calls itself...Ch. 12 - In Program 12-2 , presented earlier in this...Ch. 12 - In this chapter, the rules given for calculating...Ch. 12 - Is recursion ever required to solve a problem?...Ch. 12 - When recursion is used to solve a problem, why...Ch. 12 - How is a problem usually reduced with a recursive...Ch. 12 - What will the following program display? def...Ch. 12 - Prob. 2AWCh. 12 - The following function uses a loop. Rewrite it as...Ch. 12 - Prob. 1PECh. 12 - Prob. 2PECh. 12 - Prob. 3PECh. 12 - Largest List Item Design a function that accepts a...Ch. 12 - Recursive List Sum Design a function that accepts...Ch. 12 - Prob. 6PECh. 12 - Prob. 7PECh. 12 - Ackermann's Function Ackermann's Function is a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Porter’s competitive forces model: The model is used to provide a general view about the firms, the competitors...
Management Information Systems: Managing The Digital Firm (16th Edition)
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction To Programming Using Visual Basic (11th Edition)
What limits the number of projection welds that can be formed in a single operation?
Degarmo's Materials And Processes In Manufacturing
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
Internally, the CPU consists of the _____ and the _____.
Starting Out with C++: Early Objects (9th Edition)
A(n) _____ is a set of well-defined steps for performing a task or solving a problem.
Starting Out With Visual Basic (8th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Sorting and Searching Project Problem Statement for Sorting and Searching Project Design a program that will take an unsorted list of names and use the Insertion Sort algorithm to sort them. The program then asks the user to enter names to see if they are on the list. The program will use the recursive Binary Search algorithm to see if the name is in the list. The search should be enclosed in a loop so that the user can ask for names until they enter the sentinel value 'quit' Design Considerations The main program will provide an unsorted list of names. The list will be sorted using the Insertion Sort algorithm. Once the list is sorted, the user will provide names to search for in the list. The search will be conducted using the Recursive Binary Search Algorithm. A message will be printed displaying whetherthe name was found or not found on the list. This last part will be done inside a loop where the user will enter 'quit' when they are done searching for names. The algorithm for the…arrow_forwardHOME WORK 1-Write a steps to search for a node contain a given value in a S.L.L.L. its head is given by pointer variable ( First ) 2-Write Recursive function to count number of nodes in a given S.L.L.L. 3-Write a steps to count number of nodes contain odd number in a given S.L.L.L. its head is given by pointer variable ( First ). 4-Write a steps to test values stored in S.L.L.L. if it is in ascending order or not .arrow_forwardC programming Language Recursion Question 1: Write c program to print the sum of the array elements using recursive function. You should have the main function + function to find the summation. Question 2: Write recursive function that returns the value of the following recursive definition: f(x) = 0 if x<= 0 f(x-1 )+ 2 otherwise You should have the main function + the recursive function.arrow_forward
- In Python with comments please 4. Largest List ItemDesign a function that accepts a list as an argument and returns the largest value in the list. The function should use recursion to find the largest item.arrow_forwardC++ The binary search algorithm given in this chapter is nonrecursive. Write and implement a recursive version of the binary search algorithm. The program should prompt Y / y to continue searching and N / n to discontinue. If an item is found in the list display the following message: x found at position y else: x is not in the list Use the following list of integers when testing your program: 2, 6, 8, 13, 25, 33, 39, 42, 53, 58, 61, 68, 71, 84, 97arrow_forwardpython question: Write a code that takes a sentence as an argument and places its words in a list of words in alphabetical order If the sentence is: "Am I good" The function returns: ['Am', 'I', 'good']arrow_forward
- T/F: All recursive algorithms are efficient due to its recursive property.arrow_forwardCodeWorkout Gym Course Search exercises... Q Search kola shreya@colum X459: Review- Fibonacci In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, characterized by the fact that every number after the first two is the sum of the two preceding ones: e, 1, 1, 2, 3, 5, 8, 13, Write a recursive function that the returns the nth fibonacci number. Examples: fibonacci(0) -> 0 fibonacci(1) -> 1 fibonacci(7) -> 13 Your Answer: 1 public int fibonacci(int n) { 2 3} 4 CodeWorkout © Virginia Tech About License Privacy Contactarrow_forwardC languagearrow_forward
- Python Language - Bad Luck Numbersarrow_forwardPython question Analysis: Invariants (Q16-17) For each of the following functions, identify the loop invariant, exit condition and post condition. Question 16 (Invariant 1) This function returns the list of integers that are multiples of both 3 and 7 that occurs within a given list. Identify the loop exit condition, the loop post-condition, and the loop invariant at the end of the loop, which shows the algorithm’s correctness. def multiples_count(lst): """ Input: a list of integers, lst Output: the list of integers in lst that are multiples of both 3 and 7 """ res = [] for i in range(len(lst)): if lst[i]%3 == 0 and lst[i]%7 == 0: res.append(lst[i]) # Identify the loop invariant here return res Question 17 (Invariant 2) This function checks if a given list (of comparable elements) is sorted in ascending order. Identify the loop exit condition, the loop post-condition, and the loop invariant at the end of each iteration of the loop, which…arrow_forwardc++ data structures ADT Unsorted List The specifications for the Unsorted List ADT states that the item to be deleted is in the list. Rewrite the specifications for DeleteItem so that the list is unchanged if the item to be deleted is not in the list. Rewrite the specifications for DeleteItem so that all copies of the item to be deleted are removed if they existarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Introduction to Linked List; Author: Neso Academy;https://www.youtube.com/watch?v=R9PTBwOzceo;License: Standard YouTube License, CC-BY
Linked list | Single, Double & Circular | Data Structures | Lec-23 | Bhanu Priya; Author: Education 4u;https://www.youtube.com/watch?v=IiL_wwFIuaA;License: Standard Youtube License