# Delete all even parity nodes from circular linked list in kotlin

Kotlin program for Delete all even parity nodes from circular linked list. Here problem description and explanation.

``````// Kotlin program for
// Remove all even parity nodes from a circular single linked list
{
var data: Int;
constructor(data: Int)
{
this.data = data;
this.next = null;
}
}
{
constructor()
{
this.tail = null;
}
fun insert(value: Int): Unit
{
{
}
else
{
this.tail?.next = node;
}
this.tail = node;
}
// Display node element of circular linked list
fun display(): Unit
{
{
}
else
{
// First node of linked list
while (temp != null && temp != this.head)
{
// Display node value
print("  " + temp.data);
// Visit to next node
temp = temp.next;
}
}
}
// Handles the request to find set bits in given integer
fun coutSetBit(num: Int): Int
{
var result: Int = num;
result = result - ((result ushr 1) and 1431655765);
result = (result and 858993459) + ((result ushr 2) and 858993459);
result = (result + (result ushr 4)) and 252645135;
result = result + (result ushr 8);
result = result + (result ushr 16);
result = result and 63;
return result;
}
fun removeNode(): Unit
{
{
return;
}
var point: LinkNode ? = null;
while (temp != null)
{
if (this.coutSetBit(temp.data) % 2 == 0)
{
auxiliary = temp;
// Visit to next node
temp = temp.next;
{
if (auxiliary == this.tail)
{
// Removing a single node
this.tail = null;
temp = null;
}
else
{
this.tail?.next = temp;
}
}
else if (auxiliary == this.tail)
{
if (point != null)
{
// When Remove last node
}
this.tail = point;
}
else
{
if (point != null)
{
// When Remove last node
point.next = temp;
}
}
}
else
{
point = temp;
// Visit to next node
temp = temp.next;
{
// Stop the process
temp = null;
}
}
}
}
}
fun main(args: Array < String > ): Unit
{
// Insert node
cll.insert(3);
cll.insert(12);
cll.insert(32);
cll.insert(14);
cll.insert(27);
cll.insert(19);
cll.insert(1);
cll.insert(18);
print("\n Before Remove ");
cll.display();
/*
Node  Binary     Even Parity
3     (11)         Yes
12     (1100)       Yes
32     (100000)     No
14     (1110)       No
27     (11011)      Yes
19     (10011)      No
1         (1)       No
18     (10010)      Yes
*/
cll.removeNode();
print("\n\n After Remove");
cll.display();
}``````

Output

`````` Before Remove
3  12  32  14  27  19  1  18

After Remove