Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-06-2008, 05:09 PM
Member
 
Join Date: Jan 2008
Posts: 5
hasani6leap is on a distinguished road
My doublyLinked list does not get sorted
This is my code ..

class Link{
public String Name,Sex, Dob;

public int ssn,salary;
public Link next,previous;




Link(String nName,int Snum,String g,int sal,String dob){
Name=nName;
ssn=Snum;
Sex=g;
salary=sal;
Dob=dob;

}
void displayLink(){
System.out.println(Name+"\t"+ssn+"\t"+Sex+"\t"+sal ary+"\t"+Dob);
}

public class DoublyLinkList {

private Link Head;
private Link Tail;
int entries;

DoublyLinkList(){
Head=null;
Tail=null;
entries=0;
}

public void ProcessWhileInsert(String p,int SN,String k,int sal,String d){
Link current=Head;
Link previous=null;
Link thisLink=new Link(p,SN,k,sal,d);


while(current !=null && SN > current.ssn){
{
previous=current;
current=current.next;}



if(previous==null){
Head=thisLink;
entries++;}
else
{
thisLink.next=current;
thisLink.previous=current.previous;
current.previous=thisLink;
entries++;}
} }

public void DisplayList(){
Link current=Tail;
System.out.println("Name\tSSN\tSEX\tSALARY\tDOB");
while(current!=null){

current.displayLink();
current=current.previous;
}
System.out.println("Number of entries:"+entries);
}


If i just insert without sorting i can insert
when i try to insert whle sorting i can't even insert..
can someone tell me whats wrong with this sorting algorithm. Its a doubly linked list
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to right a program that find kth number in two sorted array? fireball2008 New To Java 8 04-22-2008 05:21 AM
How to create a Sorted List in Java Java Tip java.lang 0 04-17-2008 12:31 AM
Sorting, Searching, and Inserting into a sorted array Java Tip java.lang 0 04-14-2008 10:39 PM
list Zensai New To Java 3 11-20-2007 09:22 AM
How to get the max value from a list osval New To Java 1 07-30-2007 07:43 PM


All times are GMT +3. The time now is 01:41 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org