Page 547 - Computer science 868 Class 12
P. 547
void display() : to display contents of CharStk
Specify the class CharStk giving details of the functions void pushChar(char) and char popChar() and void display().
6. Define a class Vehicle which allows the user to add vehicle registration plate from rear end and remove the same from front end
only. The following details of the class Vehicle are given below.
Class name : Vehicle
Data Members
reg[] : an array to hold a maximum of 100 registration plates
cap : stores the capacity of the array
f : to point to the index of the front
r : to point to the index of the rear
Member Functions
Vehicle (String v) : constructor to initialise the data members cap = m, f = 0, r = 0 and to create
the integer array
void addVehicle(String v) : to add integers from the rear index if possible else display the message
“overflow”
String delVehicle() : to remove and return element from the front, if array is empty then return
“#Empty#”
void disp() : displays the elements present in the queue
Specify the class Vehicle giving details of the constructor(int), member functions void addVehicle(int), String delVehicle() and void
disp().
7. A linear structure which can store elements with the restriction that an element can be added or removed from the top only. The
details of class Stack are given below. [ISC 2011]
Class name : Stack
Data Members
st[] : an array to hold names
size : the maximum capacity of the string array
top : the index of the topmost element of the stack
ctr : to count the number of elements of the stack
Member Functions
Stack() : default constructor
Stack(int cap) : constructor to initialise size = cap and top = -1
void pushname(String n) : to push a name into the stack. If the stack is full, display the message “overflow”
String popname() : removes a name from the top of the stack and returns it. If the stack is empty,
display the message “underflow”
void display() : Displays the elements of the stack
Specify class Stack giving details of the constructors(), void pushname (String n), String popname() and void display().
8. A linear data structure called JobNo enables the user to add a job number from rear end and remove it from front. Define a class
JobNo with the following details.
Class name : JobNo
Data Members/Instance variables
Q[] : an array to store the job numbers
size : stores the maximum capacity of the array
start : to point to the index of the front end
end : to point to the index of the rear end
Member Functions
JobNo (int max) : constructor to initialise the data members size = max, start = 0 and end = 0
void enter(int j) : to add a job number from the rear end if possible, otherwise display the
message “NO SPACE”
int remove() : removes and returns the job number from the front end of the queue if any,
else returns -1
void show() : displays the array contents
Specify the class JobNo giving details of the functions void enter(int), int remove() and void show().
545
Data Structures 545

