Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

COMP 53 Midterm Two Spring Semester 2018 6) 16 points) Given the following quest

ID: 3701864 • Letter: C

Question

COMP 53 Midterm Two Spring Semester 2018 6) 16 points) Given the following questions. You do class: NoThave the linked list elas avaliable aind must use the Node template questions. Yoode template class that we used during lecture, write the code for the the template cclass T class Node ( Node() T getData): Node getNext); void setData(T item) void setNext (Noden); private: T data; Node "next; public: Node(): Node(T item, Noden); Define variables to dynamically allocate four integer Nodes. The integer values are 2, 3, 6, and 8. Node 2 should point to node 3. Node 6 points to 8. Resulting lists would look like this (2,3) and 6, 8). a. ine two "super nodes" using the template Node such that the two lists from part (a) are contained in the new nodes. Link the first super node to point to the second one. The resulting list would look like {2,3), (6,83 3. Remember that the template T substitution is not limited to a simple data type.

Explanation / Answer


Aswer a.
Node<int> a(3);
Node<int> b(2, a); /
/ Node with value 2 points to node 3

Node<int> c(8);
Node<int> d(6, c);
// Node with value 6 points to node 8

Answer b.
// we declare a node of Node<int>, so it means a node contains another node within it..
// pointer d is a list like 6 -> 8
// pointer b is a list like 2 -> 3

// Now we will create a Node<Node<int>> and put the last List <6, 8> into it..
// then we will similarly create a node to contain <2, 3> and point its next to the earlier Node<Node<int>> type
Node<Node<int>> lastNode(d);
Node<Node<int>> firstNode(b, d);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote