Page 548 - Computer science 868 Class 12
P. 548
9. Link is an entity which can hold a maximum of 100 integers. Link enables the user to add elements from the rear end and remove
integers from the front end of the entity. Define a class Link with the following details. [ISC 2011]
Class name : Link
Data Members
lnk[] : an array to hold integer elements
max : stores the maximum capacity of the entity
begin : to point to the index of the front
end : to point to the index of the rear
Member Functions
Link(int mm) : constructor to initialise max = mm, begin = 0, end = 0
void addlink(int v) : to add an element from the rear index if possible otherwise display the
message “OUT OF SIZE”
int dellink() : to remove and return an element from the front index, if possible otherwise
display the message “EMPTY…” and return -99
void display() : displays the elements of the entity
Specify the class Link giving details of the constructor(int ), void addlink(int ), int dellink() and void display().
10. A class called BothEnd is defined to perform operations on a Double ended Queue. The details of the class is given below:
Class name : BothEnd
Data Members
ele[] : an array to hold integer elements
cap : stores the capacity of the array
front : to point to the index of the front
rear : to point to the index of the rear
Member Functions
BothEnd (int max) : constructor to initialise the data members cap = max, front = 0, rear = 0 and
to create the integer array
void addfront(int v) : to add integers from the front index if possible else display the message “full
from front..overflow”
void addrear(int v) : to add integers from the rear index if possible else display the message “full
from rear..overflow”
int delfront() : to remove and return element from the front, if array is empty then return -999
int delrear() : to remove and return element from the rear, if array is empty then return -999
void display() : displays the elements present in the dequeue
Specify the class BothEnd giving details of the constructor(int), member functions void addrear(int), void addfront(int), int
delfront(), int delrear(), and void display().
11. A class called Circle is defined to perform operations on a Circular queue. The class description is given below.
Class name : Circle
Data Members
ele[] : an array to hold integer elements
cap : stores the capacity of the array
front : to point to the index of the front
rear : to point to the index of the rear
Member Functions
Circle (int max) : constructor to initialise the data members cap = max, front = 0, rear = 0 and
to create the integer array
void addvalue(int v) : to add integers from the rear index if possible else display the message
“Queue full..overflow”
int delValue() : to remove and return element from the front, if array is empty then return -1
void display() : displays the elements present in the circular queue
Specify the class Circle giving details of the constructor(int), member functions void addvalue(int), int delValue(), and void
display().
546546 Touchpad Computer Science-XII

