Question: 4) 15 points. Linked Lists. Consider the linked list template class Node { public: Node(); Node(T value, Node * nextNode); T data; Node * next;

4) 15 points. Linked Lists.

Consider the linked list

template

class Node

{

public:

Node();

Node(T value, Node* nextNode);

T data;

Node* next;

};

template

class LinkedList

{

public:

LinkedList();

Node* getHead() const; // return the head pointer

Node* getTail() const; // returns the tail pointer

void listAppend(T value); // inserts an element at the end of the list

void listPrepend(T value); //inserts a n element at the head of the list

void insertAfter(Node* curNode, T value); // Insert value after the curNode

void removeAfter(Node* curNode); // remove Node after CurNode

void removeHead(); // Removes the first element

void removeTail(); // removes the last element

void printList() const; // print the elements of the linked list

private:

Node* head;

Node* tail;

};

Write a template function that receives the head node of a singly Linked list void printEven(Node * i). The function goes through the list and prints all the even elements in the list.

template // may use for the type T. T is assumed to be int

void LinkedList::PrintEven(Node* i)

{

// Your code goes here.

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!