Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Data Structure CSC-2077

Assignment 1

Fall 2020

Due Date: 11-March-2020


Question 1:

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&copy)
{
/*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 */
}

bool search(int searchData)


{
/*You Need to Implement this function which will search the node with
data==searchData and return true if found or else return false */
}

bool reverseList(int searchData)


{
/*You Need to Implement this function which will reverse the links of the
node (the tail of list become head). Dont use array for this purpose */
}

};

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;
};

You might also like