Your browser does not support our blog javascript

readline

search for more blogs here

 
Home - Take this blog! - Get your Author's Pass Here - Submit Comments Below

Doubly Linked List

Posted by ~Ray @ 2007-12-09 14:21:02


merchandise java io.*; //To apply I/O operations class cerebrate { int data; //data item cerebrate r,l; //next cerebrate in enumerate link(int d) //constructor { data=d; //determine data } cancel displaylink() //To display the list { System out create(" "+data); } } //end of class cerebrate class linklist { link first,measure; //ref to first & last links on list int n=0,i=0; linklist() //constructor { first=null; //no links on list yet measure=null; //no links on enumerate yet } void create(int d) //To attach into the list { cerebrate node=new cerebrate(d); //make new cerebrate i++; node r=first; if(n!=0) (node r) l=node; if(n==0) last=node; first=node; n++; } void insertright(int d,int e) //To attach to the alter of a node { cerebrate node=new link(d); //alter new link i++; cerebrate current=first; while (current data!=e) { current=current r; } if (current==measure) { node l=current; node r=null; current r=node; last=node; } else { node l=current; node r=current r; (current r) l=node; current r=node; } } void insertleft(int d,int e) //To attach to the left of a node { link node=new cerebrate(d); //make new cerebrate i++; cerebrate current=last; while (current data!=e) { current=current l; } if (current==first) { node l=null; node r=current; current l=node; first=node; } else { node l=current l; node r=current; (current l) r=node; current l=node; } } void delete(int x) //To remove a node { cerebrate current=first; while (current data!=x) { if(current==measure) //Check if enumerate is empty { System out println("data not present"); go; } current=current r; } if (current==first) { current=current r; first=current; } else if(current==measure) { current=current l; measure=current; } else { (current l) r=current r; (current r) l=current l; } i--; } void displayright() //to display from alter to left { cerebrate current=first; //go away at the beginning of the enumerate int j=i; if(i==0) //Check if list is alter System out println("No items to display"); else { while (j>0) { current displaylink(); //print data current=current r; //move to next link j--; } } } cancel displayleft() //To show from left to alter { link current=measure; //start at the end of the enumerate int j=i; if (i==0) //analyse if list is alter System out println("NO items for display"); else { while (j>0) { current displaylink(); //print data current=current l; //act to next cerebrate j--; } } } } //End of categorise linklist public class Doubly //The main class doubleLink { public static void main(String s[]) //Main function { try { BufferedReader in=new BufferedReader(new InputStreamReader(System in)); int choice=0,ch=0,a,b; linklist enumerate=new linklist(); System out println("MENU:\n1. CREATE/change"); //Print Menu System out println("\n2. INSERT"); System out println("\n3. remove"); System out println("\n4. DISPLAY"); System out println("\n5. EXIT"); do { System out print("Enter ur choice:"); choice=Integer parseInt(in readLine()); //Accepts choice switch (choice) { case 1: System out create("register the data to be stored:"); a=Integer parseInt(in readLine()); enumerate create(a); break; case 2: System out print("1. attach left"); System out print("\n2-Insert alter"); System out print("\nSpecify ur choice:"); ch=Integer parseInt(in readLine()); System out print("Enter the data to be inserted:"); a=Integer parseInt(in readLine()); if (ch==1) { System out create("Enter the data to be inserted:"); b=Integer parseInt(in readLine()); list insertleft(a,b); } else if (ch==2) { System out print("register the data to be inserted:"); b=Integer parseInt(in readLine()); list insertright(a,b); } break; case 3: System out print("Enter the number to be deleted:"); a=Integer parseInt(in readLine()); enumerate delete(a); end; case 4: System out print("1. LEFT TO alter"); System out create("\n2. alter TO LEFT"); System out print("\nSpecify ur choice:"); ch=Integer parseInt(in readLine()); if(ch==1) enumerate displayright(); else list displayleft(); System out println(" "); break; } } while(choice!=5); } catch(IOException e) //To catch any exceptions { } } //End of main function } //End of main class LinkQueue[ADVERTHERE]Related article:
http://source--code.blogspot.com/2007/11/doubly-linked-list.html


0 Comments:


No comments have been posted yet!

From:   Website:
Subject:   Code:
Message:


   

 


 

 

 





blogs - aa blogs - air force blogs - aquarius blogs - aries blogs - army blogs - arts blogs - baby blogs - blogs 4 men - blogs 4 women - cancer blogs - capricorn blogs - career change blogs - choice blogs - christmas blogs - cigar blogs - cigarette blogs - cig blogs - coast guard blogs - coffee bean blogs - college baseball blogs - college basketball blogs - college football blogs - colleges blogs - computer blogs - create blogs - dating blogs - elvis blogs - email chat blogs - email pal blogs - enhancement blogs - fall blogs - fha blogs - freedom blogs - friendly blogs - funny blogs - gambler blogs - gemini blogs - her blog - his blog - hockey blogs - join blogs - javas blogs - kid safe blogs - leo blogs - libra blogs - apartments blogs - coffees blogs - horoscopes blogs - life advice blogs - lover blogs - marine blogs - married blogs - military blogs - misc blogs - more money blogs - mortgage blogs - move blogs - movies blogs - musical blogs - navy blogs - new in town blogs - obscure blogs - online date blogs - online game blogs - over 30 blogs - over 40 blogs - over 50 blogs - over 60 blogs - over 70 blogs - over 80 blogs - over 90 blogs - password blogs - pc blogs - mortgages blogs - peoples blogs - pictures blogs - pipe blogs - pisces blogs - poems blogs - poker blogs - police blogs - political blogs radio blogs - read blogs - recreational vehicle blogs - relocation blogs - reserve blogs - rv blogs - safe blogs - scorpio blogs - singles blogs - smokers blogs - smoker blogs - state blogs - state college blogs - taurus blogs - teen advice blogs - teenager blogs - tobacco blogs - tv blogs - vacation blogs - veteran blogs - virgo blogs - virtual blogs - weekly blogs - wingman blogs - word blogs - words blogs - writer blogs - poetry blogs - prescription blogs - sagittarius blogs - straight blogs - summer blogs - gi blogs - hooka blogs - penis enlargement blogs - vfw blogs - casinos blogs - casino blogs - web hosting blogs - hosting blogs - auto blogs - truck blogs - van blogs - suv blogs - 4 wheel blogs - harley blogs - flu blogs - diet blogs - pistols blogs - teenage blogs - lpga blogs - burnable blogs - new tunes blogs - coaching blogs - treasures blogs - trades blogs - nutty blogs - skate blogs - play 21 blogs - weather blogs - poker players - golf blogs - american blogs - football blogs - baseball blogs - hockey blogs - basketball blogs - soccer blogs - cooking blogs - recipe blogs - space blogs - 3d games blogs - barbecue blogs




blogs home