Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 13.1, Problem 2STE
Suppose that your
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What will be the output if you send the address of the root node to the doSomething(TreeNode *root) function above.void TreeTraversal(TreeNode *root, void (*Visit) (TreeEntry x)) {if (root){Visit(root->entry);TreeTraversal(root->left, Visit);TreeTraversal(root->right, Visit);Visit(root->entry);}}void printOne(TreeEntry x){printf("%c\n", x);}void doSomething(TreeNode *root){TreeTraversal(root, printOne);}
What will be the output if you send the address of the root node to the doSomething(TreeNode
*root) function above.
void TreeTraversal(TreeNode *root, void (*Visit) (TreeEntry x))
{
if (root)
{
Visit(root->entry); TreeTraversal(root->left, Visit); TreeTraversal(root->right, Visit); Visit(root->entry);
}
}
void printOne(TreeEntry x)
{
printf("%c\n", x);
}
void doSomething(TreeNode *root)
{
TreeTraversal(root, printOne);
}
C++ please
Please,help me by providing C++ programing solution. Do not use the LinkedList class or any classes that offers list functions. Implement a LinkList in C++. Pease,implement with an ItemType class and a NodeType structThe program should read a data file,and the data file has two lines of data as follow:100, 110, 120, 130, 140, 150, 160100, 130, 160The program will first add all of the numbers from the file,then display all of them,then delete.
Chapter 13 Solutions
Problem Solving with C++ (9th Edition)
Ch. 13.1 - Suppose your program contains the following type...Ch. 13.1 - Suppose that your program contains the type...Ch. 13.1 - Prob. 3STECh. 13.1 - Prob. 4STECh. 13.1 - Prob. 5STECh. 13.1 - Prob. 6STECh. 13.1 - Prob. 7STECh. 13.1 - Suppose your program contains type definitions and...Ch. 13.1 - Prob. 9STECh. 13.2 - Prob. 10STE
Ch. 13.2 - Prob. 11STECh. 13.2 - Prob. 12STECh. 13.2 - Prob. 13STECh. 13 - The following program creates a linked list with...Ch. 13 - Re-do Practice Program 1, but instead of a struct,...Ch. 13 - Write a void function that takes a linked list of...Ch. 13 - Write a function called mergeLists that takes two...Ch. 13 - In this project you will redo Programming Project...Ch. 13 - A harder version of Programming Project 4 would be...Ch. 13 - Prob. 6PPCh. 13 - Prob. 8PPCh. 13 - Prob. 9PPCh. 13 - Prob. 10PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is the class access specification of the base class named below? class Pet : public Dog
Starting Out with C++ from Control Structures to Objects (8th Edition)
Multiple Stock Sales Use the method that you wrote for Programming Challenge 10 (Stock Profit) in a program tha...
Starting Out with Java: From Control Structures through Objects (6th Edition)
Modify your printDetai 1 s method to include printing the reference number. However, the method should print th...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Assume mystrinc references a string. Write a statement that uses a slicing expression and displays the first 3 ...
Starting Out with Python (4th Edition)
What is a well-encapsulated class definition?
Java: An Introduction to Problem Solving and Programming (8th Edition)
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (8th Edition)
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
- I ASK THIS QUESTION HERE AND YOUR EXPERT SOLVE IT THIS WAY BUT CAN YOU WRITE THE main ( ) FOR THIS CODE Consider the following implementation of the node and doubly linked-list: template <class type>class node{public:type info;node<type> * next;// nextnode<type> * prev;//back }; template <class type>class doubly_linked_list{//data membersprivate:node<type> *head, *tail;int length;public:doubly_linked_list(){head = tail = NULL;length = 0;}bool isEmpty(){ // return (head==NULL);if (head == NULL)return true;elsereturn false;} void Append(type e){node<type> *newnode = new node<type>;newnode->info = e;if (isEmpty()){newnode->next = NULL;newnode->prev = NULL;head = newnode;tail = newnode;}else{tail->next = newnode;newnode->prev = tail;newnode->next = NULL;tail = newnode;}++length; } void Display(){if (isEmpty()) { cout << "The linked list is empty !!!!"; return; }cout << "list elements: ";node<type> *…arrow_forwardYou are going to implement a program that creates an unsorted list by using a linked list implemented by yourself. NOT allowed to use LinkedList class or any other classes that offers list functions. It is REQUIRED to use an ItemType class and a NodeType struct to solve this. Use C++, please read instructions carefully and new solution only! The “data.txt” file has three lines of data 100, 110, 120, 130, 140, 150, 160 100, 130, 160 1@0, 2@3, 3@END You need to 1. create an empty unsorted list 2. add the numbers from the first line to list using putItem() function. Then print all the current keys to command line in one line using printAll(). 3. delete the numbers given by the second line in the list by using deleteItem() function. Then print all the current keys to command line in one line using printAll().. 4. putItem () the numbers in the third line of the data file to the corresponding location in the list. For example, 1@0 means adding number 1 at position 0 of the list. Then…arrow_forwardC++ What is the output of following function for start pointing to first node of following linked list? 1->2->3->4->5->6 void fun(Node<ItemType>* start) { if(start == nullptr) return; cout << start->getItem() << " "; if(start->getNext() != nullptr ) fun(start->getNext()->getNext()); cout << start->getItem() << " ";} eof.arrow_forward
- Question 10 Create a class that implements a compressed trie for a set of strings. The class should have a constructor that takes a list of strings as an argument, and the class should have a method that tests whether a given string is stored in the trie. JAVA PLZ! . . .arrow_forwardi need this code with java Code: #include <bits/stdc++.h>using namespace std; class node{ public: int data; node* left; node* right;}; void printGivenLevel(node* root, int level);int height(node* node);node* newNode(int data); void reverseLevelOrder(node* root){ int h = height(root); int i; for (i=h; i>=1; i--) printGivenLevel(root, i);} void printGivenLevel(node* root, int level){ if (root == NULL) return; if (level == 1) cout << root->data << " "; else if (level > 1) { printGivenLevel(root->left, level - 1); printGivenLevel(root->right, level - 1); }} int height(node* node){ if (node == NULL) return 0; else { int lheight = height(node->left); int rheight = height(node->right); if (lheight > rheight) return(lheight + 1); else return(rheight + 1); }} node* newNode(int data){ node* Node = new…arrow_forwardExplain and diagrammatically illustrate the given program. int main() { struct node *rootNode = newNode('A'); rootNode->left = newNode('K'); rootNode->right = newNode('L'); rootNode->left->left = newNode('P'); rootNode->left->right = newNode('Q'); rootNode->right->left = newNode('B'); rootNode->right->right = newNode('C'); rootNode->left->left->left = newNode('J'); rootNode->right->left->left = newNode('X'); rootNode->right->left->right = newNode('Y'); rootNode->right->right->left = newNode('Z'); display(rootNode); cout<<endl<<endl; Print_2D(rootNode,0); cout<<endl<<endl; Childs(rootNode,'A'); Childs(rootNode,'K'); Childs(rootNode,'L'); Childs(rootNode,'P'); Childs(rootNode,'Q'); Childs(rootNode,'B'); Childs(rootNode,'C'); cout<<endl<<endl; return 0; }arrow_forward
- Write a method that takes a pointer to a Node structure as a parameter and returns a complete copy of the passed in data structure. The Node data structure contains two pointers to other Nodes.arrow_forwardWrite three static comparators for the Point2D data typeof page 77, one that compares points by their x coordinate, one that compares them bytheir y coordinate, and one that compares them by their distance from the origin. Writetwo non-static comparators for the Point2D data type, one that compares them bytheir distance to a specified point and one that compares them by their polar angle withrespect to a specified point.arrow_forwardJava Code: Below are the methods for parser.java. Make sure to use the existing Parser.java file to add in all the methods and show the output. OperationNode: Has enum, left and Optional right members, good constructors and ToString is good VariableReferenceNode: Has name and Optional index, good constructors and ToString is good Constant & Node Pattern: Have name, good constructor and ToString is good ParseLValue - variables: Accepts a variable name and creates an appropriate Variable Reference Node ParseLValue - arrays: Accepts a name, appropriately gets an index and creates an appropriate Variable Reference Node ParseLValue - dollar: Creates an operation node, gets the value of the $ operator appropriately ParseBottomLevel – constants & patterns: Detects strings, numbers and patterns and creates appropriate nodes ParseBottomLevel – parenthesis: Creates an operation node AND gets the contents of the parenthesis appropriately ParseBottomLevel – unary operators: All…arrow_forward
- a. What does the function begin of the class linkedListType do?b. What does the function end of the class linkedListType do?arrow_forwardExplain and diagrammatically illustrate the given program. void display(node* r){ if(r==NULL) { return; } else { display(r->left); cout<<r->data<<" "; display(r->right); }}arrow_forwardWrite a function f1 that takes the root of a binary tree as a parameter and returns the sum of the nodes which are the right child of another node. The root of the tree is not a child of any node. Consider the following class definitions while writing your code. class Node { public: int key; Node* left; Node* right; };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
Introduction to Linked List; Author: Neso Academy;https://www.youtube.com/watch?v=R9PTBwOzceo;License: Standard YouTube License, CC-BY
Linked list | Single, Double & Circular | Data Structures | Lec-23 | Bhanu Priya; Author: Education 4u;https://www.youtube.com/watch?v=IiL_wwFIuaA;License: Standard Youtube License