Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134700144
Author: Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 18, Problem 18.38PE
(Recursive tree) Write a
FIGURE 18.20 A recursive tree with the specified depth is drawn. Source: Copyright © 1995–2016 Oracle and/or its affiliates. All rights reserved. Used with permission.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
computer programming (C) language
Demonstrate Recursion Assignment Instructions
Overview
The programs we’ve discussed so far are generally structured as methods that call one another in a hierarchical manner. For some problems, it’s useful to have a method call itself—this is known as a recursive method. Such a method can call itself either directly or indirectly through another method. Recursion is an important topic discussed at length in upper-level computer-science courses.
Instructions
Write a recursive method printArray() that displays all the elements in an array of integers, separated by spaces. The array must be 100 elements in size and filled using a for loop and a random number generator. The pseudo-code for this is as follows:
//Instantiate an integer array of size 100
//fill the array
For (int i=0; i<array.length; i++)
Array[i] = random number between 1 and 100 inclusive
printArray(integer array);
For this assignment make sure that your screen shots show your program running and that your runtime…
Define the term " recursion definition " .
Chapter 18 Solutions
Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
Ch. 18.2 - What is a recursive method? What is an infinite...Ch. 18.2 - Prob. 18.2.2CPCh. 18.2 - Show the output of the following programs and...Ch. 18.2 - Prob. 18.2.4CPCh. 18.2 - Prob. 18.2.5CPCh. 18.2 - Write a recursive mathematical definition for...Ch. 18.3 - Prob. 18.3.1CPCh. 18.3 - What is wrong in the following methods?Ch. 18.3 - Prob. 18.3.3CPCh. 18.4 - Describe the characteristics of recursive methods.
Ch. 18.4 - Prob. 18.4.2CPCh. 18.4 - Prob. 18.4.3CPCh. 18.5 - Prob. 18.5.1CPCh. 18.5 - Prob. 18.5.2CPCh. 18.5 - What is a recursive helper method?Ch. 18.6 - Prob. 18.6.1CPCh. 18.6 - How does the program get all files and directories...Ch. 18.6 - How many times will the getSize method be invoked...Ch. 18.6 - Will the program work if the directory is empty...Ch. 18.6 - Will the program work if line 20 is replaced by...Ch. 18.6 - Will the program work if lines 20 and 21 are...Ch. 18.7 - Prob. 18.7.1CPCh. 18.8 - Prob. 18.8.1CPCh. 18.8 - Prob. 18.8.2CPCh. 18.8 - How many times is the displayTriangles method...Ch. 18.8 - Prob. 18.8.4CPCh. 18.8 - Prob. 18.8.5CPCh. 18.9 - Which of the following statements are true? a. Any...Ch. 18.9 - Prob. 18.9.2CPCh. 18.10 - Identify tail-recursive methods in this chapter.Ch. 18.10 - Rewrite the fib method in Listing 18.2 using tail...Ch. 18 - Prob. 18.1PECh. 18 - Prob. 18.2PECh. 18 - (Compute greatest common divisor using recursion)...Ch. 18 - (Sum series) Write a recursive method to compute...Ch. 18 - (Sum series) Write a recursive method to compute...Ch. 18 - (Sum series) Write a recursive method to compute...Ch. 18 - (Fibonacci series) Modify Listing 18.2,...Ch. 18 - Prob. 18.8PECh. 18 - (Print the characters in a string reversely) Write...Ch. 18 - (Occurrences of a specified character in a string)...Ch. 18 - Prob. 18.11PECh. 18 - (Print the characters in a string reversely)...Ch. 18 - (Find the largest number in an array) Write a...Ch. 18 - (Find the number of uppercase letters in a string)...Ch. 18 - Prob. 18.15PECh. 18 - (Find the number of uppercase letters in an array)...Ch. 18 - (Occurrences of a specified character in an array)...Ch. 18 - (Tower of Hanoi) Modify Listing 18.8,...Ch. 18 - Prob. 18.19PECh. 18 - (Display circles) Write a Java program that...Ch. 18 - (Decimal to binary) Write a recursive method that...Ch. 18 - (Decimal to hex) Write a recursive method that...Ch. 18 - (Binary to decimal) Write a recursive method that...Ch. 18 - (Hex to decimal) Write a recursive method that...Ch. 18 - Prob. 18.25PECh. 18 - (Create a maze) Write a program that will find a...Ch. 18 - (Koch snowflake fractal) The text presented the...Ch. 18 - (Nonrecursive directory size) Rewrite Listing...Ch. 18 - (Number of files in a directory) Write a program...Ch. 18 - (Game: Knights Tour) The Knights Tour is an...Ch. 18 - (Game: Knights Tour animation) Write a program for...Ch. 18 - (Game: Eight Queens) The Eight Queens problem is...Ch. 18 - Prob. 18.35PECh. 18 - (Sierpinski triangle) Write a program that lets...Ch. 18 - (Hilbert curve) The Hilbert curve, first described...Ch. 18 - (Recursive tree) Write a program to display a...Ch. 18 - Prob. 18.39PE
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Why is it useful for a programmer to have some background in language design, even though he or she may never a...
Concepts Of Programming Languages
True or False: One limitation of the for loop is that only one variable may be initialized in the initializatio...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Determine the maximum tensile and compressive bending stress in the beam if it is subjected to a moment of M = ...
Mechanics of Materials (10th Edition)
102* The sum of seven interior angles ofa closed-polygon traverse each read to the nearest
3 ” is
$99 a 59 '39...
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Why is soldering unattractive if a high-strength joint is desired?
Degarmo's Materials And Processes In Manufacturing
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
- subject (data structures ) write a pseudocode for Recursive bubble sort with an examplearrow_forwardDefine recursion. 2) What are the elements of recursion? (some definitions list only 2, others clarify a third element. Name and describe at least 2.) 3) Provide an example of a coding implementation that uses recursion. (You do not need to write the code, but describe a specific coding instance that commonly uses recursion in its implementation.) 4) Provide an example of a real-life scenario in nature that displays recursion.arrow_forwardDefine the term " recursion limitations " .arrow_forward
- *Computer Science* Reduce the term shown below: (λx . λy . (add y ((λz . (mul x z)) 3))) 7 5arrow_forwardDefine recursive procedures.arrow_forwardCalculating Fibonacci number: Write down the pseudocode for originally calculating Fibonacci number (without using dynamic programming) Write down the pseudocode for originally calculating Fibonacci number using dynamic programming, iteratively Write down the pseudocode for originally calculating Fibonacci number using dynamic programming, recursively What’s the difference between these three?arrow_forward
- Java source code writing - a recursive algorithm. Please use non-recursive and recursive ways to compute the nth Harmonic number, defined as H. Turn in your java source code file with three methods, including one main() method.arrow_forward6Recursion 8, 21, 34, 55, 89 ... ]: The Fibonacci sequence is the series of integers 0, 1, 1, 2, 3, 5, See the pattern? Each element in the series is the sum of the preceding two items. There is a recursive formula for calculating the nh number of the sequence (the 0th number if Fib(0) = 0): N, if N =0 or 1 Fib(N) = %3D Fib(N- 2) +Fib(N -1) if N>1 1. Write a recursive version of the function Fibonacci. 2. Write a non-recursive version of the function Fibonacci. 3. Compare the recursive and iterative versions for efficiency. 4. Can you think of a way to make the recursive version more efficient? If so, discuss your solution in detail.arrow_forwardUse the sequence 16,384, 4086, 1024, 256 to write a recursive rulearrow_forward
- RESTRICTIONS: Do not add any imports, the ones that you need will be given to you. Do not use recursion. Do not use try-except statements, you should be able to anticipate or prevent any errors from happening at all! PLEASE COMPLETE CODE IN PYTHON! AND PLEASE DONT COPY CODE FROM CHEGG I HAVE SEEN THE CODE AND IT IS NOT CORRECT SO DONT TRY TO FOOL PLZarrow_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_forwardPlease fix the code and explain the steps (specially the recursive part). Also please test it and screenshot the code as well as the output. (using python)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Computational Software for Intelligent System Design; Author: Cadence Design Systems;https://www.youtube.com/watch?v=dLXZ6bM--j0;License: Standard Youtube License