implementation,twoway,linked,list,technologyi
Quick Search for: in language:   
implementation,twoway,linked,list,technologyi
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 326,796 lines
 Jobs: 886 postings

 

You are in:

 
Login


Latest Code Ticker for C/ C++
Click here to see a screenshot of this code!SOCommunicator (Client/Server Chat)
By Stephan Gramlich on 2/28

(Screen Shot)

Script Language, small but powerful
By Eric Hodges on 2/27


hangman 1.0
By kyle burmark on 2/27


MasterGraphicEx
By Dan Anderson on 2/27


secant
By Anish Chapagain on 2/27


Click here to see a screenshot of this code!game of grid
By patel chirag v on 2/27

(Screen Shot)

Click here to see a screenshot of this code!game of othello
By patel chirag v on 2/27

(Screen Shot)

Enable / Disable Start Menu
By David Rodrigues Cardeiro on 2/26


Show / Hide Start Button
By David Rodrigues Cardeiro on 2/26


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 

 
 

   

two-way linked list

Print
Email
 
VB icon
Submitted on: 2/16/2002 7:02:14 PM
By: jetendar dherwani  
Level: Advanced
User Rating: Unrated
Compatibility:C++ (general), Borland C++

Users have accessed this code 266 times.
 
(About the author)
 
     this is the implementation of two-way linked list in oop technology. if u are using the code for any purpose do favour me and vote for this code .
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

//**************************************
//     
//INCLUDE files for :two-way linked list
//     
//**************************************
//     
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <alloc.h>
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: two-way linked list
// Description:this is the implementatio
//     n of two-way linked list in oop technolo
//     gy.
if u are using the code for any purpose do favour me and vote for this code .
// By: jetendar dherwani
//
// Inputs:no
//
// Returns:no
//
// Assumes:u must be aware of by values 
//     passed in the functions by reference . a
//     little bit of knowledge of two-way list
//
// Side Effects:no
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/xq/ASP/txtCod
//     eId.3320/lngWId.3/qx/vb/scripts/ShowCode
//     .htm//for details.//**************************************
//     

//this is the implementation of two way 
//     linked list
//created by jetendar dherwani
//concepts given by sir faheem qureshi
//in simple linked list i.e one way list
//     we have only one pointer
//that helps us moving in forward direct
//     ion(only forward not backward) .
//this is the biggest flaw in simple lin
//     ked list .
//this flaw is covered or u can say remo
//     ved in two-way list .
//we have the same clas student through 
//     which we will perform some experiments
#include <iostream.h>
#include <conio.h>
#include <alloc.h>
#include <stdlib.h>
class student
    {
    public:
    int data;
    student *next;//this will help in moving forward
    student *previous ; //this will help in moving backward
    public :
    student(void);
    void insert_beg(int);
    void insert_end(int,student *&);
    void insert_middle(int loc1,int element,student *&);
    void insert_byelement(int data,student *&);
    void del_beg(void);
    void del_end(student *&);
    void del_middle(int loc,student *&);
    int count();
    void traverse(void);
};

void student::del_middle(int loc,student *&end;) { student *ptr; ptr=next; for(int i=1;i<=loc-1;i++) ptr=ptr->next; if(loc==count() ) { end=ptr->previous; ptr->previous->next=NULL; } else { ptr->next->previous=ptr->previous; ptr->previous->next=ptr->next; } } void student::del_end(student *&final;) { final->previous->next=NULL; final=final->previous->previous; }
void student ::insert_byelement(int element,student *&end;) { student *ptr,*temp; ptr=next; while(1) { if(ptr->data >= element) { temp=new student(); temp->data=element; temp->next=ptr; temp->previous=ptr->previous; (temp->previous)->next=temp; ptr->previous=temp; break; } else { if(ptr->next==NULL) { temp=new student(); temp->data=element; ptr->next=temp; temp->previous=ptr; end=ptr->next; break; } } ptr=ptr->next; } } void student::insert_middle(int loc,int element,student *&end;) { student *ptr,*temp; ptr=next; for(int i=1;i<=loc-1;i++) ptr=ptr->next; if(ptr->next==NULL) { temp=new student(); ptr->next=temp; temp->previous=ptr; temp->data=element; end=temp; } else { temp=new student(); temp->data=element; temp->next=ptr->next; temp->previous=ptr; ptr->next=temp; temp->next->previous=temp; } }
void student::del_beg(void) { student *ptr; ptr=next; ptr->next->previous=ptr->previous; next=ptr->next; }
void student ::insert_end(int element,student *&ending;) { student *newptr,*ptr; ptr=ending; newptr=new student(); newptr->data=element; newptr->previous=ptr; ptr->next=newptr; ending=newptr; }
void student::insert_beg(int element) { student *ptr,*newptr; ptr=next; newptr=new student(); newptr->previous=ptr->previous; newptr->data=element; newptr->next=ptr; next=newptr; ptr->previous=newptr; }
student::student(void) { data=-1; next=NULL; previous=NULL; }
void student ::traverse(void) { student *ptr; ptr=next; while(ptr!=NULL) { cout<<'\n'<<ptr->data; ptr=ptr->next; } } int student::count(void) { int count=0; student *ptr; ptr=next; while(ptr!=NULL) { count=count+1; ptr=ptr->next; } return(count); }
void main(void) { student *start,*end,*list; //we will need two pointers to point sta // rting element of the list //and another to point to ending element // of the list //and list is a generator clrscr(); list=new student(); start=list; end=list; list->insert_end(2,end); list->insert_end(3,end); list->insert_end(5,end); list->traverse(); cout<<'\n'<<"THE TOTAL NUMBER OF ELEMENTS ARE "<<start->count(); list->insert_beg(0); list->traverse(); getch(); list->del_beg(); list->traverse(); getch(); list->insert_middle(3,1,end); list->traverse(); getch(); list->insert_byelement(1,end); list->insert_byelement(9,end); list->traverse(); getch(); cout<<'\n'<<"nnnnn"; getch(); list->del_end(end); list->traverse(); getch(); list->del_middle(5,end); list->traverse(); getch(); list->insert_end(9,end); list->traverse(); }


Other 2 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Advanced category)?
(The codewith your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.