Starting Out with C++: Early Objects
Starting Out with C++: Early Objects
8th Edition
ISBN: 9780133360929
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: Addison-Wesley
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 14, Problem 1RQE

What type of recursive function do you think would be more difficult to debug; one that uses direct recursion or one that uses indirect recursion? Why?

Expert Solution & Answer
Check Mark
Program Plan Intro

Recursive Function:

  • The function has ability to call itself is called recursion function.
  • It is a substitute method for reiteration.
  • It replaces the loop statements, so without loop statement it executes the algorithm codes a number of times.
  • Selection statement is used to make a decision for the execution of the recursion.
  • There are two types of recursive functions. They are:
    • Direct recursion
    • Indirect recursion

Direct recursion:

When a function calls itself repeatedly until the condition becomes false is called as direct recursion.

Example:

//method definition

void test()

{

    //call a function

    test();

}

Indirect recursion:

When a function calls another function which in turn calls the same calling function is called as indirect recursion.

Example:

//method definition

void test()

{

    //call a function

    test1();

}

//method definition

void test1()

{

    //call a function

    test();

}

Explanation of Solution

Recursion that is difficult to debug:

The recursion that is difficult to debug is “Indirect recursion”.

Justification:

  • Because, a function calls one function which is linked to another function.
  • Since, a function can make multiple calls to a function; it is difficult to track the flow control of function that is being processed within the code.

Therefore, “Indirect recursion” is difficult to debug when compared to direct recursion.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
The Horse table has the following columns: ID - integer, auto increment, primary key RegisteredName - variable-length string Breed - variable-length string Height - decimal number BirthDate - date Delete the following rows: Horse with ID 5 All horses with breed Holsteiner or Paint All horses born before March 13, 2013 To confirm that the deletes are correct, add the SELECT * FROM HORSE; statement.
Why is Linux popular? What would make someone choose a Linux OS over others? What makes a server? How is a server different from a workstation? What considerations do you have to keep in mind when choosing between physical, hybrid, or virtual server and what are the reasons to choose a virtual installation over the other options?
Objective  you will: 1. Implement a Binary Search Tree (BST) from scratch, including the Big Five (Rule of Five)  2. Implement the TreeSort algorithm using a in-order traversal to store sorted elements in a vector. 3. Compare the performance of TreeSort with C++'s std::sort on large datasets. Part 1: Understanding TreeSort How TreeSort Works TreeSort is a comparison-based sorting algorithm that leverages a Binary Search Tree (BST): 1. Insert all elements into a BST (logically sorting them). 2. Traverse the BST in-order to extract elements in sorted order. 3. Store the sorted elements in a vector.  Time Complexity Operation                                Average Case     Worst Case (Unbalanced Tree)Insertion                                     0(1log n)                0 (n)Traversal (Pre-order)                  0(n)                       0 (n)Overall Complexity                  0(n log n)                 0(n^2) (degenerated tree) Note: To improve performance, you could use a…
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage
Computational Software for Intelligent System Design; Author: Cadence Design Systems;https://www.youtube.com/watch?v=dLXZ6bM--j0;License: Standard Youtube License