public static void Main(string[] args)
public static void Test2016B4()
int[] arr = {1, 3, 3, 4, 4, 4, 7, 8, 9, 10};
IntNode list = ArrayToIntList(arr);
Console.WriteLine("List:");
bool isTripple = (IsListTriple(list));
arr = new int[]{1, 3, 3, 4, 1, 3, 3, 4, 1, 3, 3, 4};
Console.WriteLine("Tripple = " + isTripple);
list = ArrayToIntList(arr);
Console.WriteLine("List:");
isTripple = IsListTriple(list);
Console.WriteLine("Tripple = " + isTripple);
public static void Test18()
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
Node<int> list1 = ArrayToList(arr);
Console.WriteLine("List1:");
Node<int> list2 = ArrayToList(arr2);
Console.WriteLine("List2:");
Console.WriteLine("IsListContains: " + IsListContains(list1, list2));
Node<int> list3 = ArrayToList(arr3);
Console.WriteLine("List3:");
Console.WriteLine("IsListContains: " + IsListContains(list1, list3));
public static void Test17()
int[] arr = {1, 3, 3, 4, 4, 4, 7, 8, 9, 10};
Node<int> list = ArrayToList(arr);
Console.WriteLine("List:");
int longest = LongestSequence(list);
Console.WriteLine("Longest = " + longest);
public static void Test16()
Node<int> list1 = CreateSortedIntList(3);
Console.WriteLine("List1:");
Node<int> list2 = CreateSortedIntList(3);
Console.WriteLine("List2:");
Node<int> merged = MergeLists(list1, list2);
Console.WriteLine("Merged:");
public static void Test15()
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
Node<int> list = ArrayToList(arr);
Node<int> node = GetIt(list, 7);
public static void Test14()
char[] chars = {'K', 'K', 'K', 'B', 'B', 'K', 'Z', 'E', 'E', 'Z'};
Node<char> first = new Node<char>(chars[0]);
for (int i = 1; i < chars.Length; i++)
Node<char> node = new Node<char>(chars[i]);
CompressSequences(first);
public static void Test13()
public static void TestArrayToList()
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
Node<int> list = ArrayToList(arr);
public static void Test12()
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
Node<int> list1 = ArrayToList(arr);
Console.WriteLine("List1:");
Console.WriteLine("Max = " + GetMax(list1));
public static void TestStringNode()
Console.WriteLine("Enter word:");
StringNode first = new StringNode(Console.ReadLine());
Console.WriteLine("Enter word:");
string str = Console.ReadLine();
StringNode word = new StringNode(str);
public static void TestIntNode()
Random rnd = new Random();
IntNode first = new IntNode(n);
IntNode second = new IntNode(n);
for (int i = 0; i < 5; i++)
pos.SetNext(new IntNode(n));
public static IntNode ArrayToIntList(int[] arr)
IntNode first = new IntNode(arr[0]);
for (int i = 1; i < arr.Length; i++)
IntNode node = new IntNode(arr[i]);
public static Node<int> ArrayToList(int[] arr)
Node<int> first = new Node<int>(arr[0]);
for (int i = 1; i < arr.Length; i++)
Node<int> node = new Node<int>(arr[i]);
public static Node<int> CreateIntListX(int length)
Random rnd = new Random();
Node<int> first = new Node<int>(rnd.Next(100));
for (int i = 1; i < length; i++)
Node<int> node = new Node<int>(rnd.Next(100));
public static Node<int> CreateSortedIntList(int length)
Random rnd = new Random();
Node<int> first = new Node<int>(rnd.Next(100));
for (int i = 1; i < length; i++)
Node<int> node = new Node<int>(rnd.Next(pos.GetValue(), 100));
public static void PrintIntNodeList(IntNode list)
public static void PrintIntList(Node<int> list)
public static void PrintCharList(Node<char> list)
public static int[] ListToArray(Node<int> list, int length)
int[] arr = new int[length];
for (int i = 0; i < length; i++)
arr[i] = list.GetValue();
public static Node<int> CreateIntList(int length)
int num = r.Next(0, 101);
Node<int> n1 = new Node<int>(num);
for (int i = 1; i < length; i++)
public static int GetMax(Node<int> list)
int max = list.GetValue();
if (list.GetValue() > max)
public static void CompressSequences(Node<char> list)
public static Node<int> GetIt(Node<int> list, int num)
if (list.GetValue() == num)
public static Node<int> MergeLists(Node<int> list1, Node<int> list2)
while (pos1 != null && pos2 != null)
if (alue() < pos2.GetValue())
list2.SetNext(temp.GetNext());
list1.SetNext(temp.GetNext());
public static int LongestSequence(Node<int> list)
Node<int> first=new Node<int> (0);
while(list.GetNext()!=null)
if(list.GetValue()!=list.GetNext().GetValue())
while(list.GetValue()==list.GetNext().GetValue())
public static bool IsListContains(Node<int> list1, Node<int> list2)
public static bool IsListTriple(IntNode list)
public IntNode(int x, IntNode next)
return (this.next != null);
public void SetValue(int x)
public void SetNext(IntNode next)
public override string ToString()
return (" " + this.value);
public StringNode(string s)
public StringNode(string s, StringNode next)
public StringNode GetNext()
return (this.next != null);
public void SetValue(string s)
public void SetNext(StringNode next)
public override string ToString()
return (" " + this.value);
public Node(T value, Node<T> next)
return (this.next != null);
public void SetValue(T value)
public void SetNext(Node<T> next)
public override string ToString()
return this.value.ToString() + " ";