Skip to main content

The Fundamentals of Digital Marketing Certification

The Fundamentals of Digital Marketing Certification
Trying to make use of some spare time during these endless lockdowns. I completed The Fundamentals of Digital Marketing course on Google Digital Garage and got certified. This is not a great victory, nevertheless, I celebrate every small step towards a greater goal. #googlegarage #fundamentalsofdigitalmarketing #digitalmarketing

FDS 12

 Practical No: -12

Experiment No. 12: A double-ended queue(deque) is a linear list in which additions and deletions

may be made at either end. Obtain a data representation mapping a deque into a one-dimensional

array. Write C++ program to simulate deque with functions to add and delete elements from either

end of the deque.

Code:

using namespace std;

#include<iostream>

#include<stdio.h>

#include<process.h>

#define MAX 30

typedef struct dequeue

{

 int data[MAX];

 int rear,front;

}dequeue;

void initialize(dequeue *p);

int isEmpty(dequeue *p);

int isFull(dequeue *p);

void enqueueRear(dequeue *p,int x);

void enqueueFront(dequeue *p,int x);

int dequeueFront(dequeue *p);

int dequeueRear(dequeue *p);

void display(dequeue *p);

main()

{

 int i,x,choice,n;

 dequeue q;

 initialize(&q);

 do

 {

 cout<<"\n 1.Create \n 2.Insert(rear) \n 3.Insert(front) \n 4.Delete(rear) \n 5.Delete(front)";

 cout<<"\n 6.Display \n 7.Exit \n\n Enter your choice:";

 cin>>choice;


 switch(choice)

 {

 case 1:

 cout<<"\n Enter number of elements:";

 cin>>n;

 initialize(&q);

 cout<<"\n Enter the elements:";


 for(i=0;i<n;i++)

 {

 cin>>x;

 if(isFull(&q))

 {

 cout<<"\n Queue is full!!\n";

 exit(0);

 }

 enqueueRear(&q,x);

 }

 break;


 case 2:

 cout<<"\n Enter element to be inserted:\n";

 cin>>x;


 if(isFull(&q))

 {

 cout<<"\n Queue is full!!\n";

 exit(0);

 }


 enqueueRear(&q,x);

 break;


 case 3:

 cout<<"\n Enter the element to be inserted:\n";

 cin>>x;


 if(isFull(&q))

 {

 cout<<"\n Queue is full!!\n";

 exit(0);

 }


 enqueueFront(&q,x);

 break;


 case 4:

 if(isEmpty(&q))

 {

 cout<<"\n Queue is empty!!\n";

 exit(0);

 }


 x=dequeueRear(&q);

 cout<<"\n Element deleted is:\n"<<x;

 break;


 case 5:

 if(isEmpty(&q))

 {

 cout<<"\n Queue is empty!!\n";

 exit(0);

 }


 x=dequeueFront(&q);

 cout<<"\n Element deleted is:\n"<<x;

 break;


 case 6:

 display(&q);

 break;


 default:

 break;

 }

 }

 while(choice!=7);

}

void initialize(dequeue *P)

{

 P->rear=-1;

 P->front=-1;

}

int isEmpty(dequeue *P)

{

 if(P->rear==-1)

 return(1);

 return(0);

}

int isFull(dequeue *P)

{

 if((P->rear+1)%MAX==P->front)

 return(1);

 return(0);

}

void enqueueRear(dequeue *P,int x)

{

 if(isEmpty(P))

 {

 P->rear=0;

 P->front=0;

 P->data[0]=x;

 }


 else

 {

 P->rear=(P->rear+1)%MAX;

 P->data[P->rear]=x;

 }

}

void enqueueFront(dequeue *P,int x)

{

 if(isEmpty(P))

 {

 P->rear=0;

 P->front=0;

 P->data[0]=x;

 }

 else

 {

 P->front=(P->front-1+MAX)%MAX;

 P->data[P->front]=x;

 }

}

int dequeueFront(dequeue *P)

{

 int x;

 x=P->data[P->front];

 if(P->rear==P->front)

 initialize(P);

 else

 P->front=(P->front+1)%MAX;

 return(x);

}

int dequeueRear(dequeue *P)

{

 int x;

 x=P->data[P->rear];

 if(P->rear==P->front)

 initialize(P);


 else

 P->rear=(P->rear-1+MAX)%MAX;

 return(x);

}

void display(dequeue *P)

{

 if(isEmpty(P))

 {

 cout<<"\n Queue is empty!!";

 exit(0);

 }


 int i;

 i=P->front;


 while(i!=P->rear)

 {

 cout<<" "<<P->data[i];

 i=(i+1)%MAX;

 }

 cout<<" "<<P->data[P->rear];

}

GALLERY

GALLERY
photos

ABOUT

HTML CSS, VB.net Developer and Java, C programming. With Loves Problem Solving and to Unreval the Mysteries behind the Magic of Computer Programming

Followers

MY PROJECTS

Popular posts from this blog

FDS 5

 Practical No: -5 Experiment No. 6: Write a python program to store first year percentage of students in array. Write function for sorting array of floating-point numbers in ascending order using a) Selection Sort b) Bubble sort and display top five score Code: # Function for Selection Sort of elements def Selection_Sort(marks):  for i in range(len(marks)):  # Find the minimum element in remaining unsorted array  min_idx = i  for j in range(i + 1, len(marks)):  if marks[min_idx] > marks[j]:  min_idx = j  # Swap the minimum element with the first element  marks[i], marks[min_idx] = marks[min_idx], marks[i]  print("Marks of students after performing Selection Sort on the list : ")  for i in range(len(marks)):  print(marks[i]) #<---------------------------------------------------------------------------------------> # Function for Bubble Sort of elements def Bubble_Sort(marks):  n = len(marks)  # Traverse throug...

FDS 4

 Practical No: -4 Experiment No. 4: a) Write a python program to store roll numbers of student in array who attended training program in random order. Write function for searching whether particular student attended training program or not, using linear search and sentinel search. b) Write a Python program to store roll numbers of student array who attended training program in sorted order. Write function for searching whether particular student attended training program or not, using Binary search and Fibonacci search. Code: import array as arr # Accept the Roll Numbers of the students def accept_roll():  a = arr.array('I', [])  no_stud = int(input("Enter the number of Students : "))  for i in range(0, no_stud):  a.append(int(input("Enter the Roll Number : ")))  return a # Print the Roll Numbers of the Students def print_roll(a):  for i in range(0, len(a)):  print("\t", a[i], end=" ")  print() # Linear Search def linear_search(a, x):  f...

Contact us

Name

Email *

Message *