Professional Documents
Culture Documents
Assignement DS1
Assignement DS1
Assignment 1
Fall 2020
You are given the following class of single linklist. You need to implement the functions
struct Node
{
int data;
Node*next;
};
class linklist
{
private:
Node*head;
Node*tail;
public:
linklist()
{
/*You Need to Implement this constructor function*/
}
linklist(linklist©)
{
/*You Need to Implement this copy constructor function*/
}
void insertatHead(int data)
{
/*You Need to Implement this function which will insert node at head(before
current head)*/
}
void insertatTail(int data)
{
/*You Need to Implement this function which will insert node at tail(after
current tail)*/
}
int removehead()
{
/*You Need to Implement this function which will remove head node and
return the value of head node*/
}
int removetail()
{
/*You Need to Implement this function which will remove tail node and
return the value of tail node*/
}
void insertinBetween(int data,int point)
{
/*You Need to Implement this function which will insert the node before the
a specific node (you need to search node with data==point) and insert before it*/
}
int deleteinBetween(int search)
{
/*You Need to Implement this function which will search and delete the node
with data==search */
}
void print()
{
/*You Need to Implement this function which will print data of all the
nodes */
}
};
Question 2:
Now convert the same linklist into doubly linklist. You need to implement each function as
specifies in Question 1. The struct code will be following.
struct Node
{
int data;
Node*next;
Node*prev;
};