SoFunction
Updated on 2025-03-09

Example of linked list data structure implemented by JavaScript


function Node(){
  =null;
  =null;
}

function GenericList(){
  =null;
  =null;
//Put out all link nodes
  = function(){
  =;
   while(!=null){
      alert();
      =;
    }
 
  },
//Create a link list
  =function(t){
     
 
      var node=new Node();
      =t;
      =;
      =node;
 
  }
 
 

}


function SortList(){
//Bubbling sorting link list
=function()
   {
     if(==null||==null)
     {
        return ;
     }
    var swapped;
    do{
   
     =null;
     =;

     var swapped=false;
     while(!=null)
      {
      
       if(>0)
        {
      
        var tmp=;
        =;
        =;
        if(==null)
            {
               =tmp;
            }
         else
           {
               =tmp;
           }
          =tmp;
          swapped=true;
         
      
       }
       else
        {
       
        =;
        =;
       
        }
    
     }
    
     
   
    }while(swapped);
  
   }

}

=new GenericList();


(function Main(){
 var sl=new  SortList();
 for(var i=0;i<;i++)
 {(arguments[i]);
 }
alert("Unsorted linked list");
 ();
 ();
alert("Sorted linked list from small to large");
 ();

})("1","2","3","4")