473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Revesing the elements in a linklist.

Parul Bagadia
188 100+
I m getting stuck about back tracking the list;
i can traverse the list in forward direction, and reach till the end of list; but how will i make it go back ; is the problem.
Mar 26 '08 #1
5 1298
I m getting stuck about back tracking the list;
i can traverse the list in forward direction, and reach till the end of list; but how will i make it go back ; is the problem.

u may keep track of the previous address in the linked list..
a way to do it is to use a doubly linked list... :)
nevertheless i think u need to explain your problem in detail..i mean why would u like to back track the list... :|
Mar 26 '08 #2
mac11
256 100+
I m getting stuck about back tracking the list;
i can traverse the list in forward direction, and reach till the end of list; but how will i make it go back ; is the problem.
How is the list implemented?

If you're using the list from the stl you can use reverse iterators, but some lists are made using a single link between nodes and you can't go backwards through them.
Mar 26 '08 #3
Parul Bagadia
188 100+
How is the list implemented?

If you're using the list from the stl you can use reverse iterators, but some lists are made using a single link between nodes and you can't go backwards through them.
Yaeh its a singly link list. And we are supposed to use the same thing.
Mar 26 '08 #4
RedSon
5,000 Expert 4TB
Yaeh its a singly link list. And we are supposed to use the same thing.
You need to have a temporary node pointer, pointing to the previous node. There is no other way. If you list is singly linked there is no way to traverse backwards.
Mar 26 '08 #5
Ganon11
3,652 Expert 2GB
Not necessarily. You could look at the first node, and make that the head of your new list.

Now you look at the second node. Copy the data into a new, blank node. Set this new node's next pointer to the head node. Now make this node the head.

Repeat as desired.

EDIT: This is if you wish to obtain a list that is the reverse of the original list.

If you want to traverse the list backwards while maintaining the original order in a singly-linked list, there is no way.
Mar 26 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: jova | last post by:
I'm stuck I have to convert an array to a linklist the array is initialized as public Organization{ Crew members = new Member etc....
7
by: vjay | last post by:
I want to just create a linklist.The program below goes into an endless loop.The srange behaviour is that i can exit from the program if i create only two nodes.After two goes into infinite loop. ...
6
by: jwvai316 | last post by:
I don't really know how to say it so I just say it a nested linklist. How do you make LinkLists inside LinkList? Can anyone help me for this? I think an example program will help me a lot. ...
0
by: prashant0903 | last post by:
how i 'll made the linklist program in java both included insertion & deletion in program
5
by: Asembereng | last post by:
Hi i want to do insertion sort, merge sort and quick sort on my linkList of ints.. do anyone have an idea how to do it?? these are the codes. And i also need to define a lifo fifo class.. ...
2
by: zubia | last post by:
hi how 2 deal with the rptr n lptr in doubly linklist
0
by: smoothkriminal1 | last post by:
the question is u read timetable of 40 students from file n den find da slot where all fourty students dnt hve clash...if any.... may b i ll be able to make clash logic but i m even just nt...
1
by: smoothkriminal1 | last post by:
Write a Code that will pick timetable of 40 students from file using linklist n than find a slot where all the students dont have any class. file can be of any format Student can maximum take 6...
2
Parul Bagadia
by: Parul Bagadia | last post by:
I have written a code for deleting certain value from linklist; it's not working; where as i have written one for deleting a no., after given no. which works fine! I even debugged it; but invain;...
2
by: dynamo | last post by:
this is a basic linklist,there seems to be a runtime error when i run the program(the main function) i suspect it has something to do with my del function but i see nothing wrong can you help.Thanx...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.