473,395 Members | 1,905 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,395 software developers and data experts.

linked list endless loop

i'm new to C#, but i'm trying to write a circular doubly linked list.
theres a bug in my code somewhere (i think in my find() method or
ToGo() method) that causes an endless loop after i insert a node in
the middle of the list.

anyone care to take a look? i'm stumped. i appreciate any help.

source code:
http://www.cse.buffalo.edu/~dhfine/linkedlist.txt
thanks.
-dave

Mar 13 '07 #1
2 3385
On 13 Mar, 05:46, "finer" <finerrecli...@gmail.comwrote:
i'm new to C#, but i'm trying to write a circular doubly linked list.
theres a bug in my code somewhere (i think in my find() method or
ToGo() method) that causes an endless loop after i insert a node in
the middle of the list.

anyone care to take a look? i'm stumped. i appreciate any help.

source code:http://www.cse.buffalo.edu/~dhfine/linkedlist.txt

thanks.
-dave
Your list goes:
0->1->2->3->4->7->5->6

but backwards it goes:
6->5->4->3->2->1->0

I made the following change and it seemed to work.

public void Add(int i)
{
//GoTo(length-1);
if(current.Next == null)
{
current.Next = new Node(current, null, i);
current = current.Next;
}
else
{
current.Next.Previous = new Node(current, current.Next,i);
current.Next = current.Next.Previous; //<--- new
current = current.Next;
}
length++;
index++;
}

Mar 13 '07 #2
just use a database; kid

C# doesn't support databases

you should start with the basics.
dipshits like you are why all the jobs get outsourced to india


On Mar 12, 10:46 pm, "finer" <finerrecli...@gmail.comwrote:
i'm new to C#, but i'm trying to write a circular doubly linked list.
theres a bug in my code somewhere (i think in my find() method or
ToGo() method) that causes an endless loop after i insert a node in
the middle of the list.

anyone care to take a look? i'm stumped. i appreciate any help.

source code:http://www.cse.buffalo.edu/~dhfine/linkedlist.txt

thanks.
-dave

Mar 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: C++fan | last post by:
Suppose that I define the following class: class example_class{ public: example_class(); void funtion_1(); void function_2(); protected:
6
by: massimo | last post by:
Hey, I wrote this program which should take the numbers entered and sort them out. It doesnąt matter what order, if decreasing or increasing. I guess I'm confused in the sorting part. Anyone...
30
by: Skybuck Flying | last post by:
I was just trying to figure out how some C code worked... I needed to make a loop to test all possible values for a 16 bit word. Surprise Surprise... C sucks at it... once again :D lol... C is...
6
by: Steve Lambert | last post by:
Hi, I've knocked up a number of small routines to create and manipulate a linked list of any structure. If anyone could take a look at this code and give me their opinion and details of any...
5
by: Jani Yusef | last post by:
Based on an interview question I heard of but did not know the answer to....... How do you find and remove a loop from a singly linked list? In a google groups search I found the following code...
8
by: Charles Law | last post by:
I'm sorry to keep harping on about this one, but it is really quite important for me to be able to list _all_ required assemblies in my Help About box. Herfried kindly posted some code before that...
6
by: Julia | last post by:
I am trying to sort a linked list using insertion sort. I have seen a lot of ways to get around this problem but no time-efficient and space-efficient solution. This is what I have so far: ...
4
by: finer | last post by:
i'm new to C#, but i'm trying to write a circular doubly linked list. theres a bug in my code somewhere (i think in my find() method or ToGo() method) that causes an endless loop after i insert a...
11
by: Shraddha | last post by:
How can I find a loop in a single linked list? I thought about keeping a flag or traversing list more than once...but it will require another data structure to store all these things... Also if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.