Implementing Singly Linked List with Ruby

Implementing Singly Linked List with Ruby

A list is a collection of elements. Linked List is a list in which each item contains both data and a pointer to one or both neighboring items. A Linked List is made up of elements(nodes) which are connected doubly or singly. When connected doubly, we refer to such a list of a linked list as a doubly-linked list. However, a singly linked list is a sequence of the element where the first node links to the second and the second links to the third and so on in one direction… the singly-linked list has nodes with pointers which always point to the next element in the list. We are going to focus on singly-Linked List, for the sake of this tutorial.