Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Write a recursive function that takes as a parameter a nonnegative integer
and generates the following pattern of stars. If the nonnegative integer is 4,
the pattern generated is as follows:
****
***
**
*
*
**
***
****
Also, write a program that prompts the user to enter the number of lines in the pattern and uses the recursive function to generate the pattern. For
example, specifying 4 as the number of lines generates the preceding pattern.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 3 images
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
- K + edgenuity.com/player/ s Semester A 7 1 2 3 4 5 05 return 1 else: return n* factorial(n-1) Which line of code includes a recursive function call? 0 3 04 01 Consider the Python code for finding the factorial of an integer n using recursion. Line numbers have been added to the left of each line of code. def factorial(n): if n == 1: Mark this and return c C O M 31 0 DELL O FIXIXI A Save and Exit G < Next English Sign out V 4 19 Kinley Heat TIME REMAINING 59:14 Submit Mar 27 0 2:38arrow_forwardWrite a recursive function that takes a positive integer and returns the factorial of that integer. Attention, the function must be recursive, and its name must be "fatorial".arrow_forwardneed help Writing a recursive function, isPalindrome, to check if a string is a palindrome. Return true if the string is a palindrome; otherwise, return false. in javascript example isPalindrome('Kayak'); // => true i sPalindrome('NEVERODDOREVEN'); // => true i sPalindrome('Tacocat'); // => true isPalindrome('SELFLESS'); // => falsearrow_forward
- Please help me with these question. I am having trouble understanding what to do. Please use HTML, CSS, and JavaScript Thank youarrow_forwardCalling a recursive function. Write a statement that calls the recursive function backwards_alphabet() with input starting_letter.Sample output with input: 'f' f e d c b a def backwards_alphabet(curr_letter): if curr_letter == 'a': print(curr_letter) else: print(curr_letter) prev_letter = chr(ord(curr_letter) - 1) backwards_alphabet(prev_letter) starting_letter = input() ''' Your solution goes here '''arrow_forwardIn c++arrow_forward
- Write a program named stars.py that has two functions for generating star polygons. One function should be implemented using an iteration (a for loop), and another function should be a recursion. It is optional to fill in your shapes. The functions for generating stars should be named star (size, n, d=2) and star_recursive (size, n, level, d=2), where size is the size of the polygon side (edge), n is the number of sides (or angles), d is a density or winding number that should be set to default value 2, and level is the level of recursion initially equal to n.arrow_forwardIn Python. Upvote for Quick answer. Check picture. No need to comment the code. Thank You.arrow_forwardWrite code to complete raise_to_power(). Note: This example is for practicing recursion; a non-recursive function, or using the built-in function math.pow(), would be more common.Sample output with inputs: 4 24^2 = 16 def raise_to_power(base_val, exponent_val): if exponent_val == 0: result_val = 1 else: result_val = base_val * ''' Your solution goes here ''' return result_val user_base = int(input())user_exponent = int(input()) print('{}^{} = {}'.format(user_base, user_exponent, raise_to_power(user_base, user_exponent)))arrow_forward
- Write a program called p3.py that contains a function called reveal_recursive() that takes a word (string) and the length of the word (int) as input and has the following functionality: 1. prints the word where all characters are replaced by underscores 2. continue to print the word revealing one character at a time. i.e., the second line printed should print the first character followed by “_”’s representing the rest of the word. (see example below) 3. the function should end after printing the entire word once. 4. This function should be recursive Example: #the word is kangaroo ________ k_______ ka______ kan_____ kang____ kanga___ kangar__ kangaro_ kangarooarrow_forwardWrite code to complete raise_to_power). Note: This example is for practicing recursion; a non-recursive function, or using the built-in function math.pow(0, would be more common. Sample output with inputs: 4 2 4^2 = 16 344614.2214230.qx3zqy7 1 def raise_to_power (base_val, exponent_val): if exponent_val result_val 2 0: == = 1 4 else: result_val base_val * Your solution goes here ... = 6. 7 return result_val 9 user_base 10 user_exponent int (input ()) int (input ()) = = 11 12 print ('{}^{} {}'.format (user_base, user_exponent, raise_to_power (user_base, user_exponent))) 13arrow_forwardJava, I am not displaying my results correct. It should add up the digits in the string. input string |result for the sumIt Recursion functions and a findMax function that finds the largest number in a string "1d2d3d" | 6 total "55" |10 total "xx" | 0 total "12x8" |12 Max number "012x88" |88 Max Number "012x88ttttt9xe33ppp100" |100 Max Number public class Finder { //Write two recursive functions, both of which will parse any length string that consists of digits and numbers. Both functions //should be…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education