Menu

(Solved) : Group 3 4 People Create Binary Tree Contain Internet Packet Following Data Items Id Number Q37185471 . . .

In a group of 3 or 4 people, create a binary tree that will contain an Internet Packet with the following data items ID numbeAn isEmpty function to check to see if the tree is empty A overloaded output operator to print the ID number, the Packets n#include #include <cmath> <cstring> int main() List listl; int i; int id[4]3400, 2800, 3600, 3000); char spd[ 65] -000000000

In a group of 3 or 4 people, create a binary tree that will contain an Internet Packet with the following data items ID number (long int) – used as the primary key for sorting in the binary tree Source’s IP address (32 characters) Destination’s IP address (32 characters) Packet’s total length in bytes (16 characters) Total number of packets in the transmission (16 characters) This packet’s number in the transmission (16 characters) The remaining data (unknown length – based on the length variable defined above) A long integer for the length (in bits) of the remaining data (so it does not have to be recalculated) Two pointers to the right and left nodes of the tree Suggested: a pointer that points back to the nodes parent and another long int that contains the total length (in bits) of the transmission * * . . * * * * * The data items above define the tree’s nodes. Each of the character arrays will need to be declared as pointers and then when the data is put in to the node, the memory will be created (using the new command). The tree node class will also contain the following public functions A constructor with two argument (the ID number and a reference to the entire array of characters in the packet – which will need to be separated out by this constructor) · . A destructor * Seven get functions (one for each of the data items defined above) * Two functions that return the right and left pointers called getRight() and getLeft) . And, it should include a definition as a friend to the List class * Suggested: include functions that will convert the packet’s total number of bytes from binary to decimal (note that this is a total number so you will need to subtract 14 bytes from this number to get the number of bytes that are in the remaining data – there are 8 bits in a byte) and a function that does the opposite of the getNode() function which rebuilds the entire array of transmission characters. Include another function that returns the address of the node’s parent. Also, remember to always include a NULL (10′) character at the end of each character array. The Tree class should contain the following items to set up the linked list A pointer to the top of the tree A getNode function that creates a new list node with a arguments of the ID number and of the Internet packet data A constructor to create a tree A copy constructor An insert function to insert a new node into the tree A remove function to remove a node from the tree * * » » An isEmpty function to check to see if the tree is empty A overloaded output operator to print the ID number, the “Packet’s number in the transmission” and the “length of the remaining data” (you will need to create a convert function – should be private or protected – that converts binary values to a long integer to print out the number in the transmission) * You can use the following class definitions (it includes a few of the suggested items) and a main program will be provided for you later this week #include #include <iostream> <cstring> class TreeNode ( protected: long int id; // ID number char *s //source char *d; //destination char len; //total length of packet in bytes char *n; //number of packets in message char *c //current number char all; //storage for all other characters in packet long int length; TreeNode *right; TreeNode *left TreeNode parent; public: TreeNode long int, const char * TreeNode ); long int getID char *getsrc ) char *getDest ); char *getLen (); char *getNpac ); char *getCnum (); char *getRest ); TreeNode *getRigh TreeNode *getLeft) TreeNode *getParent friend class Tree; class Tree protected: TreeNode *first; TreeNode last; TreeNode *getNode const char * ); long int convert); public: Tree) Tree ( const List& Tree (); void insert( const char * bool remove( bool isEmpty friend ostream & operator<< ostream &, Tree // Could also include recursive functions as necessary #include #include <cmath> <cstring> int main() List listl; int i; int id[4]3400, 2800, 3600, 3000); char spd[ 65] -“0000000000000000000000000000110100000000000000000000000000001011″; char lenl[17]”0000000000010000″ char len2[17]”0000000000010001″ char len3[17]”0000000000001111″; char len4[17]”0000000000010000”; char n[17] “0000000000000100”. = char c1[17] = “0000000000000001”; char c2 [17] = “0000000000000010”. char c317 “0000000000000011”; char c417 “0000000000000100”; char a1 11 [17]-“0000000000000101”; char al12[25] “000000000000000000000110” char al13[9″00000111″; char al14[17] “0000000000001000”. char al[200], a2[ 200], a3[200, a4200]; a1[0] = ”; a2 [ 0 ] = ”; strcat( al, spd strcat( al, lenl; strcat( al, n strcat( al, cli strcat( al, all1); strcat( a2, spd strcat( a2, len2 strcat( a2, n; strcat( a2, c2 strcat( a2, all2); strcat( a3, spd) strcat( a3, len3) strcat( a3, n) strcat( a3, c3); strcat( a3, all3); strcat( a4, spd strcat( a4, len4 strcat( a4, n); strcat ( a4, c4) strcat( a4, all4) cout < listl << endl; list1.insert( id[0], al); cout < listl << endl; listl.insert id[1], a2 cout << listl << endl; listl.insert( idl 3, a4)i cout << list1 << endl; listl.insert( id2, a3 cout << listl1 << endl; int x 3210; listl.remove( x cout < list1 << endl; x 2800; listl.remove( x); cout << listl << endl; cout << endl return 0; Show transcribed image text In a group of 3 or 4 people, create a binary tree that will contain an Internet Packet with the following data items ID number (long int) – used as the primary key for sorting in the binary tree Source’s IP address (32 characters) Destination’s IP address (32 characters) Packet’s total length in bytes (16 characters) Total number of packets in the transmission (16 characters) This packet’s number in the transmission (16 characters) The remaining data (unknown length – based on the length variable defined above) A long integer for the length (in bits) of the remaining data (so it does not have to be recalculated) Two pointers to the right and left nodes of the tree Suggested: a pointer that points back to the nodes parent and another long int that contains the total length (in bits) of the transmission * * . . * * * * * The data items above define the tree’s nodes. Each of the character arrays will need to be declared as pointers and then when the data is put in to the node, the memory will be created (using the new command). The tree node class will also contain the following public functions A constructor with two argument (the ID number and a reference to the entire array of characters in the packet – which will need to be separated out by this constructor) · . A destructor * Seven get functions (one for each of the data items defined above) * Two functions that return the right and left pointers called getRight() and getLeft) . And, it should include a definition as a friend to the List class * Suggested: include functions that will convert the packet’s total number of bytes from binary to decimal (note that this is a total number so you will need to subtract 14 bytes from this number to get the number of bytes that are in the remaining data – there are 8 bits in a byte) and a function that does the opposite of the getNode() function which rebuilds the entire array of transmission characters. Include another function that returns the address of the node’s parent. Also, remember to always include a NULL (10′) character at the end of each character array. The Tree class should contain the following items to set up the linked list A pointer to the top of the tree A getNode function that creates a new list node with a arguments of the ID number and of the Internet packet data A constructor to create a tree A copy constructor An insert function to insert a new node into the tree A remove function to remove a node from the tree * * » »
An isEmpty function to check to see if the tree is empty A overloaded output operator to print the ID number, the “Packet’s number in the transmission” and the “length of the remaining data” (you will need to create a convert function – should be private or protected – that converts binary values to a long integer to print out the number in the transmission) * You can use the following class definitions (it includes a few of the suggested items) and a main program will be provided for you later this week #include #include class TreeNode ( protected: long int id; // ID number char *s //source char *d; //destination char len; //total length of packet in bytes char *n; //number of packets in message char *c //current number char all; //storage for all other characters in packet long int length; TreeNode *right; TreeNode *left TreeNode parent; public: TreeNode long int, const char * TreeNode ); long int getID char *getsrc ) char *getDest ); char *getLen (); char *getNpac ); char *getCnum (); char *getRest ); TreeNode *getRigh TreeNode *getLeft) TreeNode *getParent friend class Tree; class Tree protected: TreeNode *first; TreeNode last; TreeNode *getNode const char * ); long int convert); public: Tree) Tree ( const List& Tree (); void insert( const char * bool remove( bool isEmpty friend ostream & operator

Expert Answer


Answer to In a group of 3 or 4 people, create a binary tree that will contain an Internet Packet with the following data items ID …

OR