Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 18.2, Problem 18.2.2CP
Program Plan Intro
Recursive method:
A method which is called again and again by itself is called as recursive method. With the help of recursive method, it is possible to solve certain problems more quickly and easily.
Pros and cons of recursion:
Pros: recursion reduces unnecessary calling of functions. It is possible to solve complex problems more easily.
Cons: Recursion is always logical which is very difficult to understand. It takes more stack space. It also takes more time to process.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Analyze the ChatGPT output by answering the following questions.
Data types
Which data types would be accepted by the function count_crossings_and_nestings for the argument arcs? Would a set work?
What does the function return? What data type is it?
Run the example suggested by ChatGPT. Is the function count_crossings_and_nestings working as expected?
Try computing nestings and crossings with the smallest examples {}, {(0,1)}, {(0,1),(2,3)}, {(0,3),(1,2)} and {(0,2),(1,3}. Does the output work?
only the method in java data structures
It's well knowledge that "points" have problems with "dangling and wild pointers." Provide evidence to back up the claim you made.
Chapter 18 Solutions
Introduction to Java Programming and Data Structures: Brief Version (11th Global 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
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
- Find the bug and write code to proving you have identified the problem. What is the quick fix Byron's code needs? Byron is trying to define a 4 distinct tuples and access one specific element from each of them, but keeps getting an TypeError in his code for some reason a = (0, 1, 100)b = (-1, True, -0.1)c = (10)d = ("XX", "XY", "XXY")print(a[2], b[-1], c[0], d[2])# Byron's desired output for this code is: 100 -0.1 10 XXYarrow_forwardThe arithmetic operators and stream operators are both enumeration types. Is there a method to use these operators instantly while utilising enumeration types? For example, is it feasible to overload these operators and still get a good result? To what end are you arguing?arrow_forwardC++arrow_forward
- Which one of a, b, c, d correct ? (A) How many variables in total are referenced by the encode method? (B) How many data types are used in this method? (C) in how many ways can the parameter list for the count method be organized? Select the option that correctly answers questions A, B and C. (A) 7, (B) 2, (C) 2 (A) 5, (B) 2, (C) 1 (A) 7, (B) 2, (C) 1 (A) 7, (B) 3, (C) 1 (A) 7, (B) 3, (C) 2 (A) 5, (B) 3, (C) 1 (A) 5, (B) 3, (C) 2 (A) 5, (B) 2, (C) 2 Use hand-simulation to determine the response produced by count when given the String "modularization" as parameter. The value returned in this case is A)2 B)5 C)4 D)3 Repeat the exercise to determine what is returned by encode when given the String "abstraction". The value returned in this case A)jusuvsryau B)Vuvuvsryau C)juvuvsrysu D)juvuvsryau E)juvvvsryau F)ation of a String fir G)juvuvsryavarrow_forwardGive Description of GenerateConsoleCtrlEvent function.arrow_forwardIn this task you will work with the linked list of digits we have created in the lessons up to this point. As before you are provided with some code that you should not modify: A structure definition for the storage of each digit's information. A main() function to test your code. The functions createDigit(), append(), printNumber(), freeNumber(), readNumber() and divisibleByThree() (although you may not need to use all of these). Your task is to write a new function changeThrees() which takes as input a pointer that holds the address of the start of a linked list of digits. Your function should change all of those digits in this linked list that equal 3 to the digit 9, and count how many replacements were made. The function should return this number of replacements. Provided codearrow_forward
- Need help making a java file that combines both linearSearch and binarySearch •Both search methods must use the Comparable<T> interface and the compareTo() method.•Your program must be able to handle different data types, i.e., use generics.•For binarySearch, if you decide to use a midpoint computation formula that is different fromthe textbook, explain that formula briefly as a comment within your code. //code from textbook //linearSearch public static <T> boolean linearSearch(T[] data, int min, int max, T target) { int index = min; boolean found = false; while (!found && index <= max) { found = data [index].equals(target); index++; } return found; } //binarySearch public static <T extends Comparable<T>> boolean binarySearch(T[] data, int min, int max, T target) { boolean found = false; int midpoint = (min + max)/2; if (data[midpoint].compareTo(target)==0)…arrow_forwardQuestion 2 Get the Array ADT implementation from your textbook to work. Demonstrate that your code works as specified in the ADT. You are free to change internal names so that you can make better sense of the code provided in the textbook. You will need this code for later exercises Your implementation must provide _str_() and repr_() methods, in addition to the methods implemented in the textbook. The output of these methods must return each value separated with a comma in a string. For example, if the array has values 10, 12, 14, 16, and 18, these methods must return the string "10, 12, 14, 16, 18" Your code should support following operations: import random array = Array ( 100 ) for i in range( len( array ) ): # array[i] = random.random() # Print individual values in the array. # for value in array: # print(value) # Print the entire array. # print(array )arrow_forwardWhat is the difference between void and null pointers.Give suitable example in support of your answerarrow_forward
- Implement the scenario above using C/C++ programming language. Do apply the techniques for good programming practices.arrow_forwardIt says that 'readmatrix' is undefined. Do I need to use dlmread()? My original question was more if I had a file with entries, how do I throw them into a matrix?arrow_forwardSally and Harry are developing a Coin version. Sally specifies that the type of the single parameter to her compareTo function is Object. Harry defines the parameter to be of type Coin since he is aware that it will always be called on objects of that type. Which approach is appropriate for putting Coin items into an OrderedVector?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