Question: Browser History Web browsers commonly allow you to navigate through a history of web pages which have previously been visited. The mechanism is somewhat like

Browser History

Web browsers commonly allow you to navigate through a "history" of web pages which have previously been visited. The mechanism is somewhat like a stack, in that the most recently visited pages are at the top of the history and revisited when the "back" button is pressed.

However, the history does not really have infinite capacity. In reality, there may exist a fixed limit on the size of the history. The issue arises as to what should happen when the capacity is exhausted and a new item is pushed onto the stack. You will use the BoundedStack class for the browser history that only has room to save 50 pages in its history. When the client visits more pages, it will make room in the history for a new page by throwing away the page which is on the very bottom of the history (i.e., the least recently visited page). When the client wishes to go back to the last visited page, that page will be popped from the top of the history.

Requirements for the main class:

Browser History

  • Create an object of the BoundedStack class for a browser back button. This will be a String BoundedStack object.
  • Call the push method and pass a string: either a web page url or ip address. Repeat the method call in a loop 51 times to test the overflow.
  • Call the pop method until the BoundedStack is empty and display the return value each time. This should display 50 web page urls or ip addresses.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!