Friday, November 22, 2013

Delete Last Node (Head not not given) LInked Lists

public void deleteLast(){
 //check if this is the last node
 if(this.next == null) {
  this = null;
  return;
 }
 
 //look 2 nodes ahead to see if we have reached the end
 Node temp = this;
 while(temp.next.next != null){
  temp = temp.next;
 }
 
 //Finally, move to last node and set it null
 temp = temp.next;
 temp = null;
}

Monday, November 11, 2013

Sorting Algorithms


  1. Insertion Sort
  2. Merge Sort
  3. Quick Sort
  4. Heap Sort
  5. Counting Sort
  6. Radix Sort
  7. Bucket Sort
  • Merge Sort
  • Counting Number of Inversions Using Merge Sort
  • http://www.geeksforgeeks.org/counting-inversions/