int doo(node*root){ if(root !=0 ) { if(root->left==0 && root->right==0) return root->data; int L=doo(root->left); int R=doo(root->right); if(L>R) return R; else return L;} } this code used for a. the maximum item in the leaves of a binary tree b. find the minimum item in the leaves of a binary tree c. find the sum of leaves items in a binary tree d. find the minimum item in a binary tree
Q: t the following problem in the main case 0 (see attached photo) Your algorithm for the hierarchy…
A: Deque (doubly ended queue) is a linear data structure(i.e. it stores data in a sequential manner),…
Q: FUNCTION: str_search DESCRIPTION: takes two C strings: a "source string" s[] and a "pattern string"…
A: Given, We have to implement a c program which checks whether the pattern string is substring of…
Q: Multiple choice in data structures If the list is array based class, L1 is an object of the class…
A: If the list is array based class, L1 is an object of the class list, the best code used to empty L1…
Q: Data structures HW3 Q1. Consider the code for displayList() function shown below: void…
A: (a).
Q: Code Segment struct node { int val; struct node *Left; struct node *Right; } }; void tree_walk…
A: 1 st number in the tree-walk sequence is 5. 1 st number in the tree-walk sequence is 12. 1 st number…
Q: C++ PROGRAMMING Topic: Binary Search Trees Explain the c++ code below.: SEE ATTACHED PHOTO FOR THE…
A: Binary search tree is a sorted binary tree in that all nodes has some properties they are:: 1.All…
Q: Data structure & alogrithum java program Create a corresponding DRIVER/Tester class that performs…
A: Java Programming Creating instance of Deque Containing list of string data type Check if deque is…
Q: Task: Complete the function getMinDepth(Node *root), the function takes the root of a tree and…
A: Complete the function getMinDepth(Node *root), the function takes the root of a tree and returns the…
Q: q5) If you are developing an application in which data is dynamic and will be defined at the time…
A: The question asked is about the dynamic memory allocation to store the data. In each and every…
Q: Hi everyone, can somone help me with this Programming Assignment from Data Structures. Thank you.…
A: public class Node{ public int data; public Node next; public Node previous; } public…
Q: 1. Struct (Optional: 1 point) 1) Use the following abstract data type called Rectangle to get the…
A: Solution: Given, struct Rectangle{ float length; float width; float area;…
Q: plain the flow of the code. See attached photo for the problem. (This is not graded) int…
A: The given problem is related to C++ progamming that has the methods of linked list implemented in…
Q: Write a struct ‘Student’ that has member variables: (string) first name, (int) age and (double) fee.…
A: Code: #include<iostream>using namespace std; //Declare Nodestruct Student{ string…
Q: /* Remove node index 0, node index 2 and index 4 from the list*/ //Add your code here
A: Answer: public void deleteEven() { public Node head; if (this.head == null)…
Q: Q.4.1 Identify and differentiate between the two (2) types of selection structures. Q.4.2 If a…
A: two (2) types of selection structures are: if and nested if if checks only one condition but nested…
Q: Suppose the count variable was not used in the CircularArrayQueue class. Explain how you could use…
A: Given Suppose the count variable was not used in the CircularArrayQueue class. Explain how you could…
Q: SUBJECT: PROGRAMMING FUNDAMENTELS LAB IT provides best solutions for manual work that makes life…
A: Given: SUBJECT: PROGRAMMING FUNDAMENTELS LAB IT provides best solutions for manual work that makes…
Q: A co-worker emails you and said she developed a recursive version for doing search in a binary…
A: A binary search tree(BST) is a data structure in which every node consists of 0, 1, or a maximum of…
Q: ude using namespace std; struct node { public: int data; node* left; node* right; };
A: Pre-order traversal A preorder traversal is a traversal approach that follows the Root Left Right…
Q: Complete the following missing code: void insert_after(int key, int value) { node *myNode =new node;…
A: Void insert_after(int key, int value){node *myNode =new node;myNode=head;int flag =…
Q: You are required to implement the following functions using the Last In First Out data structure.…
A: Program Code:- #include <bits/stdc++.h> #include <iostream> using namespace std; class…
Q: Explain and diagrammatically illustrate the given program. int main() { struct node *rootNode…
A: The first few lines are used to create a binary tree. It looks like this The line…
Q: node* findNewRoot(node* curr) { if(curr->left == NULL) { return curr;…
A: Binary Search Tree: Binary Search tree is a collection of nodes that which are arranged in ordered…
Q: Movie search system that displays actors and information about the movie. If you search for an…
A: Whenever аn element is tо be seаrсhed, stаrt seаrсhing frоm the rооt nоde. Then if…
Q: #include using namespace std; third->data = 9; third->next = second; %3D class Node { SQutdatac";…
A: Given: To correct the given code and compile and run it.
Q: c++ programming Complete all these 2 methods for the node Node methods •int get_depth(): Returns…
A: Program in C++ to calculate height and depth of the tree.
Q: class Node{ public: int data; Node* left; Node* right; Node (int key) { data = key; %3D left = NULL;…
A: Program approach:- Using the necessary header file. Using the standard namespace I/O. Declaring…
Q: //iterator() creates a new Iterator over this list. It will //initially be referring to the first…
A: SUMMARY: - hence we discussed all the points.
Q: Modify the given code in C Language to act as given in the example: MyCommand: hello world…
A: 1. add the function print to traverse through elements.2. using if point to the other node.3. print…
Q: Programming Language: C++ I need the codes for arrayListType.h, main.cpp, myString.cpp, myString.h
A: arrayListType.h arrayListType.h #ifndef H_arrayListType #define H_arrayListType class…
Q: C++ PROGRAMMING Please implement these 2 methods for the node where: int get_depth(): -…
A: struct node { node* parent; node* right; node* left; int element; int get_depth() {…
Q: Complete the function that computes the length of a path that starts with the given Point. The Point…
A: The complete code is below with output .
Q: What are the consequences of writing selection structures to include an unnecessary nested selection…
A: Given: What are the consequences of writing selection structures to include an unnecessary nested…
Q: Create a class "Person" with three member variables string first name, string last name, int age.…
A: Sample Response: #include <iostream>using namespace std;//Person class definitionclass…
Q: lain each line by adding comments #include using namespace std; class Node { public: int value;…
A: The below code is an implementation of operations on Binary Search Tree such as creating, inserting,…
Q: Answer the question based on the node structure shown below. There are two different node…
A: We can see in the node structure that there are 2 types of marks given. I have written a python code…
Q: ould be the elements 42, 13 and 5. Before starting to write code for this function, you should…
A: Source Code: def count_dominators(items): count=0 for i in range(0,len(items)-1):…
Q: What statement is the most appropriate for the following f1 function? template int…
A: Answer: The function is used to calculate the number of left children using statement…
Q: in the nead of the ist anu uie typedef struct node { int num; struct node* next; } node; int…
A:
Q: mplement
A: Deque (doubly ended queue) is a linear data structure(i.e. it stores data in a sequential manner),…
Q: C
A: Explanation: The seat matrix is represented by a 2-D character list, with the first column…
Q: Create a class Node having two data members int data; Node next; Write the parametrized…
A: import java.io.*; /* Main class of Linked list */public class LinkList { Node head; // head of…
Q: There is no arrayTree or testTreeADT description!!!!! 1. Problem Description You are to develop a…
A: The program is written in java class ArrayTree<E>{ public E[] a; int count; int size; int…
Q: Given the following linked list where each node has a data I link field & uses he painters…
A: curr replaced with temp: public class list { protected Node head ; Protected int size ; Public Node…
Q: Define the rule echo(LST0, LST1). This rule describes LST1, which holds all the same elements as…
A: Introduction Define the rule echo(LST0, LST1). This rule describes LST1, which holds all the same…
Q: (Plot the cube function) Write a program that draws a diagram for the functionf(x) = x3 (see Figure…
A: Create a Polyline in JavaFX To draw a polyline in JavaFX, first, write a class that derives the…
Q: Re-write Sample Program 11.2 so that it works for an array of structures. Write the program so that…
A: #include<iostream>#include<iomanip>#include<cmath> using namespace std; //declare…
Q: The Int is stored as an amay of emplovee t type structures employee temployeelist MAX COMPANY SIZE…
A: I have written c code for the following question:
Multiple choice in data structures
int doo(node<int>*root){
if(root !=0 ) {
if(root->left==0 && root->right==0) return root->data;
int L=doo(root->left);
int R=doo(root->right);
if(L>R) return R; else return L;}
}
this code used for
the maximum item in the leaves of a binary tree
find the minimum item in the leaves of a binary tree
find the sum of leaves items in a binary tree
find the minimum item in a binary tree
Step by step
Solved in 2 steps
- Debug C language main() { int num, rem, reverse_num, temp, start = 70, end = 100; for(num=start;num=end;num--) { temp=num; reversenum=0; while(temp) { rem=temp%10; temp==temp/10; reverse_num=reverse_num*10+rem; } if(num=reverse_num) printf("%c ",num); } }#include Servo servo; int const trigPin = 9; int const echoPin = 8; #define red 5 #define green 6 void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(red,OUTPUT); pinMode(green,OUTPUT); servo.attach(10); } void loop() { int duration, distance; digitalWrite(trigPin, HIGH); digitalWrite(trigPin, LOW);// Measure the pulse input in echo pin duration = pulseIn(echoPin, HIGH);// Distance is half the duration devided by 29.1 (from datasheet) distance = (duration/2) / 29.1;// if distance less than 0.5 meter and more than 0 (0 or less means over range) if (distance = 0) { servo.write(60); digitalWrite(green,HIGH); digitalWrite(red,LOW); delay(200); } else { servo.write(10); digitalWrite(red,HIGH); digitalWrite(green,LOW); delay(80); } } TASK: create a flowchart using this code, showing the input, output and the conditions on the loop. Lastly, the flowchart must return if ever the conditions have met or notC++ Program #include <iostream>#include <cstdlib>#include <ctime>using namespace std; int getData() { return (rand() % 100);} class Node {public: int data; Node* next;}; class LinkedList{public: LinkedList() { // constructor head = NULL; } ~LinkedList() {}; // destructor void addNode(int val); void addNodeSorted(int val); void displayWithCount(); int size(); void deleteAllNodes(); bool exists(int val);private: Node* head;}; // function to check data exist in a listbool LinkedList::exists(int val){ if (head == NULL) { return false; } else { Node* temp = head; while (temp != NULL) { if(temp->data == val){ return true; } temp = temp->next; } } return false;} // function to delete all data in a listvoid LinkedList::deleteAllNodes(){ if (head == NULL) { cout << "List is empty, No need to delete…
- Consider the following code. handler () {;} main () { struct sigaction actA, actB; sigset t oldset; sigset_t addset; sigemptyset (&addSet); sigaddset (&addset,SIGUSR1); sigprocmask (SIG BLOCK, &addset,&oldset); //-- Not using oldset here actA. sa handler=handler; actA. sa flags=0; sigemptyset(&actA.sa mask) ; sigaction (SIGTERM, &actA, (struct sigaction *) 0); Select all the signals that will be blocked during the execution of handler() after the successful execution of this code. O SIGUSR1 O SIGUSR2 O SIGTERMModify 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 =…Recursive Descent subprogram with EBNF rule, using C or Java syntax (syntax) Type (Recursive-Descent Subprogram): -> while () ; The lex method to be used reads a single lexeme, and the lexemes' token code is in the nextToken variable is to the left. Suppose that the defined tokens are respectively: while - WHILE_CODE left parantex - LEFTPAREN_CODE right parenthesis - RIGHTPAREN_CODE semicolon - SEMICOLON_CODE If any error is caught, create the function that calls the error function.
- c++ programming Complete all these 2 methods for the node Node methods •int get_depth(): Returns the depth of the node. •int get_height(): Returns the height of the node. Initial code to be completed:struct node { node* parent; node* right; node* left; int element; int get_depth() { return 0; } int get_height() { return 0; }};Weighted Job Scheduling in C language only please Problem statement: You are given a list of jobs where each job has a start time, finish time, and the profit associated with that job, find the maximum profit subset of non-overlapping jobs. Problem description: The problem wants you to find the maximum profit that you can make after performing a certain number of jobs such that each job has a certain condition that you can start a job only if the start time of the current job is greater than the finish time of the previous job. You are required to develop some algorithm such that the job start time and the finish time does not coincide with other jobs. Output: (Attached photo)Please convert the code to C language //separate chaining#include <bits/stdc++.h>using namespace std; class node {public: int data; node* next; node() { data = 0; next = NULL; } node(int x) { data = x; next = NULL; }}; node* add(node* head, int data){ if (head == NULL) { head = new node(data); return head; } node* temp = head; while (temp->next) { temp = temp->next; } temp->next = new node(data); return head;} void print(node* head){ if (!head) { cout << "NULL\n"; return; } node* temp = head; while (temp) { cout << temp->data << "->"; temp = temp->next; } cout << "NULL\n";} int main(){ //set of input numbers vector<int> arr{ 123, 456, 763, 656, 908, 238, 231 }; //initialize the hash table //each entry of the hash table is a linkedlist vector<node*> hash(10); //size of…
- int machineCompare1(struct machine* mac1, struct machine* mac2){ struct mac1; struct mac2; char make1[21], make2[21]; char model1[51], model2[21]; if((lap1 -> make1 == lap2 -> make2) && (lap1 -> model1 == lap2 -> model2)) return 0; else return 1;} have to create function to compare make and model of 2 machines - it's using structures - not sure if this is correct/ on the right track?Weighted Job Scheduling in C language Problem statement: You are given a list of jobs where each job has a start time, finish time, and the profit associated with that job, find the maximum profit subset of non-overlapping jobs. Problem description: The problem wants you to find the maximum profit that you can make after performing a certain number of jobs such that each job has a certain condition that you can start a job only if the start time of the current job is greater than the finish time of the previous job. You are required to develop some algorithm such that the job start time and the finish time does not coincide with other jobs.please convert to C languange #include<bits/stdc++.h>using namespace std; class tree{ //tree node public: int data; tree *left; tree *right;}; bool hasRootToLeafSum(tree *root, int s){ bool path=false; //declare boolean variable path //base condition checking if(root==NULL && s==0) return true; s-=root->data; //subtract current root value //checking whether leaf node reached and remaining sum =0 if(s==0 && root->left==NULL && root->right==NULL) return true; //recursively done for both subtrees if(root->left){//for left subtree path=path||hasRootToLeafSum(root->left, s); } if(root->right){//for right subtree path=path||hasRootToLeafSum(root->right, s); } return path;} tree* newnode(int data){ //creating new nodes tree* node = (tree*)malloc(sizeof(tree)); node->data = data; node->left = NULL; node->right = NULL;…