Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
6.2k views
in Computer by (49.0k points)
closed by

A linear data structure enables the user to add an 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 the 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 

(a) Specify the class Diary giving details of the functions void pushadd(String) and String popadd(). Assume that the other functions have been defined.

The main function and algorithm need NOT be written. 

(b) Name the entity used in the above data structure arrangement.

1 Answer

+1 vote
by (49.9k points)
selected by
 
Best answer

(a) class Diary { 

public void pushAdd(String n) { 

if(Q[0].equals("")) 

Q[0] = n; 

else if(end + 1 < size) Q[end + 1] = n; 

else System.out.println("NO SPACE"); 

public String popadd() { 

if(start -1 >= 0) 

return Q[start--]; 

else 

return "?????"; 

}

(b) Queue

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...