Suppose that your
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
Problem Solving with C++, Student Value Edition Plus MyLab Programming with Pearson eText - Access Card Package (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with Python (4th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
- 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
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning