Posts

Showing posts from September, 2010

Simple linked list implementation in C#

Image
Linked list is the most basic data structure taught in the colleges.Though it looks simple,the kind of complex problems we can solve through it is just amazing.In languages like C,C++ its very easy to understand though pointers.Unfortunately or fortunately in C#,we don't need pointers to learn about linked list though internally,its all pointers all the way to the memory addresses.In this post I will try to explain how a link list can be implemented in C#. Ok,enough of technical jargon.Lets come straight to the point. Definition : A linked list is a simple chain of nodes where a node points to next node and so on till the next node doesn't points to anything. Now what is a node? A node is a simple object which contains some data and a reference to next node.Lets code both our node and linked list class. The Node class is self explanatory. As we can see the Linked List class just contains a head node and all the nodes are added to this node. A little bit of explanat