0% found this document useful (0 votes)
15 views2 pages

Assignement DS1

This document provides instructions for an assignment on implementing functions for a single linked list and doubly linked list data structure. It includes code for Node and linklist classes, with comments specifying functions that need to be implemented for the single linked list, including constructors, insertion, deletion, printing, searching, and reversing functions. It then asks students to convert the single linked list to a doubly linked list, implementing the same functions.

Uploaded by

LuQman Asif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Assignement DS1

This document provides instructions for an assignment on implementing functions for a single linked list and doubly linked list data structure. It includes code for Node and linklist classes, with comments specifying functions that need to be implemented for the single linked list, including constructors, insertion, deletion, printing, searching, and reversing functions. It then asks students to convert the single linked list to a doubly linked list, implementing the same functions.

Uploaded by

LuQman Asif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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