.CPP File Code
using namespace std; #include <stdlib.h> #include <iostream> 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->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->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->newStd.vuid=vuid; dNode->newStd.name=name; dNode->nextPtr=headDlinkList; headDlinkList= dNode; dNode->curPtr=dNode; } void addAtEnd(string vuid, string name) { class DoublyLinkedList* dNode= new DoublyLinkedList(); dNode->newStd.vuid=vuid; dNode->newStd.name=name; dNode->nextPtr=headDlinkList; headDlinkList= dNode; dNode->curPtr=dNode; } void delNode() { class DoublyLinkedList* temp1=curPtr; class DoublyLinkedList* temp2= temp1; temp1->nextPtr= temp2->nextPtr; free(temp2); } void print() { class DoublyLinkedList* temp= headDlinkList; while(temp!=NULL) { cout<<temp->newStd.vuid<<" "<<temp->newStd.name<<endl; temp= temp->nextPtr; } } }; int main() { string vuid,name; cout<<"Add your vuID and Name at First Position "<<endl; cout<<"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"<<endl; DoublyLinkedList dlist1; cin>>vuid; cin>>name; dlist1.addAtBegining(vuid,name); dlist1.print(); cout<<"Insertion At Beginning in doubly Link List "<<endl; cout<<"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"<<endl; cin>>vuid; cin>>name; dlist1.addAtBegining(vuid,name); dlist1.print(); cout<<"Insertion At End in doubly Link List "<<endl; cout<<"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"<<endl; cin>>vuid; cin>>name; dlist1.addAtEnd(vuid,name); dlist1.print(); cout<<"Deletion of Current Node (Last Node) "<<endl; cout<<"_ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _ _"<<endl; dlist1.delNode(); dlist1.print(); }UNSOLVED CS301 Final Term Current Paper
-
Cs301 Today paper
Q1.biner tree bnawa tha OS k levels btao.
Q2.carictrics of avl tree.
Q3.if node leaf and non leafe in binry tree then what the hight of tree of its depth is 7?
Q.4hight of nodes if hight is 5?
Q.6 [2 9 7 5 8] sort it.
Q.7 ik tree tha osko array mn conert krna tha.
Q8.crictristics of union method
Mostly mcqs and questions are from moazz files.
Shared By @Awais -
@zareen
The Linked List ADT
We have been using linked nodes to generate our structures for the Stack ADT and the Queue ADT. Now we will consider the linked list. As we have been using this structure for implementing the previous ADT structures, it is perhaps more constructive to look at a variation of the single linked list (known as the ‘sorted’ linked list).The idea behind this type of list is that any element we put into the list will have to be put into the correct position by comparing some common value held in each of the nodes. So far the Stack ADT and the Queue ADT did not impose any ordering on the elements we added. If we were looking for a basic linked list, we could use these as the basis for the structure and operations. This is a task you might attempt for yourselves.
Our sorted linked list ADT will consist of the following primitive operations:
Create()
Destroy()
Add(element)
Remove(element)
Traverse()
IsEmpty()
Search(element)We would generally need a display operation for testing purposes to ensure that the elements are being put into the correct locations. However, the Sorted linked list is a linear structure so any processing done on the list has to be carried out in a linear manner. We must access the list through the Start link / pointer and the list has to be accessed/processed in the order that the nodes appear on the list.
As we have previously seen, one of the great advantages of the linked data structure is the ease with which it may be modified. Changing the structure does not involve moving the existing nodes. In order to delete a node we update the link / pointer of the node before it and point / link this to the node after it.
-
how table ADT can be implemented using linked list?
-
Cs301
Mcqs mostly from moaz past paper and sub out fo tha
Avl tree zada question aye diagram k or table adt heap or hashing table equivalence expression theorom prove that 2 raise power h+1 _1 Wala or baqi short avl tree k thy …zada or function variable
Shared By @Awais


100% Off on Your FEE Join US! Ask Me How?


