Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3279300
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:34:37+00:00 2026-05-17T19:34:37+00:00

I have a question. I was once asked this in the interview — Suppose

  • 0

I have a question.
I was once asked this in the interview —

Suppose you have a queue.A very large queue containing objects. And you cannot fit this queue in the memory. So how do you go about implementing it so that you can add from the end of the queue.And remove from the start of the queue.How is this solution implemented in Java?
Any suggestions..??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:34:38+00:00Added an answer on May 17, 2026 at 7:34 pm

    There are at least 2 ways, one is to store the data in a flat file and other is to store it in the database.

    In case of flat file, you create a file format like:

    [current position]<-- here is no new line
    [data    1 length][data    1 in serialized format]<-- here is no new line
    [data    2 length][data    2 in serialized format]
    [data    3 length][data    3 in serialized format]
    [data etc. length][data etc. in serialized format]
    

    When you have a :

    • push(), you append to the file
    • pop(), you use RandomAccess and seek out the element on current [current position], and after that increment [current position] with [data x length].

    In case of database, you create a table like:

    [id][element data columns]
       1        
       2        
       3        
    etc.  
    

    When you have a :

    • push(), you append to the database
    • pop(), you use query element by it’s id at current_item++; what is stored at your class info.

    More things to note: If you need to remove elements, then it might be better, if you do not remove items as soon as you pop(), but later and many items at a time. You should get more then one element when you read, and not bother flat file / database each time you need an item.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

recently I was asked this question in an interview. In binary search we have
I have been asked this question once or twice in interviews. I am not
I have already asked this question once for a solution in Python: python intersect
Interview question- Often its pretty easier to debug a program once you have trouble
I got asked this question once and still haven't been able to figure it
I had asked this question once before but has had 0 attention and the
I've asked about this very example in another question: Fill in a form with
I honestly have no idea if this question has been asked before, or something
So various iterations of this question seems to have been asked on this site
I know this question was asked earlier once but I see no answer to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.