4(a) — group 1Stacks QueuesMedium2 marks
A desktop web browser stores the history of web addresses visited.
The web browser uses a back button and forward button to move between web pages recently visited.
Two stacks are used when each of these buttons are clicked: a back stack and a forward stack.
The back button is clicked to return to a previously visited web page. The back button operates as follows:
- The web address currently being displayed by the browser is pushed onto the forward stack.
- The web address from the top of the back stack is popped.
- The web address popped is loaded by the web browser.
The forward button is clicked to revisit a web page previously visited. The forward button operates as follows:
- The web address currently being displayed by the browser is pushed onto the back stack.
- The web address from the top of the forward stack is popped.
- The web address popped is loaded by the web browser.
The current state of the two stacks (TOS marks the top of stack; positions above TOS are empty):
| position (top → bottom) | back stack | forward stack |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | www.333.corp (TOS) | |
| 4 | www.zzz.corp (TOS) | www.111.home |
| 5 | www.aaa.home | www.999.corp |
| 6 | www.ccc.my | www.222.me |
The current web address being displayed by the web browser is: www.bbb.home
The browsing session continues; the buttons are clicked in sequence in three groups:
| group | buttons clicked, in order |
|---|---|
| group 1 | back button |
| group 2 | forward button |
| group 3 | forward button, forward button, forward button |
State the contents of the back stack and the forward stack, each with its TOS pointer, and the web address currently displayed by the browser, after group 1 (one click of the back button).
| Position | Back stack | Back TOS | Forward stack | Forward TOS |
|---|---|---|---|---|
| 1 | ||||
| 2 | ||||
| 3 | ||||
| 4 | ||||
| 5 | ||||
| 6 | ||||
| Web address displayed |