Hey guys, I'm writting a program that reads a list of names from a file called name.txt and instert these names directly into a linked list in alphabetical order of last names. For example, if the text file has these names: Henry Johns III, Albert Einstein, Henry Johns II, Mary D Goly, Bob Apple Jr. , Bob Apple Sr. then the linked list will be in this order: Bob Apple Jr. , Bob Apple Sr., Alber Einstein, Mary D Goly, Henry Johns II, Henry Johns III. Someone suggested me to use CompareTo to compare the last names, but I'm still very confused. PLEASE HELP ME, I'M VERY DESPERATE!
Thanks!

## All 4 Replies

I have a circular List (a circular list is like a linked list except the last node is connected to the first)and I need to prompt the user to enter an postive integer X. Include error checking to be certain that the number entered is a positive integer. Eliminate every Xth item from the circular list, beginning just once at the beginning of the list. Print each name as it is eliminate. When there is only one item remaining, that item should be printed out as the Winner!
For example: if x is 5 and the circular list has the following values: 1 x 8 4
(start at 1) after the first round, the remaing values are: x 8 4
second round: x 4
third round: x (winner!)
I've tried to write the code but I'm very confused :icon_cry:, can someone help me?
Thanks!!

nope. We can't do it for you (or rather we could, but we won't).
You have a complete and detailed problem description, implementing that should be trivial if you've done your previous homework and paid attention in class.

``````class DEListProblem
{
public class Node
{
public int Data;
public Node Next;
public Node Prev;
}

public static void Main(string[] args)
{

Node start = new Node();
start.Data = 0;
start.Next = null;
start.Prev = null;
Console.WriteLine("Enter total numbers");
int data;
Node lastNode = new Node();
Node currentNode = new Node();
for (int i = 0; i < ct; i++)
{
Console.WriteLine("Enter a number");
if (i == 0)
{
start.Data = data;
lastNode = start;
}
else
{
currentNode = new Node();
currentNode.Data = data;
lastNode.Next = currentNode;
currentNode.Prev = lastNode;
lastNode = currentNode;
}

}

start.Prev = currentNode;
currentNode.Next = start;

Console.WriteLine("Enter pivot value");

int count=1;
while (start.Next != null)
{
//Console.Write("{0} ", start.Data);
start = start.Next;
if (count == pivot-1)
{
//Console.WriteLine("\t{0} is removing", start.Data);
Node prev = start.Prev;
start = start.Next;
start.Prev = prev;
start.Prev.Next = start;
count = 1;

}
else
{
++count;
}
if (start.Next == start)
start.Next = null;
}

Console.WriteLine("winner is {0}", start.Data);