Assignment 1. Show what is produced by the following C++ code. Assume the node i
ID: 3543377 • Letter: A
Question
Assignment
1. Show what is produced by the following C++ code. Assume the node is in the usual info-link
form with the info of the type int. (list, trail, and current are pointers of type nodeType.)
list = new nodeType;
list -> info = 28;
trail = new nodeType;
trail -> info = 33;
trail -> link = list;
list -> link = NULL;
current = new nodeType;
current -> info = 62;
trail -> link = current;
current ->link = list;
list= trail;
current = list ->link;
trail = current -> link
cout << list -> info<<
Explanation / Answer
Dear,
Posted multiple questions answered 3 please do post remaining in another post.
1) Using this code the first 6 lines crates a creates two nodes as below :
Next a new node is created and added in between two nodes:
Next followed statements rearranges items and valuesand the output statement will display
28 62 28
3)
a)
current = new nodeType;
current -> info = 72;
current -> link = NULL;
b) trail=new nodeType;
trail->info = 43;
trail->link= current;
c) list= current;
current = new nodeType
current -> info = 8;
current -> link = NULL;
list-link=current;
d) current = new nodeType
current -> info = 12;
current -> link = trail;
4)
16
12
c. ptr = new nodeType;
ptr -> info = 45;
ptr -> link = list -> link -> link;
list -> link -> link = ptr;
d. ptr = new nodeType;
ptr -> info = 58;
ptr -> link = list;
list = ptr;
e. list = list -> link
Hope this will help you...