‹ Back to the paper
Question 11(b)
1 mark
Computer ScienceISC 2019 Computer Science Paper 1Short answerData structures
Answer the following about the data structure described.
Name the entity used in the above data structure arrangement.
Show the case
A linear data structure enables the user to add address from rear end and remove address from front. Define a class Diary with the following details:
Class name : Diary
Data members / instance variables:
Q[ ] : array to store the addresses
size : stores the maximum capacity of the array
start : to point the index of the front end
end : to point the index of the rear end
Member functions:
Diary (int max) : constructor to initialize the data member size=max, start=0 and end=0
void pushadd(String n) : to add address in the diary from the rear end if possible, otherwise display the message “ NO SPACE”
String popadd( ) : removes and returns the address from the front end of the diary if any, else returns “?????”
void show( ) : displays all the addresses in the diary
Answer
Answer
The entity used is a Queue (Linear Queue), which works on the FIFO (First In First Out) principle - the address added first (from the rear) is the first one removed (from the front).