A linear data structure enables the user to add an address from rear end and remove address from front. (a) Specify the class Diary giving details of the functions void pushadd(String) and String popadd(). Assume that the other functions have been defined. [4] The main function and algorithm need NOT be written. (b) Name the entity used in the above data structure arrangement.
class Queue {
protected int start = -1, end = -1, size;
String[] Q;
public Queue(int max) {
size = max;
Q = new String[size];
}
void pushadd(String val) {
if (end == size - 1) {
System.out.println("Queue Overflow");
} else {
Q[++end] = val;
}
}
String popadd() {
if (end == start) {
System.out.println("Empty Queue");
return "?????";
} else {
return Q[++start];
}
}
void show() {
for (int x = start + 1; x <= end; x++) {
System.out.println(Q[x]);
}
}
}
public class Diary {
public static void main(String[] args) {
}
}