473,465 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem moving between nodes of a linked list

1 New Member
In single/double linked list having 10 nodes due to some memory problems the 4th next node is pointing to 3rd node not to a 5 th node, how to findout the 5th node?
please explain concept and send code .
Sep 24 '07 #1
4 1805
gpraghuram
1,275 Recognized Expert Top Contributor
In single/double linked list having 10 nodes due to some memory problems the 4th next node is pointing to 3rd node not to a 5 th node, how to findout the 5th node?
please explain concept and send code .
HI,
If there is a corruption then try to solve the issue first. and then this issue will be solved automatically.
Try to use some tool like Rational Purify to identify the memory corruption

Raghuram
Sep 24 '07 #2
ashitpro
542 Recognized Expert Contributor
This is what we called as loop in link list.
To find out loop in link list follow the steps.

take two pointers, pointing to start of link list.
while(first node != NULL && second node !=NULL)
{
advance first pointer with one node
advance first pointer with two node
if(first node == second node)
{
here you can say that, there is loop in link list
break
}
}
Sep 24 '07 #3
sicarie
4,677 Recognized Expert Moderator Specialist
FYI - I changed the title of the thread to be a bit more descriptive.
Sep 24 '07 #4
weaknessforcats
9,208 Recognized Expert Moderator Expert
This is what we called as loop in link list.
To find out loop in link list follow the steps.

take two pointers, pointing to start of link list.
while(first node != NULL && second node !=NULL)
{
advance first pointer with one node
advance first pointer with two node
if(first node == second node)
{
here you can say that, there is loop in link list
break
}
}
That's not going to work.

A loop in a linked list is when more than one node points at a second node.

What to have to do is start going through the list keeping a list of the current node addresses. If any node next address points to any address in the address list, you have a loop.

Before this, however, fix your linked list code.

I assume you are using C. If you ae using C++ you should be using the list template instead of re-inventing the wheel.
Sep 24 '07 #5

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

Similar topics

5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
3
by: sugaray | last post by:
hi, i have to build a linked-list which has another sturcture _score as it's data entry, so how can i sort such linked-list based on, let say, history score into proper order...
10
by: Ben | last post by:
Hi, I am a newbie with C and am trying to get a simple linked list working for my program. The structure of each linked list stores the char *data and *next referencing to the next link. The...
11
by: bofh1234 | last post by:
Hello, I am having a problem with linked lists. My program is based on a client server model. The client sends some packets of data to the server. The server reads those packets and is...
4
by: Niks | last post by:
Hey.. I tried to creat a linked list by using a structure defined in a class as follows: class LL { struct node { int data; node *next,*previous
2
by: sieg1974 | last post by:
Hi, I have a linked list with 705 nodes, and the functions getContact and listContact to deal with it. listContact works properly, and prints all some debug information about each node. On the...
4
by: Jonas Ferreira | last post by:
Hi everyone, I'm trying to code a linked list example and everything was working fine. Then I started to code my clear() (to clear my list) but it won't work. Here is the code: class list {...
12
by: kalyan | last post by:
Hi, I am using Linux + SysV Shared memory (sorry, but my question is all about offset + pointers and not about linux/IPC) and hence use offset's instead on pointers to store the linked list in...
6
by: Gaijinco | last post by:
I'm trying to do a template class Node. My node.hpp is: #ifndef _NODE_HPP_ #define _NODE_HPP_ namespace com { namespace mnya { namespace carlos { template <typename T>
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.