String Permutation

Here's an efficient implementation of string permutation in java:

Efficient string permutation

digg story

Java - Reverse a singly linked list

Sometimes the solutions are not quite obvious. Search for an algorithm to reverse a singly linked list using Java and you won't find any good hits except for this code.

public void reverse()
{
  Node currentNode, nextNode, loopNode;

  if(first == null) return;

  currentNode = first;
  nextNode = first.next;
  loopNode=null;

  while(nextNode != null)
  {
    currentNode.next = loopNode;
    loopNode = currentNode;
    currentNode = nextNode;
    nextNode = nextNode.next;
  }
  first = currentNode;
  first.next = loopNode;
}


This might not be a very intuitive solution at first sight but infact this is a very clever simulation of C/C++ pointers in Java.

read more | digg story

Added a mis-spelt word to firefox dictionary?

Don't fret.. there is a way to fix this -

Click here for details.

Adblock plus

Researched on AdBlock Plus and found that Filterset.G isn't recommended to run with it.

Check this