single Linked list traversal.
I think we can create a Node as this structure
class Node {
int val;
Node link;
boolean isVisited
}
class Linkedlist{ Node head;} with insert(),delete(),find() and traverse() methods
I will have another class
class LinkVisits extends Linkedlist{
@override
public void traverse()
{
current = head;
while(current!=null)
{
System.out.println("Visted Node's value"+current.val);
current.isVisited=true;
current=current.next;
}
}
}
Just proposed an idea. Open for comments. Thanks
You can use a splay tree.
- Splay tree May 13, 2013Splay tree uses caching capabilities. So in case, you add a node into the splay tree- which functions like a BST, the node bubbles up to the root. So the next time you need to check if the locality of refernce exists, you can do this in the top part of the tree, while traversing.
That enables caching and faster access.