C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 12, Problem 12.17E
Program Plan Intro
Program plan:
- line, token variables are used for input. There is structure Treenode having data, leftptr, rightptr member variables which represent the tree node.
- void insertnode(node **ptr, char *value) function inserts the node in the tree.
- void preorder(node *ptr) function displays the contents of the tree in a preorder fashion.
- void inorder(node *ptr) function displays the contents of the tree in an in-order fashion.
- void postorder(node *ptr) function display the contents of the tree in a post-order fashion.
Program description:
The main purpose of the program is to create a tree from the line entered by the user and split it into the word. Then these words are inserted into the tree. This created tree contents are displayed in preorder, inorder and postorder fashion.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
) A singly linked list contains n - 1 strings that are binary representations of numbers from the set {0, 1,.…, n – 1} where n is an exact power of 2. However, the string corresponding to one of the numbers is missing. For example, if n = 4, the list will contain any three strings from 00, 01, 10 and 11. Note that the strings in the list may not appear in any specific order. Also note that thelength of each string is lgn, hence the time to compare two strings in O(lgn). Write an algorithmthat generates the missing string in O(n).
(Please Help. My professor did not teach us any of this and will not answer my emails)
Design a class named Queue for storing integers. Like a stack, a queue holds elements. In a stack, the elements are retreived in a last-in-first-out fashion. In a queue, the elements are retrieved in a first-in-first-out fashion. The class contains:
An int[] data field named elements that stores the int values in the queue
A data field named size that stores the number of elements in the queue
A constructor that creates a Queue object with defult capacity 8
The method enqueue(int v) that adds v into the queue
The method empty () that returns true if the queue is empty
The method getSize() that returns the size of the queue
(True/False): Arrays are passed by reference to avoid copying them onto the stack
Chapter 12 Solutions
C How to Program (8th Edition)
Ch. 12 - Prob. 12.6ECh. 12 - (Merging Ordered Lists) Write a program that...Ch. 12 - Prob. 12.8ECh. 12 - (Creating a Linked List, Then Reversing Its...Ch. 12 - Prob. 12.10ECh. 12 - Prob. 12.11ECh. 12 - Prob. 12.12ECh. 12 - Prob. 12.13ECh. 12 - Prob. 12.14ECh. 12 - (Supermarket Simulation) Write a program that...
Knowledge Booster
Similar questions
- (Tree height) Define a new class named BSTWithHeight that extends BST with the following method: /** Return the height of this binary tree */ public int height () Use https://liveexample.pearsoncmg.com/test/Exercise25_01.txt to test your code. Class Name: Exercise25_01 If you get a logical or runtime error, please refer https://liveexample.pearsoncmg.com/faq.html.arrow_forwardDo not use 2d lists, sets, dicts, arrays or recursion. Code in Python. Write the function destructiveRemoveRepeats(L), whichtakes a list L and destructively returns a new list in which any repeating elements in L are removed. Thus, this function should directly modify the provided list to not have any repeating elements. Since this is a destructive function, it should not return any value at all (so, implicitly, it should return None). For example: L = [1, 3, 5, 3, 3, 2, 1, 7, 5] destructiveRemoveRepeats(L) assert(L == [1, 3, 5, 2, 7])arrow_forwardapartmentList is a pointer to the first node in a linked list of nodes. Use this for Parts a, b, and c. Part a. Create an inner class that will hold the following information: the apartment number of the apartment (an int), the number of bedrooms in the apartment (also an int), the current rent of the apartment (a double). Don't forget to include a field for the link! Just create the class itself and the instance variables; you don't need to put any methods into the class.arrow_forward
- JAVA - HELParrow_forward(Generic binary search) Implement the following method using binary search. public static > int binarySearch(E[] list, E key)arrow_forward(Circular linked lists) This chapter defined and identified various operations on a circular linked list.a. Write the definitions of the class circularLinkedList and its member functions. (You may assume that the elements of the circular linked list are in ascending order.)b. Write a program to test various operations of the class defined in (a).arrow_forward
- Topic: Singly Linked ListImplement the following functions in C++ program. Read the question carefully. (See attached photo for reference) int count(int num) This will return the count of the instances of the element num in the list. In the linked list in removeAll method, having the method count(10) will return 3 as there are three 10's in the linked list. Additionally, you are to implement these methods: bool move(int pos1, int pos2) This method will move the element at position pos1 to the position specified as pos2 and will return true if the move is successful. This will return false if either the specified positions is invalid. In the example stated, operating the method move(1, 3) will move the 1st element and shall now become the 3rd element. The linked list shall now look like: 30 -> 40 -> 10 -> 50 int removeTail() This method will remove the last element in your linked list and return the said element. If the list is empty, return 0. You can use the…arrow_forward(Postfix notation) Postfix notation is a way of writing expressions without using parentheses. For example, the expression (1 + 2) 3 would be writ- ten as 1 2 + 3 *. A postfix expression is evaluated using a stack. Scan a postfix expression from left to right. A variable or constant is pushed to the stack. When an operator is encountered, apply the operator with the top two operands in the stack and replace the two operands with the result. The follow- ing diagram shows how to evaluate 1 2 + 3 *. 1. 3 3 9. 12 + 3 * 12 + 3* 12+3* 12 + 3* 12 +3* scanned scanned scanned scanned scanned Write a program that prompts the user to enter a postfix expression and evalu- ates it.arrow_forward(Algebra: perfect square ) Write a program that prompts the user to enter an integer m and find the smallest integer n such that m * n is a perfect square. (Hint: Store all smallest factors of m into an array list. n is the product of the factors that appear an odd number of times in the array list. For example, consider m = 90, store the factors 2, 3, 3, 5 in an array list. 2 and 5 appear an odd number of times in the array list. So, n is 10.) Sample Run 1 Enter an integer m: 1500 The smallest number n for m x n to be a perfect square is 15 m x n is 22500 Sample Run 2 Enter an integer m: 63 The smallest number n for m x n to be a perfect square is 7 m x n is 441 Class Name: Exercise11_17 Answer is : import java.util.Scanner; public class Squares { public static void main(String[] args) { Scanner scan = new Scanner(System.in); //instantiation of Scanner that will take inputs from the keyboard //the try catch block below is for trapping error with the input try {…arrow_forward
- 12) Fun With Mergesort. Given the recursive mergesort function below. Modify the msort function such that, msort calls msort for sub arrays with more than 1024 elements, and msort calls bsort for sub arrays with 1024 or less elements. Assume both functions operate on the same global array. int data[4294967296]; // REALLY BIG array void bsort (int f, int 1); // forward declaration void msort (int f, int 1) int m; if (f<1) { m - (f+1)/2; msort (f, m): msort (m+1,1): merge (f,m, 1);arrow_forward01. ""Implementation of the Misra-Gries algorithm.Given a list of items and a value k, it returns the every item in the listthat appears at least n/k times, where n is the length of the array By default, k is set to 2, solving the majority problem. For the majority problem, this algorithm only guarantees that if there isan element that appears more than n/2 times, it will be outputed. If thereis no such element, any arbitrary element is returned by the algorithm.Therefore, we need to iterate through again at the end. But since we have filtredout the suspects, the memory complexity is significantly lower thanit would be to create counter for every element in the list. For example:Input misras_gries([1,4,4,4,5,4,4])Output {'4':5}Input misras_gries([0,0,0,1,1,1,1])Output {'1':4}Input misras_gries([0,0,0,0,1,1,1,2,2],3)Output {'0':4,'1':3}Input misras_gries([0,0,0,1,1,1]Output None. """arrow_forward(a,b} u {} = {a,b} True False The order of the elements in a set is important True False The empty set is a subset of every other set True 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