<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CS301 Assignment 1 Solution and Discussion]]></title><description><![CDATA[<p dir="auto">Assignment No. 01<br />
Semester Fall 2019<br />
CS301- Data Structures	Total Marks: 20</p>
<p dir="auto">Due Date : 18-Nov-2019<br />
Instructions<br />
Please read the following instructions carefully before solving &amp; submitting assignment:<br />
It should be clear that your assignment will not get any credit (zero marks) if:<br />
o	The assignment is submitted after due date.<br />
o	The submitted code does NOT compile.<br />
o	The submitted assignment is other than .CPP file.<br />
o	The submitted assignment does NOT open or file is corrupted.<br />
o	The assignment is copied (from other student or ditto copy from handouts or internet).<br />
Uploading instructions<br />
For clarity and simplicity, You are required to Upload/Submit only ONE .CPP file.</p>
<p dir="auto">Note: Use ONLY Dev-C++ IDE.<br />
Objective<br />
The objective of this assignment is</p>
<p dir="auto">o	To make you familiar with implementing the Doubly Linked List data structure in C++ programming language.</p>
<p dir="auto">For any query about the assignment, contact at <a href="mailto:cs301@vu.edu.pk" target="_blank" rel="noopener noreferrer nofollow ugc">cs301@vu.edu.pk</a></p>
<p dir="auto">GOOD LUCK</p>
<p dir="auto">Marks: 20<br />
Problem Statement:</p>
<p dir="auto">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:</p>
<ol>
<li>
<p dir="auto">A structure named as “StudentDetail” by using struct keyword.<br />
StudentDetail structure should consist of following data members of type “string”.<br />
name<br />
vuid</p>
</li>
<li>
<p dir="auto">A node class named as “Node” by using class keyword.<br />
Node class will have following data members and member functions:<br />
<img src="https://i.imgur.com/0Q9PkDw.png" alt="cda47932-36ec-4210-ab0a-b3bee8bce8dc-image.png" class=" img-fluid img-markdown" /></p>
<pre><code> (“X” denotes StudentDetail variable means the student details and “Y” denotes the data value of the node).
</code></pre>
</li>
<li>
<p dir="auto">A doubly linked list class named as “DoublyLinkedList” by using class keyword.<br />
DoublyLinkedList class will have following data members and member functions:<br />
<img src="https://i.imgur.com/DbRi787.png" alt="a46ffa50-421f-4ab2-9d20-67bfac975435-image.png" class=" img-fluid img-markdown" /></p>
</li>
</ol>
<p dir="auto">Detailed description of member functions of DoublyLinkList class:</p>
<ol>
<li>
<p dir="auto">addAtBegining(X): To add the node at the beginning of the doubly linked list class.<br />
<img src="https://i.imgur.com/zSdkfUT.png" alt="4da1ea58-b161-48f7-98b0-9684d220156b-image.png" class=" img-fluid img-markdown" /></p>
</li>
<li>
<p dir="auto">addAtEnd(X): To add the node at the End of the doubly linked list class.<br />
<img src="https://i.imgur.com/U7K8PxG.png" alt="08b97a59-7a5e-4312-9d83-5cdb81890a8f-image.png" class=" img-fluid img-markdown" /></p>
</li>
<li>
<p dir="auto">delNode(): To delete a node pointed by current pointer in the doubly linked list.<br />
<img src="https://i.imgur.com/GfFKhEd.png" alt="59d9f4dd-919a-4db9-991a-950c4d6bb829-image.png" class=" img-fluid img-markdown" /></p>
</li>
<li>
<p dir="auto">display():To display all student details in doubly linked list.</p>
<pre><code>      (“X” denote Node to add in the doubly linked list).
</code></pre>
</li>
</ol>
<p dir="auto">In the main ( ) function you have to do the following:</p>
<ol>
<li>
<p dir="auto">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.<br />
Note that first object should contain your own VU ID and your own name otherwise you will get zero marks.</p>
</li>
<li>
<p dir="auto">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.</p>
</li>
<li>
<p dir="auto">Delete current node of the doubly linked list and use display() method to display doubly linked list.</p>
</li>
<li>
<p dir="auto">Display doubly linked list after calling each functions.</p>
</li>
</ol>
<p dir="auto">Detailed Output Screenshot:<br />
<img src="https://i.imgur.com/YNo870E.png" alt="fcd2ba41-d1ae-4c73-9648-8180c609cba1-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Lectures Covered:  This assignment covers Lecture # 1-8.<br />
Deadline:           Your assignment must be uploaded/submitted at or before 18-Nov-2019.</p>
]]></description><link>https://community.secnto.com//topic/618/cs301-assignment-1-solution-and-discussion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 19:59:52 GMT</lastBuildDate><atom:link href="https://community.secnto.com//topic/618.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 18 Nov 2019 08:34:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CS301 Assignment 1 Solution and Discussion on Wed, 22 Jan 2020 09:09:19 GMT]]></title><description><![CDATA[<p dir="auto"><strong>100 % Solved:</strong></p>
<pre><code>// Include header files
#include&lt;iostream&gt;
#include&lt;string.h&gt;
#include&lt;conio.h&gt;
#include&lt;stdlib.h&gt;
using namespace std;

// Create Structure of StudentDetail
struct StudentDetail{
	string name;
	string vuid;
};

// Create a Node class

class Node{

// Data Members of Node class
private:
	StudentDetail newStd;
	Node *prev;
	Node *next;

// Member Functions of Node class
public:
	
	// Set and get data
	void set(StudentDetail newStd){
		this-&gt;newStd = newStd;
	}
	
	StudentDetail get(){
		return newStd;
	}
	
	// Set and get next node pointer
	void setNext(Node *nextPtr){
		next = nextPtr;
	}
	
	Node* getNext(){
		return next;
	}
	
	// set and get previous node pointer
	void setPrev(Node *prevPtr){
		prev = prevPtr;
	}
	
	Node* getPrev(){
		return prev;
	}
};
// Create a DoublyLinkedList class 

class DoublyLinkedList{
// Data Members of DoublyLinkedList class
private:
	
	Node *headPtr;
	Node *curPtr;
	int size;
// Member Functions of DoublyLinkedList class
public:
	
	// Constructor of DoublyLinkedList class
	DoublyLinkedList(){
		headPtr=new Node;
		headPtr-&gt;setNext(NULL);
		headPtr-&gt;setPrev(NULL);
		curPtr=NULL;
		size = 0;
	}
	// Add node at the begining of DoublyLinkedList class
	
	void addAtBegining(Node *newNode){
		
		if(headPtr-&gt;getNext()==NULL){
			newNode-&gt;setNext(headPtr-&gt;getNext());
			headPtr-&gt;setNext(newNode);
			newNode-&gt;setPrev(headPtr);
			curPtr = newNode; 
		}
		else{
			
			newNode-&gt;setNext(headPtr-&gt;getNext());
			Node *tempNode = headPtr-&gt;getNext();
			tempNode-&gt;setPrev(newNode);
			headPtr-&gt;setNext(newNode);
			newNode-&gt;setPrev(headPtr);
		}
		size++;
	}
	
	// Add node at the end of DoublyLinkedList Class
	void addAtEnd(Node *newNode){
		
		if(curPtr==NULL){
			newNode-&gt;setNext(headPtr-&gt;getNext());
			headPtr-&gt;setNext(newNode);
			newNode-&gt;setPrev(headPtr);
			curPtr = newNode;
		}
		else{
			newNode-&gt;setNext(curPtr-&gt;getNext());
			curPtr-&gt;setNext(newNode);
			newNode-&gt;setPrev(curPtr);
			curPtr = newNode;
		}
		
		size++;
	}
	// Deleting the current node
	void delNode(){
		Node *tempCur = curPtr;
		
		if(curPtr==NULL){
			cout&lt;&lt; "List is Empty";
		}
		else{
			
			tempCur = curPtr-&gt;getPrev();
			tempCur-&gt;setNext(curPtr-&gt;getNext());
			delete curPtr;
			curPtr = tempCur;
			size--;
		}
		
		
	}
	
	// Display method for DoublyLinkedList nodes
	
	void display(){
		
		Node *tempCur = headPtr-&gt;getNext();
		
		for(int i=0; i&lt;size; i++){
			cout&lt;&lt;tempCur-&gt;get().name &lt;&lt;" "&lt;&lt;tempCur-&gt;get().vuid&lt;&lt; "---&gt;";
			tempCur = tempCur-&gt;getNext();
		}
	}
	
	
};

int main(){
	// Initializing Student data in structure variables
	StudentDetail  r1={"BC123457896","Ali"};
	StudentDetail  r2={"BC123458967","Basit"};
    StudentDetail  r3={"BC123458963","Agha"};

	
	// Create new nodes 
	Node *newNode[3] ;
	newNode[0] = new Node();
	newNode[1] = new Node();
	newNode[2] = new Node();

	newNode[0]-&gt;set(r1);
	newNode[1]-&gt;set(r2);
	newNode[2]-&gt;set(r3);


	// Create an object of DoublyLinkedList and calling the required methods
	DoublyLinkedList *dll = new DoublyLinkedList();
	cout&lt;&lt;"\n";
	cout&lt;&lt;"  Add Your VUid and Name at First Position\n";
	cout&lt;&lt;"  -----------------------------------------------\n"&lt;&lt;endl;
	dll-&gt;addAtBegining(newNode[0]);  // adding 1st node at start
	cout&lt;&lt;"  ";
	dll-&gt;display();
	cout &lt;&lt; endl ;
	
	cout&lt;&lt;"\n\n\n  Insertion at Beginning in Doubly Linked List\n";
	cout&lt;&lt;"  -----------------------------------------------\n"&lt;&lt;endl;
	dll-&gt;addAtBegining(newNode[1]); // adding 2nd node at start 
	cout&lt;&lt;"  ";
	dll-&gt;display();
	cout &lt;&lt; endl  ;

	cout&lt;&lt;"\n\n\n  Insertion at End in Doubly Linked List\n";
	cout&lt;&lt;"  -----------------------------------------------"&lt;&lt;endl;
	cout&lt;&lt;"\n";
	dll-&gt;addAtEnd(newNode[2]); // adding 3rd node at end
	cout&lt;&lt;"  ";
	dll-&gt;display();
	cout &lt;&lt; endl  ;
	
	// Deleting current (last) node at the end
	cout&lt;&lt;"\n\n\n  Deltion of current node (Last Node)\n";
	cout&lt;&lt;"  -----------------------------------------------\n"&lt;&lt;endl;
	dll-&gt;delNode();
	cout&lt;&lt;"  ";
	dll-&gt;display();

	cout&lt;&lt;"\n\n\n\n";
	system("pause");
	return 1;
}

</code></pre>
]]></description><link>https://community.secnto.com//post/1704</link><guid isPermaLink="true">https://community.secnto.com//post/1704</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Wed, 22 Jan 2020 09:09:19 GMT</pubDate></item><item><title><![CDATA[Reply to CS301 Assignment 1 Solution and Discussion on Wed, 22 Jan 2020 09:09:30 GMT]]></title><description><![CDATA[<p dir="auto">.CPP File Code</p>
<pre><code>using namespace std;
 
#include &lt;stdlib.h&gt;
#include &lt;iostream&gt;
 
struct StudentDetail{
     
    string name;
    string vuid;
     
     
};
 
//class Node* head;
 
 
class Node{
     
    struct StudentDetail newStd;
    class Node* next;
    class Node* prev;
     
    void Set(string name,string vuid)
    {
        newStd.name=name;
        newStd.vuid=vuid;
         
         
    }
     
    Node Get()
    {
             
    }
     
    void setNext(string name,string vuid){
         
        if(next==NULL)
        {
             
        }
        else
        {
            class Node* newNode= new Node();
             
                newStd.name=name;
                newStd.vuid=vuid;
                newNode-&gt;next= newNode;
         
             
             
    }   }
     
    string getNext()
    {
        next;
         
    }
     
        void setPrev(string name,string vuid){
         
        if(next==NULL)
        {
             
        }
        else
        {
            class Node* newNode= new Node();
             
                newStd.name=name;
                newStd.vuid=vuid;
                newNode-&gt;next= newNode;
         
             
             
    }   }
     
        string getPrev()
    {
        prev;
         
    }
     
     
};
 
 
 
class DoublyLinkedList{
    public:
    struct StudentDetail newStd;
class DoublyLinkedList* headPtr;
class DoublyLinkedList* curPtr;
class DoublyLinkedList* nextPtr;
int size;
//dfdf
 
class DoublyLinkedList* headDlinkList=NULL;
 
void addAtBegining(string vuid, string name)
{
class DoublyLinkedList* dNode= new DoublyLinkedList();
 
    dNode-&gt;newStd.vuid=vuid;
    dNode-&gt;newStd.name=name;
    dNode-&gt;nextPtr=headDlinkList;
    headDlinkList= dNode;
    dNode-&gt;curPtr=dNode;
     
     
     
    }
     
void addAtEnd(string vuid, string name)
{
 
    class DoublyLinkedList* dNode= new DoublyLinkedList();
 
    dNode-&gt;newStd.vuid=vuid;
    dNode-&gt;newStd.name=name;
    dNode-&gt;nextPtr=headDlinkList;
    headDlinkList= dNode;
        dNode-&gt;curPtr=dNode;
     
    }   
     
     
 void delNode()
 {
    class DoublyLinkedList* temp1=curPtr;
    class DoublyLinkedList* temp2= temp1;
    temp1-&gt;nextPtr= temp2-&gt;nextPtr;
     
    free(temp2);
     
     
     
     
     
 }
     
     
     
     
    void print()
    {
     
   class DoublyLinkedList* temp= headDlinkList;
    
   while(temp!=NULL)
   {
 cout&lt;&lt;temp-&gt;newStd.vuid&lt;&lt;"      "&lt;&lt;temp-&gt;newStd.name&lt;&lt;endl;  
    temp= temp-&gt;nextPtr;
         
}
         
    }
 
 
 
 
     
};
 
 
 
 
int main()
{
    string vuid,name;
     
cout&lt;&lt;"Add your vuID and Name at First Position "&lt;&lt;endl;
cout&lt;&lt;"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"&lt;&lt;endl;
 
    DoublyLinkedList dlist1;
 
     
    cin&gt;&gt;vuid;
    cin&gt;&gt;name;
     
    dlist1.addAtBegining(vuid,name);
    dlist1.print();
     
    cout&lt;&lt;"Insertion At Beginning in doubly Link List "&lt;&lt;endl;
    cout&lt;&lt;"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"&lt;&lt;endl;
        cin&gt;&gt;vuid;
    cin&gt;&gt;name;
    dlist1.addAtBegining(vuid,name);
dlist1.print(); 
 
        cout&lt;&lt;"Insertion At End in doubly Link List "&lt;&lt;endl;
    cout&lt;&lt;"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"&lt;&lt;endl;
    cin&gt;&gt;vuid;
    cin&gt;&gt;name;
        dlist1.addAtEnd(vuid,name);
dlist1.print(); 
        cout&lt;&lt;"Deletion of Current Node (Last Node) "&lt;&lt;endl;
    cout&lt;&lt;"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"&lt;&lt;endl;
    dlist1.delNode();
    dlist1.print();
     
}
</code></pre>
<p dir="auto"><a href="https://www.dropbox.com/s/er8a9wjh7108k1o/cs301Assignemnt.cpp?dl=0" target="_blank" rel="noopener noreferrer nofollow ugc">Download .cpp File</a></p>
<p dir="auto"><a href="https://youtu.be/lG5dpgvNi1s" target="_blank" rel="noopener noreferrer nofollow ugc">https://youtu.be/lG5dpgvNi1s</a></p>
]]></description><link>https://community.secnto.com//post/1705</link><guid isPermaLink="true">https://community.secnto.com//post/1705</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Wed, 22 Jan 2020 09:09:30 GMT</pubDate></item><item><title><![CDATA[Reply to CS301 Assignment 1 Solution and Discussion on Wed, 22 Jan 2020 09:09:19 GMT]]></title><description><![CDATA[<p dir="auto"><strong>100 % Solved:</strong></p>
<pre><code>// Include header files
#include&lt;iostream&gt;
#include&lt;string.h&gt;
#include&lt;conio.h&gt;
#include&lt;stdlib.h&gt;
using namespace std;

// Create Structure of StudentDetail
struct StudentDetail{
	string name;
	string vuid;
};

// Create a Node class

class Node{

// Data Members of Node class
private:
	StudentDetail newStd;
	Node *prev;
	Node *next;

// Member Functions of Node class
public:
	
	// Set and get data
	void set(StudentDetail newStd){
		this-&gt;newStd = newStd;
	}
	
	StudentDetail get(){
		return newStd;
	}
	
	// Set and get next node pointer
	void setNext(Node *nextPtr){
		next = nextPtr;
	}
	
	Node* getNext(){
		return next;
	}
	
	// set and get previous node pointer
	void setPrev(Node *prevPtr){
		prev = prevPtr;
	}
	
	Node* getPrev(){
		return prev;
	}
};
// Create a DoublyLinkedList class 

class DoublyLinkedList{
// Data Members of DoublyLinkedList class
private:
	
	Node *headPtr;
	Node *curPtr;
	int size;
// Member Functions of DoublyLinkedList class
public:
	
	// Constructor of DoublyLinkedList class
	DoublyLinkedList(){
		headPtr=new Node;
		headPtr-&gt;setNext(NULL);
		headPtr-&gt;setPrev(NULL);
		curPtr=NULL;
		size = 0;
	}
	// Add node at the begining of DoublyLinkedList class
	
	void addAtBegining(Node *newNode){
		
		if(headPtr-&gt;getNext()==NULL){
			newNode-&gt;setNext(headPtr-&gt;getNext());
			headPtr-&gt;setNext(newNode);
			newNode-&gt;setPrev(headPtr);
			curPtr = newNode; 
		}
		else{
			
			newNode-&gt;setNext(headPtr-&gt;getNext());
			Node *tempNode = headPtr-&gt;getNext();
			tempNode-&gt;setPrev(newNode);
			headPtr-&gt;setNext(newNode);
			newNode-&gt;setPrev(headPtr);
		}
		size++;
	}
	
	// Add node at the end of DoublyLinkedList Class
	void addAtEnd(Node *newNode){
		
		if(curPtr==NULL){
			newNode-&gt;setNext(headPtr-&gt;getNext());
			headPtr-&gt;setNext(newNode);
			newNode-&gt;setPrev(headPtr);
			curPtr = newNode;
		}
		else{
			newNode-&gt;setNext(curPtr-&gt;getNext());
			curPtr-&gt;setNext(newNode);
			newNode-&gt;setPrev(curPtr);
			curPtr = newNode;
		}
		
		size++;
	}
	// Deleting the current node
	void delNode(){
		Node *tempCur = curPtr;
		
		if(curPtr==NULL){
			cout&lt;&lt; "List is Empty";
		}
		else{
			
			tempCur = curPtr-&gt;getPrev();
			tempCur-&gt;setNext(curPtr-&gt;getNext());
			delete curPtr;
			curPtr = tempCur;
			size--;
		}
		
		
	}
	
	// Display method for DoublyLinkedList nodes
	
	void display(){
		
		Node *tempCur = headPtr-&gt;getNext();
		
		for(int i=0; i&lt;size; i++){
			cout&lt;&lt;tempCur-&gt;get().name &lt;&lt;" "&lt;&lt;tempCur-&gt;get().vuid&lt;&lt; "---&gt;";
			tempCur = tempCur-&gt;getNext();
		}
	}
	
	
};

int main(){
	// Initializing Student data in structure variables
	StudentDetail  r1={"BC123457896","Ali"};
	StudentDetail  r2={"BC123458967","Basit"};
    StudentDetail  r3={"BC123458963","Agha"};

	
	// Create new nodes 
	Node *newNode[3] ;
	newNode[0] = new Node();
	newNode[1] = new Node();
	newNode[2] = new Node();

	newNode[0]-&gt;set(r1);
	newNode[1]-&gt;set(r2);
	newNode[2]-&gt;set(r3);


	// Create an object of DoublyLinkedList and calling the required methods
	DoublyLinkedList *dll = new DoublyLinkedList();
	cout&lt;&lt;"\n";
	cout&lt;&lt;"  Add Your VUid and Name at First Position\n";
	cout&lt;&lt;"  -----------------------------------------------\n"&lt;&lt;endl;
	dll-&gt;addAtBegining(newNode[0]);  // adding 1st node at start
	cout&lt;&lt;"  ";
	dll-&gt;display();
	cout &lt;&lt; endl ;
	
	cout&lt;&lt;"\n\n\n  Insertion at Beginning in Doubly Linked List\n";
	cout&lt;&lt;"  -----------------------------------------------\n"&lt;&lt;endl;
	dll-&gt;addAtBegining(newNode[1]); // adding 2nd node at start 
	cout&lt;&lt;"  ";
	dll-&gt;display();
	cout &lt;&lt; endl  ;

	cout&lt;&lt;"\n\n\n  Insertion at End in Doubly Linked List\n";
	cout&lt;&lt;"  -----------------------------------------------"&lt;&lt;endl;
	cout&lt;&lt;"\n";
	dll-&gt;addAtEnd(newNode[2]); // adding 3rd node at end
	cout&lt;&lt;"  ";
	dll-&gt;display();
	cout &lt;&lt; endl  ;
	
	// Deleting current (last) node at the end
	cout&lt;&lt;"\n\n\n  Deltion of current node (Last Node)\n";
	cout&lt;&lt;"  -----------------------------------------------\n"&lt;&lt;endl;
	dll-&gt;delNode();
	cout&lt;&lt;"  ";
	dll-&gt;display();

	cout&lt;&lt;"\n\n\n\n";
	system("pause");
	return 1;
}

</code></pre>
]]></description><link>https://community.secnto.com//post/1704</link><guid isPermaLink="true">https://community.secnto.com//post/1704</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Wed, 22 Jan 2020 09:09:19 GMT</pubDate></item></channel></rss>