Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 19, Problem 8RQE
Program Plan Intro
Binary Tree:
Binary tree is a non-linear data structure which contains the node such as root node that is pointed to two child nodes. A root node will have left reference node and right reference node.
A complete binary tree is a tree with the property that every node must have exactly two children, and in the last level the nodes should be from left to right.
The analog for binary tree is given below:
struct NodeName
{
int value;
NodeName *left;
NodeName *right;
};
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A dequeue is a list from which elements can be inserted or deleted at either end
a. Develop an array based implementation for dequeue.
b. Develop a pointer based implementation dequeue.
5. Assume the following definition for a node of a binary tree.
public class Node {
public int data;
public Node left; public Node right;
public Node (int d) { data = d; left = null; right = null; }
}
(a) Write a recursive function height (Node root) which calculates and returns the height
of the binary tree rooted at the given root node.
public static int height (Node root) {
}
(b) Consider the following recursive function:
public static void fun (int a, int b, int c)
int d - 3 - (b + c);
if (a > 1) fun (a-1, ь, d);
System.out.println (a + "
" + b +"
" + c) ;
if(a > 1) fun (a-1, d, c);
What is the output generated by calling: fun (3, 0, 2)?
Answer:
Write JAVA code
General Problem Description:
It is desired to develop a directory application based on the use of a double-linked list data structure, in which students are kept in order according to their student number. In this context, write the Java codes that will meet the requirements given in detail below.
Requirements:
Create a class named Student to represent students. In the Student class; student number, name and surname and phone numbers for communication are kept. Student's multiple phones
number (multiple mobile phones, home phones, etc.) so phone numbers information will be stored in an “ArrayList”. In the Student class; parameterless, taking all parameters and
It is sufficient to have 3 constructor methods, including a copy constructor, get/set methods and toString.
Chapter 19 Solutions
Starting Out with C++: Early Objects (9th Edition)
Ch. 19.1 - Prob. 19.1CPCh. 19.1 - Prob. 19.2CPCh. 19.1 - Prob. 19.3CPCh. 19.1 - Prob. 19.4CPCh. 19.1 - Prob. 19.5CPCh. 19.1 - Prob. 19.6CPCh. 19.2 - Prob. 19.7CPCh. 19.2 - Prob. 19.8CPCh. 19.2 - Prob. 19.9CPCh. 19.2 - Prob. 19.10CP
Ch. 19.2 - Prob. 19.11CPCh. 19.2 - Prob. 19.12CPCh. 19 - Prob. 1RQECh. 19 - Prob. 2RQECh. 19 - Prob. 3RQECh. 19 - Prob. 4RQECh. 19 - Prob. 5RQECh. 19 - Prob. 6RQECh. 19 - Prob. 7RQECh. 19 - Prob. 8RQECh. 19 - Prob. 9RQECh. 19 - Prob. 10RQECh. 19 - Prob. 11RQECh. 19 - Prob. 12RQECh. 19 - Prob. 13RQECh. 19 - Prob. 14RQECh. 19 - Prob. 15RQECh. 19 - Prob. 16RQECh. 19 - Prob. 17RQECh. 19 - Prob. 18RQECh. 19 - Prob. 19RQECh. 19 - Prob. 20RQECh. 19 - Prob. 1PCCh. 19 - Prob. 2PCCh. 19 - Prob. 3PCCh. 19 - Prob. 4PCCh. 19 - Prob. 5PCCh. 19 - Prob. 6PCCh. 19 - Prob. 7PCCh. 19 - Prob. 8PCCh. 19 - Prob. 9PCCh. 19 - Prob. 10PC
Knowledge Booster
Similar questions
- Read this: Complete the code in Visual Studio using C++ Programming Language - Give me the answer in Visual Studio so I can copy*** - Separate the files such as .cpp, .h, or .main if any! Develop a C++ "doubly" linked list class of your own that can hold a series of signed shorts Develop the following functionality: Develop a linked list node struct/class You can use it as a subclass like in the book (Class contained inside a class) You can use it as its own separate class Your choice Maintain a private pointer to a node class pointer (head) Constructor Initialize head pointer to null Destructor Make sure to properly delete every node in your linked list push_front(value) Insert the value at the front of the linked list pop_front() Remove the node at the front of the linked list If empty, this is a no operation operator << Display the contents of the linked list just like you would print a character string operator [] Treat like…arrow_forwardModify the given code to accept float instead of int as a coefficient in C LANGUAGE: // Node structure containing power and coefficient of// variablestruct Node {int coeff;int pow;struct Node* next;}; // Function to create new nodevoid create_node(int x, int y, struct Node** temp){struct Node *r, *z;z = *temp;if (z == NULL) {r = (struct Node*)malloc(sizeof(struct Node));r->coeff = x;r->pow = y;*temp = r;r->next = (struct Node*)malloc(sizeof(struct Node));r = r->next;r->next = NULL;}else {r->coeff = x;r->pow = y;r->next = (struct Node*)malloc(sizeof(struct Node));r = r->next;r->next = NULL;}} // Function Adding two polynomial numbersvoid polyadd(struct Node* poly1, struct Node* poly2,struct Node* poly){while (poly1->next && poly2->next) {// If power of 1st polynomial is greater then 2nd,// then store 1st as it is and move its pointerif (poly1->pow > poly2->pow) {poly->pow = poly1->pow;poly->coeff = poly1->coeff;poly1 =…arrow_forwardconst int MAX = 10000; class enum errorCode (underflow, overflow, success); class Stack ( public: Stack () ({ count = 0; } errorCode top(int &) const; errorCode pop (); errorCode push (int) const; private: int count; on int entry[MAX]; Write the following functions that do not belong to the class: (a) Function int size(Stack &s) leaves the Stack s unchanged and returns a count of the number of entries in the Stack, (b) Function void deleteAll(Stack &s, stackEntry x) deletes all occurrences (if any) of x from s and leaves the remaining entries in s in the same relative order.arrow_forward
- Double pointers: Describe how this operation can be done in O(1) time if there are pointers in each node to both the previous and the next node.arrow_forwardConsider the following C declaration: struct Node{ char c; double value; struct Node* next; int flag; struct Node* left; struct Node* right; typedef struct Node* pNode; /* NodeTree is an array of N pointers to Node structs */ pNode NodeTree[N]; Q5.1 How many total bytes of padding are contained in a single object of type Node? Enter your answer herearrow_forwardFor C++ please just need cpp filearrow_forward
- Please convert the code in C language #include <bits/stdc++.h>using namespace std; class Node{ public: int data; //value Node *left; //pointer to left child Node *right; //pointer to right child}; // creating new nodeNode* newnode(int data) { Node* node = (Node*)malloc(sizeof(Node)); node->data = data; node->left = NULL; node->right = NULL; return(node); } Node* LCA(Node *root, int n1, int n2){while(true){ if((root->data>=n1 && root->data<=n2)||(root->data<=n1 && root->data>=n2)) return root; if(n1<root->data) root=root->left; else root=root->right; }} int main(){ cout<<"tree is built as per 1st example\n"; Node *root=newnode(8); root->left= newnode(4); root->right= newnode(10); root->right->right=newnode(11); root->right->left=newnode(9); root->left->left=newnode(3);…arrow_forwardWithout using C++ queue STL, write a simple menu based selection to insert, delete, show and exit from queue. 1. Create a class called Queue with member variable queueArr as integer queue array, integer rear and integer front to keep track both rear and front element in the queue array.2. Define several member functions in Queue such as: a) constructor – initialize both rear and front to -1 b) insert – receive an integer and check if queue is full, if not then insert the integer to the queue array c) delete – delete front element from queue if front is not equal to rear (empty)d) display – if rear is not equal to front, then print out the queue array. 3. Write a main function to test the Queue class.arrow_forward1. Complete the function evaluate_postfix(String exp): Input: "10 23 - 5 15 + +" Retur: 7 Node.java public class Node {Object info;Node next;Node(Object info, Node next){this.info=info;this.next=next;}}// "((1+2)"// ['(','(','1','+','2',')']// stack : ')' -> '2' -> '1' -> '(' -> '(' -> null Stack.java public class Stack {private Node top;public Stack() {top = null;}public boolean isEmpty() {return (top == null);}public void push(Object newItem) {top = new Node(newItem, top);}public Object pop() {if (isEmpty()) {System.out.println("Trying to pop when stack is empty");return null;} else {Node temp = top;top = top.next;return temp.info;}}void popAll() {top = null;}public Object peek() {if (isEmpty()) {System.out.println("Trying to peek when stack is empty");return null;} else {return top.info;}}} Runner.java public class Runner {public static void main(String[] args) {String expression1 = "((1+2)))))+(2+2))(1/2)";boolean res =…arrow_forward
- python assignment Matrix class Implement a matrix class (in matrix.py). a) The initializer should take a list of lists as an argument, where each outer list is a row, and each value in an inner list is a value in the corresponding row. b) Implement the __str__ method to nicely format the string representation of the matrix: one line per row, two characters per number (%2d) and a space between numbers. For example: m = Matrix([[1,0,0],[0,1,0],[0,0,1]]) print(m)> 1 0 0> 0 1 0> 0 0 1 c) Implement a method scale(factor) that returns a new matrix where each value is multiplied by scale. For example: m = Matrix([[1,2,3],[4,5,6],[7,8,9]])n = m.scale(2)print(n)> 2 4 6> 8 10 12>14 16 18print(m)> 1 2 3> 4 5 6> 7 8 9 d) Implement a method transpose() that returns a new matrix that has been transposed. Transposing flips a matrix over its diagonal: it switches rows and columns. m = Matrix([[1,2,3],[4,5,6],[7,8,9]])print(m)> 1 2 3> 4 5 6> 7 8…arrow_forwardComputer Science JAVA Write a program that maintains the names of your friends and relatives and thus serves as a friends list. You should be able to enter, delete, modify, or search this data. You should assume that the names are unique. use a class to represent the names in the friends list and another class to represent the friends list itself. This class should contain a Binary Search Tree of names as a data field. (TreeNode Class BinarySearchTree Class FriendsList Class)arrow_forwardIn c++ Also add comments explaining each linearrow_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