• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer

CBSE Tuts

CBSE Maths notes, CBSE physics notes, CBSE chemistry notes

  • NCERT Solutions
    • NCERT Solutions for Class 12 English Flamingo and Vistas
    • NCERT Solutions for Class 11 English
    • NCERT Solutions for Class 11 Hindi
    • NCERT Solutions for Class 12 Hindi
    • NCERT Books Free Download
  • TS Grewal
    • TS Grewal Class 12 Accountancy Solutions
    • TS Grewal Class 11 Accountancy Solutions
  • CBSE Sample Papers
  • NCERT Exemplar Problems
  • English Grammar
    • Wordfeud Cheat
  • MCQ Questions

NCERT Solutions for Class 12 Computer Science (C++) – Queue

NCERT Solutions for Class 12 Computer Science (C++) – Queue

Long Answer Type Questions [4 marks each]

Question 1:
Define member function delque() to perform delete operation on a linked queue where each node has the following structure :

struct node 
{
char name[20]
int marks; 
node *link;
};
class queue
{
node *front,‘rear; 
public :
queue() {front=rear=NULL;
}
void delque ( );
};    [CBSE Comptt., 2014]

Answer:

void queue : : delque ()
{
if ( front != NULL)
{
node *Temp = front;
cout << Temp -> name << Temp
->marks;
front = front->link;
delete Temp;
if(front == NULL)
rear = NULL;
}
else
cout << "Queue is empty";
} 
(4 marks for correct program)

Question 2:
Give the necessary declaration of linked’ implemented Queue containing players information (as defined in the following definition of Node). Also write a user defined function in C++ to delete one Player’s information from the Queue.
[CBSE Comptt., 2013]

struct node   
{
int Player No ;
char PlayerName[20];
Node*Link;
}

Answer:
NODE *QUEUEDEL(Node * front, int val, char val2[ ])

{
Node *temp;
if (front ==NULL)    [1]
cout<<"Queue EMPTY";
{
else
{
temp=front ;
temp®PlayerNo=val;    [1]
strcpy (temp®PlayerName, val2); 
front=front®Link;    [1]
delete temp;
}
return (front);
}  [1]

Question 3:
Write a function QDELETE ( ) in C++ to perform delete operation on a Linked Queue, which contains Passenger no and Passenger name. Consider the following definition of Node in the code,

struct node
{
long int Pno; 
char Pname [20]; 
node *Link;
};    [O.D, 2013]

Answer:
//Function to delete queue elements Node * QUEUE (Node * front, int val, char vail [])

{
Node *temp; 
if (front == NULL) 
cout <<"Queue Empty"; 
else 
{
temp = front; 
temp®Pno=val;
strcpy (temp®Pname, vail); 
front = front®Link; 
delete temp;
}
return (front);
}    [4]

Question 4:
Write a function QINSERT() in C+ + to perform insert operation on a Linked Queue, which contains Client no and Client name. Consider the following definition of NODE in the code of . QINSERT ().    [Delhi, 2013]

struct Node
{
long int Cno; // Client No 
char Cname [20]; //
Client Name 
Node *Next ;
};

Answer:
Function to Insert element
Node * QINSERT (Node *rear, int val),

char val []
{
Node *temp; 
temp = new Node;
temp®Cno = val; 
strcpy (temp®Cname, val); 
temp®NEXT=NULL; 
rear®NEXT=temp; 
rear=temp; 
return (rear);
}    [4]

Question 5:
Write a function in C++ to perform Insert operation in a circular Queue containing Layer’s information (represented with the help of an array of structure Player).    [CBSE SQP 2013]

struct Player
{
long PID;    //Player ID
char Pname [20];}    //Player Name
Player*Link;
}

Answer:

void Insert ( )
{
PLAYER *P = new PLAYER;
cout <<"Enter Player ID & Name";
cin>>P→PID;
gets (P→ Pname);
P®Link=NULL;
if ((fronts = NULL) && (rear == NULL))
{
front = rear = P;
}
else
{
rear®Link = P; 
rear = P;
}
}    [4]

Question 6:
Write a function in C++ to perform insert operation in a static circular queue containing book’s information (represented with the help of an array of structure BOOK).    [O.D, 2012]

struct BOOK
{
long Accno; //Book Accession Number char Title[20];    //Book Title
};

Answer:

struct BOOK
{
long Accno; char Title [20] ; 
int front, rear;
}B [10] ; 
void insert()
{
if (r e a r = = s i z e - l & & f r o n t = = 0||front== rear+1)
{ 
cout<<"\n Circular queue is full"; return;
}
else if(rear==-l)
{
rear++; 
front++;
}
else if(rear==size-1) 
rear=0; 
else 
{
rear++;
}
cout<<"Enter Title : ” ;
cin>>B[rear] . Title;
cout<<"Enter Accno : ” ;
 cin>>B[rear] . Accno;
}    [4]

Question 7:
Write a function in C++ to perform insert operation in a dynamic queue containing DVD’s information (represented with the help of an array of structure DVD). [Delhi, 2012]
Answer:
/*Function in C++ to perform insert in a dynamic queue is given as*/

struct DVD 
{
long No; // DVD Number 
char Title[20]; // DVD Title 
DVD *Link 
};
void insert(struct DVD *start, char data[20] ) ;
{
DVD *q, *temp;
// Dynamic memory has been allocated for a node
temp=(DVD*)malloc(size of (DVD)); 
temp=Title[20]=data[20] ; 
temp"Next=NULL;
if (start    =    = NULL) /*Element
inserted at end*/
while (q"Next ! = NULL)
q=q.Next;
q.Next = temp;
}    [4]

Question 8:
Write the definition of a member function INSERT() for a class QUEUE in C++, to insert a CUSTOMER in a dynamically allocated Queue of items considering the following code which is already written as a part of the program,

struct CUSTOMER 
{
int CNO; char CNAME[20];
CUSTOMER *Link;
};
Class QUEUE
{
CUSTOMER *R,*F;
Public:
QUEUE(){R=NULL;F=NULL;} 
void INSERT(); 
void DELETE()
-QUEUE();
};    [CBSE SQP 2013]

Answer:

void QUEUE : : INSERT ()
{
CUSTOMER*T=New CUSTOMER;
cin>>T>>;
gets(T→CNAME);
//OR cin>>T>>CNAME; 
T → LINK = NULL; 
if (R==NULL)
{
F=T; R=T;
}
else
{ R → LINK = T; R = T;
}
}

(1 Mark for correct a new code)
(1/2 Mark for entering data to new code)
(1/2Mark for assigning NULL to link of the new code)
(1/2 Mark for assigning front to the first code as L=T)
(1/2 Mark for linking the last node to new code as R→Link=T)
(1 Mark for assign Read to the new code as R=T)

NCERT SolutionsComputer scienceEnglishHindiHumanitiesCommerceScience

Primary Sidebar

NCERT Exemplar problems With Solutions CBSE Previous Year Questions with Solutoins CBSE Sample Papers
  • The Summer Of The Beautiful White Horse Answers
  • Job Application Letter class 12 Samples
  • Science Lab Manual Class 9
  • Letter to The Editor Class 12 Samples
  • Unseen Passage For Class 6 Answers
  • NCERT Solutions for Class 12 Hindi Core
  • Invitation and Replies Class 12 Examples
  • Advertisement Writing Class 11 Examples
  • Lab Manual Class 10 Science

Recent Posts

  • Understanding Diversity Question Answer Class 6 Social Science Civics Chapter 1 NCERT Solutions
  • Our Changing Earth Question Answer Class 7 Social Science Geography Chapter 3 NCERT Solutions
  • Inside Our Earth Question Answer Class 7 Social Science Geography Chapter 2 NCERT Solutions
  • Rulers and Buildings Question Answer Class 7 Social Science History Chapter 5 NCERT Solutions
  • On Equality Question Answer Class 7 Social Science Civics Chapter 1 NCERT Solutions
  • Role of the Government in Health Question Answer Class 7 Social Science Civics Chapter 2 NCERT Solutions
  • Vital Villages, Thriving Towns Question Answer Class 6 Social Science History Chapter 9 NCERT Solutions
  • New Empires and Kingdoms Question Answer Class 6 Social Science History Chapter 11 NCERT Solutions
  • The Delhi Sultans Question Answer Class 7 Social Science History Chapter 3 NCERT Solutions
  • The Mughal Empire Question Answer Class 7 Social Science History Chapter 4 NCERT Solutions
  • India: Climate Vegetation and Wildlife Question Answer Class 6 Social Science Geography Chapter 8 NCERT Solutions
  • Traders, Kings and Pilgrims Question Answer Class 6 Social Science History Chapter 10 NCERT Solutions
  • Environment Question Answer Class 7 Social Science Geography Chapter 1 NCERT Solutions
  • Understanding Advertising Question Answer Class 7 Social Science Civics Chapter 7 NCERT Solutions
  • The Making of Regional Cultures Question Answer Class 7 Social Science History Chapter 9 NCERT Solutions

Footer

Maths NCERT Solutions

NCERT Solutions for Class 12 Maths
NCERT Solutions for Class 11 Maths
NCERT Solutions for Class 10 Maths
NCERT Solutions for Class 9 Maths
NCERT Solutions for Class 8 Maths
NCERT Solutions for Class 7 Maths
NCERT Solutions for Class 6 Maths

SCIENCE NCERT SOLUTIONS

NCERT Solutions for Class 12 Physics
NCERT Solutions for Class 12 Chemistry
NCERT Solutions for Class 11 Physics
NCERT Solutions for Class 11 Chemistry
NCERT Solutions for Class 10 Science
NCERT Solutions for Class 9 Science
NCERT Solutions for Class 7 Science
MCQ Questions NCERT Solutions
CBSE Sample Papers
NCERT Exemplar Solutions LCM and GCF Calculator
TS Grewal Accountancy Class 12 Solutions
TS Grewal Accountancy Class 11 Solutions