**Construct a binary tree using the following pre - order and in - order trasversals : Pre-order:ABGHMCDEF In-order:BHMGADFEC ** I Just Need a Diagram of Binary Tree . I have tried a lot with youtube tutorials but not getting the answer plz help.

Member Avatar
Member Avatar
+0 forum 2

I'm working on this code for class, I am not expecting anyone to do my homework but help would be appreciated. Nodes are confusing for me and my professor did not explain well. The errors I am getting are where I declare the functions, I dont know the nodeType(?) that goes in the arguments. Hopefully that makes sense.I think I may have also need to initialize the node? #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; ///employeeType struct, node struct, typedef statement go here. struct employeeType { int idNum; string firstName; string lastName; char gender; double payrate; …

Member Avatar
Member Avatar
+0 forum 1

Hello there. I recently have been teaching myself C++ and have come across something that I just can't seem to grasp. I undersatdn the basics of structures but when it comes to this nesting type situation I just can't figure out what is going on. If someone could explain in a somewhat simple manner it would help me greatly Here's the code: #include <iostream> using namespace std; struct sct { int t[2]; }; struct str { sct t[2]; }; int main(void) { str t[2] = { {0, 2, 4, 6}, {1, 3, 5, 7} }; cout << t[1].t[0].t[1] << t[0].t[1].t[0]; …

Member Avatar
Member Avatar
+0 forum 2

I want to convert this piece of code using this memory layout transformation : https://software.intel.com/en-us/articles/memory-layout-transformations (Array of Structures to Structure of Arrays) Here are the codes before and after applying the transformation and I want to know whether I'm doing it right or not? Before: typedef struct { double x; }str1; typedef struct { str1 v; }str2; int main(){ str2 *pointer; double y = pointer[1].v.x; return 0; } After: typedef struct { double x[1]; }str1; typedef struct { str1 v; }str2; int main(){ str2 pointer; double y = pointer.v.x[1]; return 0; }

Member Avatar
Member Avatar
+0 forum 3

I have searched these forums and have seen multiple threads on the Weather Structure C++ program. I don't believe they have been resolved. I am tasked with the following: Write a program that uses a structure to store the following weather data for a particular month: Total Rainfall High Temperature Low Temperature Average Temperature The program should have an array of 12 structures to hold weather data for an entire year. When the program runs, it should ask the user to enter data for each month. (The average temperature should be calculated.) Once the data are entered for all the …

Member Avatar
Member Avatar
+0 forum 6

#include<iostream.h> #include <stdlib.h> //FOR exit(1) struct Flight { char flightNo[5]; char date[12]; char time[6]; char gate[3]; }; Flight flight={"AB11","10-12-2008","20:30","RT"}; struct Seat { char name[40]; char booking_ID[3]; int seats; }; Seat choice[4][5]; void displaymenu(); void booking(); void seat(); void ticket(); void records(); void menu(); void exit(); //Variables int selection,i,j,password; int seats_num[20]={0}; int booking_ID=100; int seatsAvailable=20; int main(void) { displaymenu(); while(selection!=4) { menu(); } return 0; } void displaymenu() { cout<<"\n\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"; cout<<"\n\t% %\n"; cout<<"\t% Airline Booking System %\n"; cout<<"\t% ======================= %\n"; cout<<"\t% MENU %\n"; cout<<"\t% ======================= %\n"; cout<<"\t% 1.BOOKING %\n"; cout<<"\t% 2.SEAT %\n"; cout<<"\t% 3.RECORDS %\n"; cout<<"\t% 4.EXIT %\n"; cout<<"\t% %\n"; cout<<"\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\t"; …

Member Avatar
Member Avatar
-1 forum 2

Here's a little program i wrote, i'm trying to pass my structure book to function input. The code works fine on Code::Blocks but VS12 is giving an error on compliation " error C4700: uninitialized local variable 's' used ". What i'm doing wrong? #include <string.h> #include <iostream> using namespace std; struct book{ char title[20]; char author[20]; int price; }; book input(struct book); void display(struct book); book input(book details) { cout << "Book Title : "; gets_s(details.title); cout << "\nBook Author : "; gets_s(details.author); cout << "\nBook : Price : "; cin >> details.price; return details; } void display(book details) { …

Member Avatar
Member Avatar
+0 forum 1

need a program to perform polynomial division with linked lists or arrays. i already tried multiplication,subtraction and addition but stucked in division can anyone help me out on this.

Member Avatar
+0 forum 0

I have been asked to build a group of functions that carry out set theory operations such as intersection and union. The functions below that I must complete are set_intersectWith, set_unionWith, set_minusWith, set_powerset, where: > set_intersectWith = A ∩ B > set_unionWith = A ∪ B > set_minusWith = complement = A \ B > set_powerset = P(S) The following file is what I am working on, *set.c*: #include <assert.h> #include <stdlib.h> #include <stdio.h> #include "clist.h" #include "set.h" struct set_implementation { clist * items; printer item_printer; equals item_compare; }; set * new_set(printer item_printer, equals item_compare) { set * s = …

Member Avatar
Member Avatar
+0 forum 1

I'm having trouble with a couple of things in my program. I want to create 3 different players and then record their scores to a file called highScores.txt I need to also come up with another game that features an array in it (i would put this in the place that says //ARRAY GAME WITH point values here)...this game should just like the other two games have point values. Also, I tried creating one of the players and I get a compiling error that says: project2.cpp:131: error: ‘x’ was not declared in this scope project2.cpp:169: error: ‘x’ was not declared …

Member Avatar
Member Avatar
+0 forum 1

Hey everyone, I am taking an online C++ class and part of our assignment is to complete a whole bunch of small program snipits on a site called myprogramminglab.com. This one program seems to have me stumped as I am not very familiar with Data structures. Could someone help me out with this? > Assume that SREC has already been defined. Define a new type, ROSTER , that is a structure consisting of an int field, size , and another field, grades , that is an SREC array with 500 elements.

Member Avatar
Member Avatar
+0 forum 4

1. You are required to make a structure named “section”. The names of the two sections are secA and secB. 2. There are two members of this structure i.e. numberOfBoys and numberOfGirls. 3. In secA there are 48 boys and 6 girls while in secB there are 50 boys and 2 girls. 4. Write a function totalBoysAndGirls(). It takes two arguments by value. These arguments are the two section structures. Pass structures secA and secB to this function to calculate the total number of boys and total number of girls in the computer programming course and returns this sum in …

Member Avatar
Member Avatar
+0 forum 1

/*I'm having trouble creating a constructor for degree and *coeffs as well as properly creating the dynamic arrays for the coefficients of the 2 polynomials a and b. I'm just concerned about getting the correct values. My textbook only gives us eamples of constructos for eamples not well related to my HW question.Due tonight! any help would be much appreciated.*/ #include <iostream> #include <cstdlib> using namespace std; struct Polynomial { int degree; int *coeffs; Polynomial(); }; Polynomial* readPoly1(); Polynomial* readPoly2(); void outputPoly(Polynomial* p,char x); Polynomial* addPoly(Polynomial* a,Polynomial* b); Polynomial* multPoly(Polynomial* a,Polynomial* b); void deletePoly(Polynomial* &p); int main() { Polynomial *a; …

Member Avatar
Member Avatar
+0 forum 9

Hi everybody I am populating an array of structures with info for a product enquiry. <!--- ADD PRODUCT TO CART ARRAY ROUTINE---> <cfif IsDefined("btn_add")> <a href="%5C"> <cfset temp = arrayAppend(session.enquirycontents, structNew())> <cfset session.enquirycontents[arrayLen(session.enquirycontents)].ID = #form.ID#> <cfset session.enquirycontents[arrayLen(session.enquirycontents)].product = #productdetail.product#> <cfset session.enquirycontents[arrayLen(session.enquirycontents)].prodnum = #productdetail.prodnum#> <cfset session.enquirycontents[arrayLen(session.enquirycontents)].quantity = #form.Quantity#> <cfset session.enquirycontents[arrayLen(session.enquirycontents)].dimensions = #productdetail.dimensions#> <cflocation url="enquiryContents.cfm"> </a> </cfif> <!---FINISH ADDING TO CART ARRAY ROUTINE <!---FINISH ADDING TO CART ARRAY ROUTINE as i add each product i want to check that a product has not allready been entered (ID doesnt exist) i have tried all sorts of searches on the web but cant get …

Member Avatar
Member Avatar
+0 forum 5

I am currently in an introductory c++ class and am working assignment that sorts data. We recently covered structs and I decided to use structs to approach the problem rather than create 3 arrays to hold the information from our data file. The trouble i'm having is when i'm trying to pass my struct to my function. Here is my error: analyze_data.cpp: In function ‘int main()’: analyze_data.cpp:76: error: conversion from ‘weather*’ to non-scalar type ‘weather’ requested analyze_data.cpp: In function ‘int find_pos_of_smallest(weather, int, int)’: analyze_data.cpp:110: error: no match for ‘operator[]’ in ‘data[pos]’ analyze_data.cpp:110: error: no match for ‘operator[]’ in ‘data[pos_of_smallest]’ I …

Member Avatar
Member Avatar
+0 forum 1

hello everyone I was wondering if anyone could explain big-oh estimate to me for c++ data structures. I do not understand it that much and does anyone know of any good websites that have good information on c++ data structures i would greatly appreciate it. Also could anyone explain to me how to use big-oh estimate on the following problem. My prof gave this to us at the end of class saying he would explain how to do solve it the next class day but i have no idea how to do this, would greatly appreciate anyones help. thanks. the …

Member Avatar
Member Avatar
+0 forum 2

hey friends i need help once again... i need to know that how to accessing a structure in another function using pointers.i mean when we returning a pointer to the main function we have have the address of the structure.how to use that address to access the structure..pls guys help me.i'm still learning.:S

Member Avatar
Member Avatar
+0 forum 11

Hi, I am trying to write code to read a text file containing velocity vector data in the form x, y, u, v. An example of the data file I am opening is: 0 1.0 3.24 45.64 1.5 2.5 54.34 23.45 ... I have a function which can read the data file into an array of structures and display the values but I don't know how to access the array of structures in int main(). I am fairly new to C programming and giving it a go as Matlab is too slow for the files I'm trying to process (about …

Member Avatar
Member Avatar
+0 forum 3

Hi there, As the title says, I'm having an issue passing an array of structures to a function.The structure reads and tokenises information from a text file. I then need to do things with that data using several different functions. Here's my code: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{ char carID[4]; char carType[8]; int engineSize; char bodyType[9]; int numSeats; char transType[9]; int mileage; char available; } cars_t; int main() { cars_t cars[8]; char line[100]; char line2[100]; char *nextWordPtr; int count = 0; FILE *ptr_cars; ptr_cars = fopen("cars.txt", "r"); while ( fgets ( line, sizeof line, ptr_cars ) != …

Member Avatar
Member Avatar
+0 forum 3

Need help from daniweb community. I suck at programming. It doesn't make sense to me. I'm not going to be programming in my career but it's part of my major. I'm desperately trying to get an c- just to pass. Would love some help. I would appreciate some explanation but it is not necessarily needed. Given the following struct: typdef struct node { int data; struct node * left; struct node *right; }tNode, *treeNode; typedef struct list{ int data; struct list *next; }lNode, *listNode; First insert random numbers into the linked list listNode generateList ( listNode head, int size ); …

Member Avatar
Member Avatar
+0 forum 1

hello! i have written a program to read in a text file and then ask the user to process the file with a different sorting method. so far i have been able to get my program to read in the file but my bubble sort seems to not be sorting the elements right. ive tried thinking of as many solutions as possible but im not sure whats wrong.the text file looks like this 1 65 44 34 23 6 any help or ideas on where to start looking for the problem would be greatly appriciated. /****************************************************** * * Program3.cpp Author: …

Member Avatar
Member Avatar
+0 forum 2

Hello everyone, I have a program that intends to create a doubly linked list of structures, using the following header (q1.h): [CODE=c]typedef struct lNode* ListNodePtr; typedef struct lNode { char* string; ListNodePtr next; ListNodePtr prev; } ListNode; [/CODE] This is my implementation: [CODE=c]#include "q1.h" #include <stdio.h> #include <stdlib.h> #include <string.h> ListNodePtr tail = 0; ListNodePtr newNode(void); ListNodePtr addNode(ListNodePtr h, char *w); void printList(ListNodePtr h); void deleteNode(ListNodePtr h, char *w); ListNodePtr newNode(void) { ListNodePtr n; n = (ListNodePtr)malloc(sizeof(ListNode)); n->prev = 0; n->next = 0; return n; } ListNodePtr addNode(ListNodePtr h, char *w) { ListNodePtr a; if (h == 0 && tail …

Member Avatar
Member Avatar
+0 forum 30

Hey everyone, I wrote some code to create a deck of cards, described the deck and randomly deals 5 cards. First, I want to let everyone know that this is homework for my C-II college class, so I am not looking for any answers, but solutions or guidance in figuring out what I am trying to do. What I want to do with this deck of cards is to shuffle the deck and then deal 5 cards, while not dealing the same cards in that hand. IE: Program deals 5 cards. The 5 cards are as follow (I actually ran …

Member Avatar
Member Avatar
+0 forum 6

I have been having trouble developing a function that frees all of the memory associated with structs of a linked list. Im not asking for a clear cut answer, just an idea or a function that can aid. F.Y.I. the linked list contains a head struct and a tail struct to identify the Here's some code that might spark some thought: [CODE]void deleteAllStructs(void){ struct structTypeName listingPtr; do{ for(listingPtr=gHead;listingPtr->next!=NULL;listingPtr=listingPtr->next) ; listingPtr = NULL; while(gHead!=NULL); }[/CODE]

Member Avatar
Member Avatar
+0 forum 6

Hi everyone, I am doing on page optimization for one my client but I want to change the URL of my website without effecting the other navigations in the webpage. Here is the webpage that I need to be optimized [CODE]www.xxxxxxxxxx.com/what-we-do/managed-services/data-centre-services.php[/CODE] I need to change the above URL into [CODE]www.xxxxxxxxxx.com/data-centre-services.php[/CODE] I mean there are many other pages of which I want to remove these extra words "/what-we-do/managed-services/" from the URL's. Kindly help me by replying to my question with the required code to be used to resolve this issue. Regards Jaspal

Member Avatar
Member Avatar
+0 forum 3

Yo guys! How's it going? To give you a quick gist of my goals : I want to allow the user to enter a bunch of criteria for a book (title, author, etc) so I made a structure. Then I store that structure in an array so they can enter a bunch of books. Then I want to give them the option to sort that array (all their books) by a certain criteria like clicking album on itunes. Finally, I want to give them the option to see the average and total cost of their books. Needless to say I …

Member Avatar
Member Avatar
+0 forum 8

I'm having problems with my code all over. I have to be able to open a command line argument( which i know how to do). create a linked list, and print it backwards. This is what i have but im stuck with errors that i don't know how to fix. I don't have any errors in the insertNode function just main and printList. basically if the file i open is "ABC" , I need to print "CBA" header file: [CODE] #include <stdio.h> #define my typedef char KEY_TYPE; typedef struct { KEY_TYPE key; } DATA; typedef struct nodeTag { DATA data; …

Member Avatar
Member Avatar
+0 forum 6

I have a file of name PROFILES.DAT in which several records are stored. I want to create some new fields in those records so I made a new program to read the file, store records in a structure, copy the structure elements into a new structure and finally write the new structure to a file PROFILES2.DAT. The program does not reach the first while loop at line 60. Can anyone help me out? I have added the source code of the other program I used to edit the file PROFILES.DAT. [CODE] #include<iostream.h> #include<conio.h> #include<stdio.h> #include<stdlib.h> #include<string.h> long int recsize,recsize2; struct …

Member Avatar
Member Avatar
+0 forum 2

Hi folks, [CODE] int a=10,b=5,tmp; tmp=a; a=b; b=tmp; [/CODE] This is ordinary swap. I want to do this swap to the structure variables. And how to free the memory of tmp structure variable after swapping.

Member Avatar
Member Avatar
+0 forum 3

Hi, I haven't seriously written Java code in over 5 years. I am looking to find good online resources to help me refresh in a few weeks. Thanks! Marquita

Member Avatar
Member Avatar
+0 forum 3

The End.