0% found this document useful (0 votes)
4 views5 pages

Problem #1472 Design Browser History Presentation

The document outlines the design of a BrowserHistory class using doubly-linked lists to manage website navigation. It describes the implementation of three functions: visit(), back(int steps), and forward(int steps), focusing on handling navigation without encountering null pointer errors. The author shares their approach to ensure safe traversal through the list while adhering to the specified step limits.

Uploaded by

gael.santos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Problem #1472 Design Browser History Presentation

The document outlines the design of a BrowserHistory class using doubly-linked lists to manage website navigation. It describes the implementation of three functions: visit(), back(int steps), and forward(int steps), focusing on handling navigation without encountering null pointer errors. The author shares their approach to ensure safe traversal through the list while adhering to the specified step limits.

Uploaded by

gael.santos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Problem #1472:

Design Browser History

Gael Santos
What was the task?

● Use doubly-linked lists to connect website Nodes from one to another


● Write a constructor for the BrowserHistory class, then write three functions
1. void visit()
● Creates a new website Node and links it to the previous one
1. string back(int steps)
● Follows the list backwards `steps` amount of Nodes, and returns the url
of the Node it lands on
1. string forward(int steps)
● Follows the list forwards `steps` amount of Nodes, and returns the url of
the Node it lands on
One small issue…

The forward and back functions So what I did was make it a while loop with

required me to write them in such a two conditions.

way where any amount of steps ● The first being steps > 0, and I will
between 1 to 100 (inclusive) would be decrement steps after each loop
allowed. ● The second being that the pointer
variable in the Node is not a nullptr
The issue with this is avoiding null
pointer errors while looping through This allows the loop to stop at a Node that

the list. exists and does not generate an error.


Here is my code:
THANK YOU!

You might also like