Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

Assignment No.

01 Total Marks: 20
Semester Fall 2019
Due Date : 18-Nov-2019
CS301- Data Structures
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (zero marks) if:
o The assignment is submitted after due date.
o The submitted code does NOT compile.
o The submitted assignment is other than .CPP file.
o The submitted assignment does NOT open or file is corrupted.
o The assignment is copied (from other student or ditto copy from handouts or internet).
Uploading instructions
For clarity and simplicity, You are required to Upload/Submit only ONE .CPP file.

Note: Use ONLY Dev-C++ IDE.


Objective
The objective of this assignment is

o To make you familiar with implementing the Doubly Linked List data structure in C++ programming
language.

For any query about the assignment, contact at cs301@vu.edu.pk

GOOD LUCK
Marks: 20
Problem Statement:

You have to implement a Double Linked List in C++ language in which you have to create a structure and two classes
as given below:
1. A structure named as “StudentDetail” by using struct keyword.
StudentDetail structure should consist of following data members of type “string”.
name
vuid

2. A node class named as “Node” by using class keyword.


Node class will have following data members and member functions:

Data Members Descriptions


newStd newStd is a variable of type StudentDetail.
prev prev is a pointer of type Node and will point to previous node in doubly linked list.
next next is a pointer of type Node and will point to next node in doubly linked list.

Methods Descriptions
set(X) Set the value of data in a Node.
get() Get all data values in Node
setNext(Y) Set the value of “next” data member and point to next node otherwise point to
NULL (if no next node).
getNext() Get the address of next node.
setPrev(Y) Set the value of “prev” data member and point to previous node otherwise point to
NULL (if no previous node).
getPrev() Get the address of previous node.

(“X” denotes StudentDetail variable means the student details and “Y” denotes the data value of the node).

3. A doubly linked list class named as “DoublyLinkedList” by using class keyword.


DoublyLinkedList class will have following data members and member functions:

Data Members Descriptions


headPtr headPtr is a pointer of type Node and will point to head node of the doubly
linked list.
curPtr curPtr is a pointer of type Node and will point to the current node of the
doubly linked list.
size size is a variable of integer type and stores the size of the doubly linked list.
Detailed description of member functions of DoublyLinkList class:

1. addAtBegining(X): To add the node at the beginning of the doubly linked list class.

2. addAtEnd(X): To add the node at the End of the doubly linked list class.

3. delNode(): To delete a node pointed by current pointer in the doubly linked list.

4. display():To display all student details in doubly linked list.

(“X” denote Node to add in the doubly linked list).

In the main ( ) function you have to do the following:

1. Create two objects of type StudentDetail at the Beginning of the doubly linked list class using addATBegining
(X) method of DoublyLinkedList and use display() method to display doubly linked list.

Note that first object should contain your own VU ID and your own name otherwise you will get zero marks.
2. Create one objects of type StudentDetail at the End of the doubly linked list class using addAtEnd (X) method
of DoublyLinkedList and use display() method to display doubly linked list.

3. Delete current node of the doubly linked list and use display() method to display doubly linked list.

4. Display doubly linked list after calling each functions.

Detailed Output Screenshot:

Lectures Covered: This assignment covers Lecture # 1-8.


Deadline: Your assignment must be uploaded/submitted at or before 18-Nov-2019.

You might also like