Question: You are to implement a Linked List that has the following interface: insertAtStart(data) insertAtEnd(data) Search(key) Delete(key) Data is key/value fields for example in a Student
You are to implement a Linked List that has the following interface:
insertAtStart(data)
insertAtEnd(data)
Search(key)
Delete(key)
Data is key/value fields for example in a Student type of data RollNo is the key or identifying field And all other data fields like name and address and session are value fields. All these fields combine to form the data. (Note that for search and delete all we need from the user is the key field.) Your Linked List must accommodate Student type of data.
class LinkedList{
//This class will only have the address of the first node in the List because if you have that you //
can reach any other node in the list by the next pointers in the node
Node * head;
//The head is only a place to hold the address of a node it does not mean that there is space //
for a Node object that is created. Make sure to make a Node object on heap (using new) //and then assign the address of this node to head pointer.
/*The functions or interface will come here .
insertAtStart(data)
insertAtEnd(data)
Search(key)
Delete(key) */
};
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
