C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 12, Problem 12.24E

(Printing Trees) Write a recursive function outputTree to display a binary tree on the screen. The function should output the tree row-by-row with the top of the tree at the left of the screen and the bottom of the tree toward the right of the screen. Each row is output vertically. For example, the binary tree illustrated in Fig12.22. is output as follows:

Chapter 12, Problem 12.24E, (Printing Trees) Write a recursive function outputTree to display a binary tree on the screen. The

Note that the rightmost leaf node appears at the top of the output in the rightmost column, and the root node appears at the left of the output. Each column of output starts five spaces to the right of the previous column. Function outputTree should receive as arguments a pointer to the root node of the tree and an integer totalSpaces representing the number of spaces preceding the value to be output (this variable should start at zero so that the root node is output at the left of the screen). The function uses a modified inorder traversal to output the tree. The algorithm is as follows:

While the pointer to the current node is not NULL.

Recursively call outputTree with the current node’s right subtree and totalSpaces + 5.

Use a for statement to count from 1to totalSpaces Output the value in the current node.

Recursively call outputTree with the current nodes left subtree and totalSpaces + 5.

Blurred answer
Students have asked these similar questions
1001 UnaI (p E. Write a program named as ProblemE_.cpp that constructs a BST from a given postorder traversal of that tree. For example, if the given traversal is {1, 7, 5, 50, 40, 10}, then the output should be the tree shown in Problem 3. Hints: • Write a recursive function to do the followings: a) Get the last element of the array and make it root of the BST. b) Find the index i such that the value in i-1 is the first value smaller than the root. c) Recursively call a function to do the same for left subarray (1 .. i-1) and right subarray (i..size-2). i) Get the last element of right half and make it right child of the root created in step a. ii) Get the last element of left half and make it left child of the root created in step a. d) return root.
Calculation "a" was used for loop to calculate the sum of squares of values in this list: 1, 7, 8, 6, 11 (The answer was 271) (Question 1) Create recursive function to do the same calculation "a" in the above. (The function input will be the list. Each recursion, you are going to send a sub-list with one less item from the list) (Hint:There are many ways to do sorting. Create a function to perform bubble sorting as descried in this tutorial: (https://www.geeksforgeeks.org/bubble-sort/) . The algorithm should stop when there are no swaps in the last iteration.)
C Proggraming Found in the Shuffle (Strings)   An ordinary deck of playing cards contains 52 cards, each of which has a suit and a value. Most card games require that a deck be shuffled at the beginning of a play. However, sometimes the deck isn't shuffled well enough, and there are arrangements of cards in the deck which may cause a bias in the play. Two such arrangements are a same-suit sequence and an ascending sequence. A same-suit sequence is simply a sequence of consecutive cards in the deck with the same suit. An ascending sequence is a sequence of consecutive cards in the deck that follow one another in increasing value, with Ace following King and preceding two. Thus, 2S, 5S, KS, 3S AS is a same-suit sequence of length five, and 9C, 10D, JC, QS, KH, AC, 2D is an ascending sequence of length seven, and 2H 3H 4H 5H 6H is both a same-suit and ascending sequence of length five.   The Problem   Given a deck of cards, determine the length of the longest same-suit sequence and the…

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Is Java a high-level language or a low-level language?

Java: An Introduction to Problem Solving and Programming (7th Edition)

The ____________ is always transparent.

Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)

The following program will not compile because the lines have been mixed up. System.out.print(Success\n); } pub...

Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)

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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Computational Software for Intelligent System Design; Author: Cadence Design Systems;https://www.youtube.com/watch?v=dLXZ6bM--j0;License: Standard Youtube License