Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 13, Problem 4MC
Program Description Answer
The resultant of the infinite recursion will be a run-time exception.
Hence, the correct answer is option “D”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
An infinite recursion will result ina) a program that "hangs"b) a broken computerc) a rebootd) a run-time exception
/** Iluustration of RecursiveTask*/import java.util.concurrent.ExecutionException;import java.util.concurrent.ForkJoinPool;import java.util.concurrent.RecursiveTask;
public class SumWithPool{ public static void main(String[] args) throws InterruptedException, ExecutionException {
//get the number of avaialbe CPUs int nThreads = Runtime.getRuntime().availableProcessors(); System.out.println("Available CPUs: " + nThreads); //create an array of data int n = 10; //initital data size if(args.length > 0) // use the user given data size n = Integer.parseInt(args[0]); int[] numbers = new int[n];
for(int i = 0; i < numbers.length; i++) { numbers[i] = i; }
ForkJoinPool forkJoinPool = new ForkJoinPool(nThreads); Sum s = new Sum(numbers,0,numbers.length);
long startTime = System.currentTimeMillis(); //start timer Long result = forkJoinPool.invoke(s); long endTime =…
1. In a linked stack the bottom of the stack is in the beginning of the list and the top of the stack is at the end of the list.
2. In the worst case a sequential search of an array with N elements is O(N).
3. In the best case, a sequential search of an array with 1,000 elements requires this many comparisons: ________________.
4. Java programmers can define their own exception classes.
A. True B. False
5. If a recursive method does not have a base case:
A. a syntax error is identified.B. an exception will be thrown.
C. it will operate more efficiently.D. it will run forever.
Chapter 13 Solutions
Python Programming: An Introduction to Computer Science, 3rd Ed.
Ch. 13 - Prob. 1TFCh. 13 - Prob. 2TFCh. 13 - Prob. 3TFCh. 13 - Prob. 4TFCh. 13 - Prob. 5TFCh. 13 - Prob. 6TFCh. 13 - Prob. 7TFCh. 13 - Prob. 8TFCh. 13 - Prob. 9TFCh. 13 - Prob. 10TF
Ch. 13 - Prob. 1MCCh. 13 - Prob. 2MCCh. 13 - Prob. 3MCCh. 13 - Prob. 4MCCh. 13 - Prob. 5MCCh. 13 - Prob. 6MCCh. 13 - Prob. 7MCCh. 13 - Prob. 8MCCh. 13 - Prob. 9MCCh. 13 - Prob. 10MCCh. 13 - Prob. 1DCh. 13 - Prob. 2DCh. 13 - Prob. 3DCh. 13 - Prob. 4DCh. 13 - Prob. 5DCh. 13 - Prob. 1PECh. 13 - Prob. 2PECh. 13 - Prob. 3PECh. 13 - Prob. 4PECh. 13 - Prob. 5PECh. 13 - Prob. 6PECh. 13 - Prob. 7PE
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
- USING SIMPLE JAVA CODE TAKE GIVEN CODE AND MODIFY MODIFY GIVEN CODE USING JAVA RECURSIVE ACTION DO THE SAME JOB BUT USING RECURSIVE ACTION INSTEAD OF RECURSIVE TASK SAMPLE CODE BELOW ********************************************************************************************************* import java.util.concurrent.ExecutionException;import java.util.concurrent.ForkJoinPool;import java.util.concurrent.RecursiveTask; //replace with recursive action to do same job below// public class SumWithPool{ public static void main(String[] args) throws InterruptedException, ExecutionException { //get the number of avaialbe CPUs int nThreads = Runtime.getRuntime().availableProcessors(); System.out.println("Available CPUs: " + nThreads); //create an array of data int n = 10; //initital data size if(args.length > 0) // use the user given data size n = Integer.parseInt(args[0]); int[] numbers = new int[n]; for(int i = 0; i <…arrow_forwardIn JavaScript use recursion to find the sum of all pages in the following: function getPageTotal(list) {// your code here// returns an integer}Example test case:Input: {"book":"A","pages":50,"next":{"book":"B","pages":25,"next": null}}Output: 75Reasoning: 50 + 25 pagesarrow_forwardIf the returned values of a recursion are returned in the order of First In First Out (FIFO), then how are they stored in the memory stack before the program finishes running the recursion code?arrow_forward
- 305. A program that runs in parts on several computers is said to be a. delegated b. spread c. distributed d. recursivearrow_forwardThe following recursive method is causing an exception because the base case is missing. This method is suppose to display the content of an array backward. For example If the array num contains 1 2 3 4 5 6 then the call print(num, 5) should display: 6 5 4 3 2 1 public static void print(int[] a, int index){ System.out.println(a[index]); print(a, index -1);}Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 5 fill in the blank so that the exception does not happen, in order of the given numbers public static void print(int[] a, int index){if( __1___ ___2__ ___3__) <----- base case __4____ System.out.println(a[index]); print(a, index -1); <---- recursive case}arrow_forwardWhat is the definition of an endless recursion? What is the definition of a direct recursion? What is an indirect recursion, and how does it work?arrow_forward
- Please provide the full activation record stack for the following code at point 1. Show all values. void fun1(int& s1, int& s2){ int temp = s2; s2 = s1; s1 = temp; } // end fun1 int fun2(int s1, int& s2){ return s1 + (s2 * 2); } //end fun2 void recur1(int check){ if(check < 8){ check++; recur1(check); } else //point 1 --- This will happen after the final recursion call. return; } // end recur1 int main(){ int x = 0; int y = 2; int z = 3; fun1(x, y); x = fun2(z, y); recur1(x + y + z); return 0; } // end mainarrow_forwardA recursion that never ends is defined as follows: What exactly is a direct recursion, and how does it work? An indirect recursion is a kind of recursion that works in a certain way.arrow_forwardcreate a program that takes a nested list and flattens the nested list without using recursion.arrow_forward
- To understand the value of recursion in a programming language, write a program that implements quicksort, first using recursion and then without recursion.arrow_forwardPython Using recursion only No loops Take a string representing a directory path as a parameter And returns the number of directories in the path that have no files def countSparseDirs(path):arrow_forwardAs recursion is implemented using a stack, an object of class Stack must be declared and initialized in the program to hold the class objects of every recursive call? a)true b) falsearrow_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
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License