Which data structure is most suitable?

Go To StackoverFlow.com

1

Which data structure is most suitable for forward and backward webpage traversal in web browsers?

Answer is Doubly Linked List. Why? Why can't we use Tree with pointer for it?

2012-04-04 16:33
by Luv
Most suitable is Doubly Linked List.Why? Why can't we use Tree with parent pointer for it and why it is not as efficient as Doubly Linked List - Luv 2012-04-04 16:35


1

Because there is only two operations you can do in a web browser, forward and backward.

What would be the use of an entire tree? You can't choose a branch.

2012-04-04 16:35
by Colin Hebert
Arguably going back in the browser and going forward to a new link could represent a bisection point for a tree structure - Kirk Woll 2012-04-04 16:38
@KirkWoll Indeed, but in the end you still can't reach other branches. So you end up with a data structure full of useless elements - Colin Hebert 2012-04-04 16:39
As browsers are, currently, yes. It's an interesting idea, though, saving the different forward paths you've taken. You could map the button's click handler the the most recent forward path, and put the rest of the forward paths in a context menu. For example: from site A, I navigate to site B, then back up to site A. Then I go to site C and back to A. The forward button would take me to site C, but it's context menu would provide options for sites B or C. I can see some utility in that - jpm 2012-04-04 16:40
Well, it's true that no existing browser provides any UI to navigate such a structure (in all probability because they do not even use a tree structure) but that doesn't mean it's not plausible for a browser to provide such - Kirk Woll 2012-04-04 16:40
@jpm, Kirk Woll, I agree that could be an idea (even if I think it's getting complicated for the end user). But given only the "forward" and "backward" actions, a tree wouldn't be useful. You would have to create new actions - Colin Hebert 2012-04-04 16:43
I'm not disagreeing with you that, with the current UIs, there's no need for a tree. As far as being too complicated, I think if you set it up right, the lay-user could use it just like they use their current UI - jpm 2012-04-04 16:47
Ads