Data Structures and Algorithms Discussion Board
February 04, 2012, 10:33:16 AM *
Welcome, Guest. Please login or register.
Login with username, password and session length
News: Looking for a reliable webhosting provider? Read HostGator review to find 7 arguments in support of HostGator.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Singly Linked List Algorithm  (Read 4921 times)
alsaadi
Newbie
*

Rating: 0
Offline Offline

Posts: 1


« on: November 12, 2009, 11:26:12 PM »

hey 4 all
i'm writing an algorithm for the Singly linked List but i do not know how to create the nodes and how to assign the values to the nodes,,,
this what i did until now


public class SLL {
   public static void main(String[]args){
      
      SLLNode current = SLLHeader.LTFN;
      // i need to add 4 nodes with the values 10,20,30, and 40
      
      while(current!=null){
         System.out.println(current.data);
         current=current.next;
      }
   }

   

}
class SLLNode{
   int data;
   SLLNode next;
   
   SLLNode(int data){
      this.data=data;
      this.next=null;
   }
}
class SLLHeader{
   static SLLNode LTFN;
   SLLHeader(){
      LTFN=null;
   }
}


i realy need help with this,,,
Logged
Denis
Newbie
*

Rating: 0
Offline Offline

Posts: 21


« Reply #1 on: November 21, 2009, 04:32:23 AM »

Take a look at singly-linked list tutorial. You find all you need there (internal representation, add and traversal operations).
Logged
Pages: [1]
  Print  
 
Jump to:  

 
Partners Ads        maximuscle viper active        Badboy Shorts