Posts

Data Structure Lab 7

Image
Source Code: #include <iostream> using namespace std; struct Node{ int id; Node*next; // Node*head = NULL; }; Node* head = NULL; Node* temp=NULL; //menu void menu() { cout << "***************************************** \n"; cout << "1: Insert an Element at front \n"; cout << "2: delete an Elemnet from end \n"; cout << "3: Search an element \n"; cout << "4: Display list \n"; cout << "5: Is List empty \n"; cout << "6: Exit \n "; cout << "***************************************** \n"; cout<< " Enter Your  choice: "; } //insert at start void InsertAtStart(int x) { Node*newnode = new Node; newnode->id = x; newnode->next = NULL; if (head == NULL) { head = newnode; cout<<"Value is entered in linked list \n "; } else ...

DS Lab quiz 1

There are n cars at a gas station .Every time a new car arrive it joins the line from the end.the car came from first served fist.implement a linked list based solution in order to record the information.Store the following properties of car in your linked list. Car plate No Car Model Car's position in the line your solution must be contain following functions. Add the information of a car. update car info display the total size. Source Code: #include <iostream> using namespace std; struct car{ string CplateNo; int model; int carposition; car*next; };car *head=NULL; car* temp=NULL; string cno; int mod,cp=0,sizecount=0; //add void add(string Carno,int carmod) { bool flag=false; car* c=new car; c->carposition=cp++; c->CplateNo=Carno; c->model =carmod; c->next=NULL; if(head==NULL) { sizecount++; head=c; cout<<"Information is entered"<<endl; ...

Data Structure Lab 6

Image
Source code : #include <iostream> using namespace std; #define size 5 int que[size],front=0,rear=0; //add value in enque void enque(int value) { if(size==rear && front==0) { cout<<"Qeue is full"<<endl; } else { que[rear]=value; rear++; cout<<value<<" value is enqeue in array"<<endl; } } //del value from que void deque() { int no; if(front==rear) { cout<<"Stack is empty"<<endl; } else { no=que[front]; front++; cout<<no<<" is deleted from que. "<<endl; } } void display() { if(front==rear) { cout<<"Stack is empty"<<endl; } else { for(int i=front;i<rear;i++) { cout<<que[i]<<"  "; } cout<<endl; } } int main() { int choice,value; do{ cout<<"****...

Data Structure Lab 5

Image
#include<iostream> #define MAX 5 using namespace std; int STACK[MAX],TOP; //stack initialization void initStack(){     TOP=-1; } //check it is empty or not int isEmpty(){     if(TOP==-1)         return 1;     else         return 0; } //check stack is full or not int isFull(){     if(TOP==MAX-1)         return 1;     else           return 0; } void push(int num){     if(isFull()){         cout<<"STACK is FULL."<<endl;         return;     }     ++TOP;     STACK[TOP]=num;     cout<<num<<" has been inserted."<<endl; } void display(){     int i;     if(isEmpty()){         cout<<"STACK is EMPTY."<<endl;         return; ...

Data Structure lab 4

Data Structure lab 4: Create a program that take an array of 10 inputs from the user and generate the sorted out put using the following Algorithms; •       Bubble Sort •       Insertion Sort •       Selection Sort Code: #include <iostream> using namespace std; void bubblesort(int c[]) {                 int temp;                 for (int j = 1; j < 10; j++)                 {                                 for (int i = 0; i< 10-j; i++)        ...

Data Structure lab 2

                                                    LAB 02                                              Data Structure Lab              Task :1 Part 1    #include <iostream> using namespace std; void main(){        int count = 0;        int n ,flag=0;        cout << "Enter any integer: " ;        cin >> n;        for ( int i =2; i<=n-1; i++){      ...

Data Structure lab 1

Task 1: Write a Program to enter three integers and output the smallest integer using IF. #include <iostream> using namespace std; void smallest(int a,int b, int c); int main() {             int a,b,c;             cout<<"Enter 3 numbers"<<endl;             cin>>a;             cin>>b;             cin>>c;             smallest(a,b,c);             system("pause"); } void smallest(int a, int b, int c) {                         if (a...