Jump to content


Check out our Community Blogs

AbhishekMaheshwari

Member Since 21 Jul 2016
Offline Last Active Oct 13 2016 10:21 PM
-----

Posts I've Made

In Topic: [C] Josephus Solution Using Circularly Linked List

13 October 2016 - 10:22 PM

Assume link list is circular link list, then have two functions like this and call eliminate with the index you want to skip after each execution.

public int RemoveAt(int index)
{
int value = 0;
Node current = first;
do
{
if (current.Counter == index)
{
value = current.Data;
}
current = current.Next;
} while (current != first);
return value;
}

public int Eliminate(int m)
{
int value = 0;
Node current = first;
Node nextNode;

Reference:- http://tech.queryhom...ing-linked-list