...

/

Solution Review: Finding the Length of a Linked List

Solution Review: Finding the Length of a Linked List

This review provides a detailed analysis on finding the length of a linked list.

We'll cover the following...

Solution: Linear iteration

Press + to interact
main.cs
LinkedList.cs
using System;
namespace chapter_3
{
class Challenge_4
{
static void Main(string[] args)
{
LinkedList list = new LinkedList(); // created linked list
for (int i = 1; i <= 8; i++)
{
list.InsertAtHead(i); // inserting data in list
list.PrintList();
}
int listLength = list.Length(); // calling length function
Console.WriteLine("Length of the list is " + listLength + "!");
return;
}
}
}

The ...