コード例 #1
0
        public void CanEnumerateFixedQueue()
        {
            var pq1 = new TestPriorityQueue <char>(5);            // fixed capacity

            pq1.AddWithOverflow('f');
            pq1.AddWithOverflow('u');
            pq1.AddWithOverflow('b');
            pq1.AddWithOverflow('a');
            pq1.AddWithOverflow('r');

            var enumerator = pq1.GetEnumerator();

            var list1 = Iterate(enumerator);

            Assert.AreEqual("abfru", new string(list1.OrderBy(c => c).ToArray()));

            pq1.Clear();
            pq1.Add('f');
            pq1.Add('o');
            pq1.Add('o');

            enumerator.Reset();

            var list2 = Iterate(enumerator);

            Assert.AreEqual("foo", new string(list2.OrderBy(c => c).ToArray()));

            enumerator.Dispose();
        }
コード例 #2
0
        public void CanUnboundedCapacity()
        {
            const int count = 1000;             // will trigger reallocations

            var pq = new TestPriorityQueue <int>();

            var items = Enumerable.Range(1, count).ToList();

            Shuffle(items, new Random(1234));

            foreach (var i in items)
            {
                pq.Add(i);
            }

            Assert.AreEqual(count, pq.Count);

            var popped = new List <int>();

            while (pq.Count > 0)
            {
                popped.Add(pq.Pop());
            }

            Assert.True(popped.SequenceEqual(Enumerable.Range(1, count)));
        }
コード例 #3
0
        public void CanEnumerateGrowingQueue()
        {
            var pq = new TestPriorityQueue <char>();            // unbounded

            pq.Add('f');
            pq.Add('u');
            pq.Add('b');
            pq.Add('a');
            pq.Add('r');

            var enumerator = pq.GetEnumerator();

            var list1 = Iterate(enumerator);

            Assert.AreEqual("abfru", new string(list1.OrderBy(c => c).ToArray()));

            list1.Clear();
            pq.Pop();             // modify collection
            enumerator.Reset();

            var list2 = Iterate(enumerator);

            Assert.AreEqual("bfru", new string(list2.OrderBy(c => c).ToArray()));

            enumerator.Dispose();
        }
コード例 #4
0
        public void CannotTopEmpty()
        {
            var pq = new TestPriorityQueue <char>();

            pq.Add('a');
            pq.Pop();

            var ex = Assert.Catch <InvalidOperationException>(() => pq.Top());

            Console.WriteLine("Expected: {0}", ex.Message);
        }
コード例 #5
0
ファイル: PriorityQueueTest.cs プロジェクト: ujr/csutils
        public void CannotTopEmpty()
        {
            var pq = new TestPriorityQueue <char>();

            Assert.Throws <InvalidOperationException>(() => pq.Top());            // queue empty

            pq.Add('a');
            pq.Pop();

            Assert.Throws <InvalidOperationException>(() => pq.Top());            // queue empty
        }
コード例 #6
0
        public void CanCreateSubclass()
        {
            var pq1 = new TestPriorityQueue <char>();

            Assert.AreEqual(TestPriorityQueue <char> .Unbounded, pq1.Capacity);
            Assert.AreEqual(0, pq1.Count);

            var pq2 = new TestPriorityQueue <char>(5);

            Assert.AreEqual(5, pq2.Capacity);
            Assert.AreEqual(0, pq2.Count);
        }
コード例 #7
0
        public void PerformanceTest()
        {
            const int capacity = 100 * 1000;
            const int count    = 100 * capacity;
            var       random   = new Random(12345);

            var startTime1 = DateTime.Now;
            var pq1        = new TestPriorityQueue <int>(capacity);

            for (int i = 0; i < count; i++)
            {
                int value = random.Next();
                pq1.AddWithOverflow(value);
            }

            Assert.AreEqual(Math.Min(capacity, count), pq1.Count);

            while (pq1.Count > 0)
            {
                pq1.Pop();
            }

            var elapsed1 = DateTime.Now - startTime1;

            Console.WriteLine("Capacity={0:N0} Count={1:N0} AddWithOverflow/Pop Elapsed={2}",
                              capacity, count, elapsed1);

            var startTime2 = DateTime.Now;
            var pq2        = new TestPriorityQueue <int>();     // unbounded

            for (int i = 0; i < count; i++)
            {
                int value = random.Next();
                pq2.Add(value);
            }

            Assert.AreEqual(count, pq2.Count);

            while (pq2.Count > 0)
            {
                pq2.Pop();
            }

            var elapsed2 = DateTime.Now - startTime2;

            Console.WriteLine("Capacity=unbounded Count={0:N0} Add/Pop Elapsed={1}",
                              count, elapsed2);

            Assert.Less(elapsed1, TimeSpan.FromSeconds(1), "Too slow");
            Assert.Less(elapsed2, TimeSpan.FromSeconds(12), "Too slow");
        }
コード例 #8
0
ファイル: PriorityQueueTest.cs プロジェクト: ujr/csutils
        public void CanEnumerateGrowingEmptyQueue()
        {
            var pq         = new TestPriorityQueue <char>();    // unbounded
            var enumerator = pq.GetEnumerator();

            Assert.Empty(Iterate(enumerator));

            pq.Add('x');
            pq.Pop();             // empty again
            enumerator.Reset();

            Assert.Empty(Iterate(enumerator));

            enumerator.Dispose();
        }
コード例 #9
0
ファイル: PriorityQueueTest.cs プロジェクト: ujr/csutils
        public void CanEnumerateFixedEmptyQueue()
        {
            var pq         = new TestPriorityQueue <char>(0);    // fixed capacity
            var enumerator = pq.GetEnumerator();

            Assert.Empty(Iterate(enumerator));

            pq.AddWithOverflow('x');
            Assert.Equal(0, pq.Count);             // still empty
            enumerator.Reset();

            Assert.Empty(Iterate(enumerator));

            enumerator.Dispose();
        }
コード例 #10
0
        public void CanContains()
        {
            var pq = new TestPriorityQueue <char>();

            foreach (char c in "hello")
            {
                pq.Add(c);
            }

            Assert.True(pq.Contains('h'));
            Assert.True(pq.Contains('e'));
            Assert.True(pq.Contains('l'));
            Assert.True(pq.Contains('o'));
            Assert.False(pq.Contains('x'));
        }
コード例 #11
0
ファイル: PriorityQueueTest.cs プロジェクト: ujr/csutils
        public void CannotAddFull()
        {
            const int capacity = 5;
            var       pq       = new TestPriorityQueue <char>(capacity);

            pq.Add('a');
            pq.Add('b');
            pq.Add('c');
            pq.Add('d');
            pq.Add('e');

            Assert.Equal(capacity, pq.Count);                             // queue is now full

            Assert.Throws <InvalidOperationException>(() => pq.Add('x')); // queue full
        }
コード例 #12
0
        public void CanFixedCapacity7()
        {
            // Capacity 7: complete binary tree
            const int capacity = 7;
            var       pq       = new TestPriorityQueue <char>(capacity);

            Assert.AreEqual(7, pq.Capacity);
            Assert.AreEqual(0, pq.Count);

            pq.Add('e');
            Assert.AreEqual('e', pq.Top());
            pq.Add('g');
            Assert.AreEqual('e', pq.Top());
            pq.Add('b');
            Assert.AreEqual('b', pq.Top());
            pq.Add('c');
            Assert.AreEqual('b', pq.Top());
            pq.Add('a');
            Assert.AreEqual('a', pq.Top());
            pq.Add('f');
            Assert.AreEqual('a', pq.Top());
            pq.Add('d');
            Assert.AreEqual('a', pq.Top());

            Assert.AreEqual(7, pq.Count);
            Assert.AreEqual('a', pq.Top());

            Assert.AreEqual('a', pq.AddWithOverflow('x'));             // 'a' drops out
            Assert.AreEqual('a', pq.AddWithOverflow('a'));             // 'a' never gets in...

            Assert.AreEqual(7, pq.Count);

            Assert.AreEqual('b', pq.Top());
            Assert.AreEqual('b', pq.Pop());
            Assert.AreEqual('c', pq.Pop());
            Assert.AreEqual('d', pq.Pop());
            Assert.AreEqual('e', pq.Pop());
            Assert.AreEqual('f', pq.Pop());
            Assert.AreEqual('g', pq.Pop());
            Assert.AreEqual('x', pq.Top());
            Assert.AreEqual('x', pq.Pop());

            Assert.AreEqual(0, pq.Count);

            var ex = Assert.Catch(() => pq.Pop());

            Console.WriteLine("Expected: {0}", ex.Message);
        }
コード例 #13
0
ファイル: PriorityQueueTest.cs プロジェクト: ujr/csutils
        public void CanFixedCapacity0()
        {
            const int capacity = 0;
            var       pq       = new TestPriorityQueue <char>(capacity);

            Assert.Equal(0, pq.Capacity);
            Assert.Equal(0, pq.Count);

            Assert.Throws <InvalidOperationException>(() => pq.Top());            // queue empty
            Assert.Throws <InvalidOperationException>(() => pq.Pop());            // queue empty

            // With capacity zero, all additions immediately overflow:
            Assert.Equal('z', pq.AddWithOverflow('z'));
            Assert.Equal('a', pq.AddWithOverflow('a'));
            Assert.Throws <InvalidOperationException>(() => pq.Add('b'));            // queue full
        }
コード例 #14
0
        public void CanEnumerateGrowingEmptyQueue()
        {
            // ReSharper disable once CollectionNeverUpdated.Local
            var pq         = new TestPriorityQueue <char>();    // unbounded
            var enumerator = pq.GetEnumerator();

            IterateEmpty(enumerator);

            pq.Add('x');
            pq.Pop();             // empty again
            enumerator.Reset();

            IterateEmpty(enumerator);

            enumerator.Dispose();
        }
コード例 #15
0
        public void CanEnumerateFixedEmptyQueue()
        {
            // ReSharper disable once CollectionNeverUpdated.Local
            var pq         = new TestPriorityQueue <char>(0);    // fixed capacity
            var enumerator = pq.GetEnumerator();

            IterateEmpty(enumerator);

            pq.AddWithOverflow('x');
            Assert.AreEqual(0, pq.Count);             // still empty
            enumerator.Reset();

            IterateEmpty(enumerator);

            enumerator.Dispose();
        }
コード例 #16
0
ファイル: PriorityQueueTest.cs プロジェクト: ujr/csutils
        public void CanFixedCapacity7()
        {
            // Capacity 7: complete binary tree
            const int capacity = 7;
            var       pq       = new TestPriorityQueue <char>(capacity);

            Assert.Equal(7, pq.Capacity);
            Assert.Equal(0, pq.Count);

            pq.Add('e');
            Assert.Equal('e', pq.Top());
            pq.Add('g');
            Assert.Equal('e', pq.Top());
            pq.Add('b');
            Assert.Equal('b', pq.Top());
            pq.Add('c');
            Assert.Equal('b', pq.Top());
            pq.Add('a');
            Assert.Equal('a', pq.Top());
            pq.Add('f');
            Assert.Equal('a', pq.Top());
            pq.Add('d');
            Assert.Equal('a', pq.Top());

            Assert.Equal(7, pq.Count);
            Assert.Equal('a', pq.Top());

            Assert.Equal('a', pq.AddWithOverflow('x'));             // 'a' drops out
            Assert.Equal('a', pq.AddWithOverflow('a'));             // 'a' never gets in...

            Assert.Equal(7, pq.Count);

            Assert.Equal('b', pq.Top());
            Assert.Equal('b', pq.Pop());
            Assert.Equal('c', pq.Pop());
            Assert.Equal('d', pq.Pop());
            Assert.Equal('e', pq.Pop());
            Assert.Equal('f', pq.Pop());
            Assert.Equal('g', pq.Pop());
            Assert.Equal('x', pq.Top());
            Assert.Equal('x', pq.Pop());

            Assert.Equal(0, pq.Count);

            Assert.Throws <InvalidOperationException>(() => pq.Pop());            //    queue empty
        }
コード例 #17
0
        public void CannotAddFull()
        {
            const int capacity = 5;
            var       pq       = new TestPriorityQueue <char>(capacity);

            pq.Add('a');
            pq.Add('b');
            pq.Add('c');
            pq.Add('d');
            pq.Add('e');

            Assert.AreEqual(capacity, pq.Count);             // full

            var ex = Assert.Catch <InvalidOperationException>(() => pq.Add('x'));

            Console.WriteLine("Expected: {0}", ex.Message);
        }
コード例 #18
0
        public void CannotEnumerateChangingQueue()
        {
            const string items = "hello";
            var          pq    = new TestPriorityQueue <char>(items.Length + 1);

            foreach (var c in items)
            {
                pq.Add(c);
            }

            var iter = pq.GetEnumerator();

            Assert.True(iter.MoveNext());
            pq.Add('x');             // modify (will fill up capacity)
            var ex1 = Assert.Catch <InvalidOperationException>(() => iter.MoveNext());

            Console.WriteLine("Expected after Add: {0}", ex1.Message);

            iter.Reset();

            Assert.True(iter.MoveNext());
            pq.AddWithOverflow('y');             // modify (will overflow)
            var ex2 = Assert.Catch <InvalidOperationException>(() => iter.MoveNext());

            Console.WriteLine("Expected after AddWithOverflow: {0}", ex2.Message);

            iter.Reset();

            Assert.True(iter.MoveNext());
            pq.Pop();             // modify
            var ex3 = Assert.Catch <InvalidOperationException>(() => iter.MoveNext());

            Console.WriteLine("Expected after Pop: {0}", ex3.Message);

            iter.Reset();

            Assert.True(iter.MoveNext());
            pq.Clear();             // modify
            var ex4 = Assert.Catch <InvalidOperationException>(() => iter.MoveNext());

            Console.WriteLine("Expected after Clear: {0}", ex4.Message);

            iter.Dispose();
        }
コード例 #19
0
        public void CanCopeWithTies()
        {
            var pq = new TestPriorityQueue <char>(5);

            pq.Add('x');
            pq.Add('y');

            Assert.AreEqual(2, pq.Count);

            pq.Add('x');             // again

            Assert.AreEqual(3, pq.Count);

            Assert.AreEqual('x', pq.Pop());
            Assert.AreEqual('x', pq.Pop());             // again!
            Assert.AreEqual('y', pq.Pop());

            Assert.AreEqual(0, pq.Count);
        }
コード例 #20
0
        public void CanCopyTo()
        {
            var pq = new TestPriorityQueue <char>();

            foreach (char c in "hello")
            {
                pq.Add(c);
            }

            var array = new char[pq.Count];

            pq.CopyTo(array, 0);

            // The items in the array are in "heap array order",
            // but that's an undocumented implementation detail;
            // officially the ordering is undefined, so sort:

            Array.Sort(array);
            Assert.True(array.SequenceEqual("ehllo".ToCharArray()));
        }
コード例 #21
0
ファイル: PriorityQueueTest.cs プロジェクト: ujr/csutils
        public void CanFixedCapacity6()
        {
            // Capacity 6: incomplete binary tree
            const int capacity = 6;
            var       pq       = new TestPriorityQueue <char>(capacity);

            Assert.Equal(6, pq.Capacity);
            Assert.Equal(0, pq.Count);

            pq.Add('e');
            Assert.Equal('e', pq.Top());
            pq.Add('b');
            Assert.Equal('b', pq.Top());
            pq.Add('c');
            Assert.Equal('b', pq.Top());
            pq.Add('a');
            Assert.Equal('a', pq.Top());
            pq.Add('f');
            Assert.Equal('a', pq.Top());
            pq.Add('d');
            Assert.Equal('a', pq.Top());

            Assert.Equal(6, pq.Count);

            Assert.Equal('a', pq.AddWithOverflow('x'));
            Assert.Equal('a', pq.AddWithOverflow('a'));

            Assert.Equal(6, pq.Count);

            Assert.Equal('b', pq.Top());
            Assert.Equal('b', pq.Pop());
            Assert.Equal('c', pq.Pop());
            Assert.Equal('d', pq.Pop());
            Assert.Equal('e', pq.Pop());
            Assert.Equal('f', pq.Pop());
            Assert.Equal('x', pq.Pop());

            Assert.Equal(0, pq.Count);

            Assert.Throws <InvalidOperationException>(() => pq.Pop());            // queueu empty
        }
コード例 #22
0
        public void CanFixedCapacity0()
        {
            const int capacity = 0;
            var       pq       = new TestPriorityQueue <char>(capacity);

            Assert.AreEqual(0, pq.Capacity);
            Assert.AreEqual(0, pq.Count);

            var ex1 = Assert.Catch(() => pq.Top());

            Console.WriteLine("Expected: {0}", ex1.Message);

            var ex2 = Assert.Catch(() => pq.Pop());

            Console.WriteLine("Expected: {0}", ex2.Message);

            // With capacity zero, all additions immediately overflow:
            Assert.AreEqual('z', pq.AddWithOverflow('z'));
            Assert.AreEqual('a', pq.AddWithOverflow('a'));
            var ex3 = Assert.Catch(() => pq.Add('b'));

            Console.WriteLine("Expected: {0}", ex3.Message);
        }
コード例 #23
0
ファイル: PriorityQueueTest.cs プロジェクト: ujr/csutils
        public void CannotEnumerateChangingQueue()
        {
            const string items = "hello";
            var          pq    = new TestPriorityQueue <char>(items.Length + 1);

            foreach (var c in items)
            {
                pq.Add(c);
            }

            var iter = pq.GetEnumerator();

            Assert.True(iter.MoveNext());
            pq.Add('x');             // modify (will fill up capacity)
            Assert.Throws <InvalidOperationException>(() => iter.MoveNext());

            iter.Reset();

            Assert.True(iter.MoveNext());
            pq.AddWithOverflow('y');             // modify (will overflow)
            Assert.Throws <InvalidOperationException>(() => iter.MoveNext());

            iter.Reset();

            Assert.True(iter.MoveNext());
            pq.Pop();             // modify
            Assert.Throws <InvalidOperationException>(() => iter.MoveNext());

            iter.Reset();

            Assert.True(iter.MoveNext());
            pq.Clear();             // modify
            Assert.Throws <InvalidOperationException>(() => iter.MoveNext());

            iter.Dispose();
        }
コード例 #24
0
        public void CanRemove()
        {
            var pq = new TestPriorityQueue <char>();

            foreach (char c in "abcdefghijklmnopqrstuvwxyz")
            {
                pq.Add(c);
            }

            Assert.IsFalse(pq.Remove('$'));             // no such item
            Assert.AreEqual(26, pq.Count);

            // Last item: easy to remove
            Assert.IsTrue(pq.Remove('z'));
            Assert.AreEqual(25, pq.Count);
            Assert.AreEqual('a', pq.Top());
            Assert.IsFalse(pq.Contains('z'));

            // Remove a bottom row item:
            Assert.IsTrue(pq.Remove('w'));
            Assert.AreEqual(24, pq.Count);
            Assert.AreEqual('a', pq.Top());
            Assert.IsFalse(pq.Contains('w'));

            // Remove an inner item:
            Assert.IsTrue(pq.Remove('e'));
            Assert.AreEqual(23, pq.Count);
            Assert.AreEqual('a', pq.Top());
            Assert.IsFalse(pq.Contains('e'));

            // Remove the root item:
            Assert.IsTrue(pq.Remove('a'));
            Assert.AreEqual(22, pq.Count);
            Assert.AreEqual('b', pq.Top());
            Assert.IsFalse(pq.Contains('a'));

            // Remove returns false if not found:
            Assert.IsFalse(pq.Remove('z'));
            Assert.IsFalse(pq.Remove('w'));
            Assert.IsFalse(pq.Remove('e'));
            Assert.IsFalse(pq.Remove('a'));

            // Pop remaining items and verify order:
            Assert.AreEqual('b', pq.Pop());
            Assert.AreEqual('c', pq.Pop());
            Assert.AreEqual('d', pq.Pop());
            Assert.AreEqual('f', pq.Pop());
            Assert.AreEqual('g', pq.Pop());
            Assert.AreEqual('h', pq.Pop());
            Assert.AreEqual('i', pq.Pop());
            Assert.AreEqual('j', pq.Pop());
            Assert.AreEqual('k', pq.Pop());
            Assert.AreEqual('l', pq.Pop());
            Assert.AreEqual('m', pq.Pop());
            Assert.AreEqual('n', pq.Pop());
            Assert.AreEqual('o', pq.Pop());
            Assert.AreEqual('p', pq.Pop());
            Assert.AreEqual('q', pq.Pop());
            Assert.AreEqual('r', pq.Pop());
            Assert.AreEqual('s', pq.Pop());
            Assert.AreEqual('t', pq.Pop());
            Assert.AreEqual('u', pq.Pop());
            Assert.AreEqual('v', pq.Pop());
            Assert.AreEqual('x', pq.Pop());
            Assert.AreEqual('y', pq.Pop());

            Assert.AreEqual(0, pq.Count);
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: jacobkurien1/Algorithms
        static void Main(string[] args)
        {
            // StringProblems
            //Test calls for Reverse string
            string input = "jacob";

            Console.WriteLine(input + "<=>" + new string(SimpleProblem.ReverseString(input.ToCharArray())));
            input = "jake";
            Console.WriteLine(input + "<=>" + new string(SimpleProblem.ReverseString(input.ToCharArray())));
            input = "";
            Console.WriteLine(input + "<=>" + new string(SimpleProblem.ReverseString(input.ToCharArray())));
            input = "jdshjdh@#$%^&)";
            Console.WriteLine(input + "<=>" + new string(SimpleProblem.ReverseString(input.ToCharArray())));

            ReplaceSpaces.TestReplaceSpacesInplace();
            Anagrams.TestIsAnagramAlgo();
            StringRotation.TestIsThisRotatedString();
            RemoveDuplicates.TestRemoveDuplicatesFromString();
            StringToLongConverter.TestStringToLong();
            RegexMatching.TestMatch();
            SumOfTwoNumbersInArray.TestSumOfTwoNumbersInArray();
            SumOfThreeNumbersInArray.TestSumOfThreeNumbersInArray();
            PairInSortedArrayClosestToAParticularValue.TestPairInSortedArrayClosestToAParticularValue();
            PalindromeInStringPermutation.TestPalindromeInStringPermutation();
            EditDistanceBetweenStrings.TestEditDistanceBetweenStrings();
            AnagramIsPalindrome.TestAnagramIsPalindrome();
            GreatestPalindrome.TestGreatestPalindrome();
            ReverseStringWithoutVowels.TestReverseStringWithoutVowels();
            LongestSubstringWithKDistinctChars.TestLongestSubstringWithKDistinctChars();
            // Pattern Matching
            NativePatternMatching.TestNativePatternMatching();
            KMPPatternMatching.TestKMPPatternMatching();
            BoyerMoorePatternMatching.TestPatternMatching();
            RabinKarp.TestRabinKarp();

            //Console.ReadLine();

            //Array Problems
            ArrayOfNumsIncrement.TestIncrementArrayOfNumbers();
            MajorityElement.TestFindMajorityElement();
            Merge2SortedArrays.TestMergeSortedArrays();
            MaxDistanceInArray.TestMaxDistanceInArray();
            MovingAverage.TestMovingAverage();
            TotalAverage.TestTotalAverage();
            ArrayWithGreaterElementToRight.TestArrayWithGreaterElementToRight();
            WaterCollectedInPuddleShownByHistogram.TestWaterCollectedInPuddleShownByHistogram();
            CountOfPairsWhichSumUpToGivenSum.TestCountOfPairsWhichSumUpToGivenSum();
            //Median.TestGetMedianOf2SortedArray();

            // Sorting Problems
            SelectionSort.TestSorting();
            BubbleSort.TestSorting();
            InsertionSort.TestSorting();
            ShellSort.TestSorting();
            MergeSort.TestMergeSort();
            QuickSort.TestQuickSort();
            HeapSortTester.TestHeapSort();
            CountingSort.TestSorting();
            RadixSort.TestRadixSort();
            DutchNationalFlag.TestDutchNationalFlag();
            SortedSquares.TestSortedSquares();

            // Matrix Problem
            Rotate_Matrix_90_degree.TestRotateMatrix();
            Matrix_Column_Rows_0.TestMakeRowColZero1();
            Matrix_Column_Rows_0.TestMakeRowColZero2();
            RotateMatrix180.TestRotateMatrix180();
            SumOfMatrixElementsFormedByRectangleWithCoordinates.TestSumOfMatrixElements();
            SortedArrayFromSortedMatrix.TestSortedArrayFromSortedMatrix();
            SearchWordInMatrix.TestSearchWordInMatrix();
            MaxOnesInRow.TestMaxOnesInRow();
            MatrixAsTriangle.TestMatrixAsTriangle();
            MinRangeInMatrix.TestMinRangeInMatrix();
            PrintMatrixAsSnake.TestPrintMatrixAsSnake();
            PrintMatrixInSpiral.TestPrintMatrixInSpiral();
            MaxSqAreaInBinaryMatrix.TestMaxRectAreaInBinaryMatrix();
            TicTacToeWinner.TestTicTacToeWinner();
            WaterfallCreation.TestWaterfallCreation();

            // Linked list Problems
            DeleteLinkedListNode.TestDeleteFirstNode();
            DeleteDuplicatesFromLinkedList.TestDeleteDuplicates();
            NthLastElementOfLinkedList.TestNthLastNodeOfLinkedList();
            DeleteNodeWithDirectReference.TestDeleteNode();
            AddNumbers.TestAddNumbersRepresentedByLinkedList();
            CopyLinkedListWithRandomNode.TestGetCopiedLinkedListWithRandomNode();
            CommonElementInTwoLinkedList.TestCommonElement();
            ReverseAdjacentNodesInLinkedList.TestReverseAdjacentNodes();
            MergeSortedLinkedList.TestMerge();
            CycleInLinkedList.TestStartOfCycleInLinkedList();
            MedianForCircularLinkedList.TestGetMedian();
            ReverseLinkedList.TestReverseLinkedList();
            SortedCircularLinkedList.TestCircularLinkedList();

            // stack and queue problem
            ThreeStackWithOneArray.TestThreeStackWithOneArray();
            StackWithMinElement.TestStackWithMinElement();
            StackOfPlates.TestStackOfPlates();
            SortAStack.TestSortAStackAscending();
            WellFormedExpression.TestWellFormedExpression();
            QueueVia2Stack.TestQueueVia2Stack();
            LRUCache.TestLRUCache();
            EvaluatePrefixNotation.TestGetPrefixNotationResult();
            EvaluateInflixNotation.TestGetInflixNotationResults();
            EvaluatePostfixNotation.TestGetPostfixNotationResult();
            TestCircularQueue.TestCircularQueueWithDifferentCases();
            LargestAreaInHistogram.TestLargestAreaInHistogram();
            TextEditerWithUndo.TestTextEditerWithUndo();

            //Recursion Problem
            TowerOfHanoi.TestTowerOfHanoi();
            MaxSumOfConsecutiveNums.TestMaxSumOfConsecutiveNums();

            // Back tracking problems
            Sudoku.TestSudokuSolver();
            HamiltonianCycle.TestHamiltonianCycle();
            GraphColoringWithMColors.TestGraphColoringWithMColors();
            MakeLargestIsland.TestMakeLargestIsland();

            //Misc Problem
            MinNumOfCoins.TestMinNumOfCoins();
            IsPrime.TestCheckPrime();
            SquareRoot.TestCalculateSquareRoot();
            CreditCardCheck.TestLuhnAlgo();
            ExcelFirstRowConversion.TestCovertExcelColumnToLong();
            Skyline.TestSkyline();
            SumOfSquaresWithoutMultiplication.TestSumOfSquares();
            MergeIntervals.TestMergeIntervals();
            WidthOfCalendar.TestWidthOfCalendar();
            JosephusProblem.TestJosephusProblem();

            // Permutation and Combination problem
            ShuffleAList.TestFisherYatesAlgo();
            CombinationsOfBinaryString.TestCombinationsOfBinaryString();
            AllCombinationsOfString.TestAllCombinationsOfString();
            AllPermutationsOfString.TestAllPermutationsOfString();
            PhoneNumberToWords.TestPhoneNumberToWords();
            AllNumbersInRangeWithDifferentDigits.TestAllNumbersInRangeWithDifferentDigits();
            DivideSetIntoTwoEqualSetsWithMinSumDiff.TestDivideSetIntoTwoEqualSetsWithMinSumDiff();
            PowerSet.TestPowerSet();
            AllCombinationsOfParenthesis.TestAllCombinationsOfParenthesis();
            GoodDiceRoll.TestGoodDiceRoll();
            PermutationsOfValidTime.TestPermutationsOfValidTime();

            // Tree Problems
            TreeFromExpression.TestCreateTreeFromExpression();
            TestBinarySearchTree.TestDifferentOperationsOnBST();
            AncestorOfTwoNodesInBST.TestAncestorOfTwoNodesInBST();
            CheckBTisBST.TestCheckBTisBST();
            MaxSumOnTreeBranch.TestMaxSum();
            WalkTheTree.TestWalkTheTree();
            SkewedBSTToCompleteBST.TestConvertSkewedBSTToCompleteBST();
            CheckIfTheTreeIsBalanced.TestIsTreeBalanced();
            LinkedListOfTreeNodesAtEachDepth.TestCreateLinkedListOfTreeNodesAtEachDepth();
            PrintBinaryTreeNodeAtEachLevel.TestPrintBinaryTreeNodeAtEachLevel();
            PrintBinaryTreeNodeAtEachLevelSpirally.TestPrintBinaryTreeNodeAtEachLevelSpirally();
            TreeSubtreeOfAnother.TestMatchTree();
            AncestorOfTwoNodesInBT.TestGetAncestorOfTwoNodesInBT();
            AncestorOfMultiNodesInBT.TestAncestorOfMultiNodesInBT();
            LinkedListFromLeavesOfBT.TestLinkedListFromLeavesOfBT();
            ExteriorOfBT.TestPrintExteriorOfBT();
            DepthOfTree.TestGetDepthOfTree();
            TreeToColumns.TestTreeToColumns();
            KthSmallestElementFromBST.TestKthSmallestElementFromBST();
            MakeBSTFromPreOrder.TestMakeBSTFromPreOrder();
            MirrorATree.TestMirrorATree();
            CloneABTWithRandPointer.TestCloneABTWithRandPointer();
            TreeWithInorderAndPreorder.TestTreeWithInorderAndPreorder();
            TreeWithInorderAndPostorder.TestTreeWithInorderAndPostorder();
            TreePathSumsToValue.TestTreePathSumsToValue();
            AllPathInNArayTree.TestAllPathInNArayTree();
            SerializeDeserializeBinaryTree.TestSerializeDeserializeBinaryTree();
            SerializeDeserializeAnNaryTree.TestSerializeDeserializeAnNaryTree();
            AncestorOfTwoNodesInNaryTree.TestAncestorOfTwoNodesInNaryTree();
            AbsOfMaxAndSecondMaxDepthInBT.TestGetAbsOfMaxAndSecondMaxDepthInBT();

            // Trie problems
            CreateAndSearchSimpleTrie.TestCreateAndSearchSimpleTrie();
            // ToDo: have a problem of suffix trees
            ShortestPrefix.TestGetShortestPrefixNotPresentInStringSet();

            // Dynamic Programming problems
            LongestCommonSubsequence.TestGetLongestCommonSubsequence();
            LongestPalindromeSubString.TestGetLongestPalindromeSubString();
            LongestPalindromicSubsequence.TestGetLongestPalindromicSubsequence();
            MaximumAs.TestGetMaximumAs();
            MinNumberOfJumps.TestGetMinimumNumberOfJumps();
            LongestCommonSubString.TestGetLongestCommonSubString();
            KnapSackProblem.TestGetTheMaximumValueWithLimitedWeight();
            TreeCuttingProblem.TestGetTreeCuttingToMaximizeProfits();
            WordBreaking.TestBreakTheWords();
            DistanceOfWords.TestDistanceOfWords();
            LongestIncreasingSubSequence.TestLongestIncreasingSubSequence();
            MinCostPath.TestMinCostPath();
            DifferentWaysForCoinChange.TestDifferentWaysForCoinChange();
            MatrixMultiplication.TestMatrixMultiplication();
            BinomialCoefficient.TestBinomialCoefficient();
            BoxStacking.TestBoxStacking();
            WordWrapping.TestWordWrapping();
            MaxSubMatrixWithAllOnes.TestMaxSubMatrixWithAllOnes();
            LongestSubStringWithEqualSum.TestLongestSubStringWithEqualSum();
            PartitionArrayIntoEqualSumSets.TestPartitionArrayIntoEqualSumSets();
            MaxSumRectangle.TestMaxSumRectangle();
            RegularExpressionMatch.TestRegularExpressionMatch();
            NumRepresentedByPerfectSquares.TestNumRepresentedByPerfectSquares();
            LongestCommonSubsequenceInSameString.TestLongestCommonSubsequenceInSameString();
            StringDecodeAsAlphabets.TestStringDecodeAsAlphabets();
            BalloonBursting.TestBalloonBursting();
            TravellingSalesmanProblem.TestTravellingSalesmanProblem();
            MaxSumWithoutAdjacentElements.TestMaxSumWithoutAdjacentElements();
            MaxPathThroughMatrix.TestMaxPathThroughMatrix();
            BrickLaying.TestBrickLaying();
            JobSchedullingWithConstraints.TestJobSchedullingWithConstraints();
            EggDropMinTrials.TestEggDropMinTrials();

            // Graph Problems
            ShortestPath.TestGetShortestPathBetween2Vertex();
            CycleInDirectedGraph.TestIsCycleInDirectedGraph();
            CycleInUnDirectedGraph.TestIsCycleInUnDirectedGraph();
            SolveAMaze.TestSolveAMaze();
            AllPathsGivenStartEndVertex.TestGetAllPathsInGraphFromStartVertexToEndVertex();
            AllPaths.TestGetAllPathsInGraphFromStartVertex();
            ColorVertices.TestColorVerticesWithDifferentColor();
            CheckBipartiteGraph.TestCheckBipartiteGraph();
            TransformOneWordToAnother.TestGetTransformation();
            ConstraintsVerification.TestConstraintsVerification();
            ExtendedContactsInSocialNetwork.TestComputeExtendedContacts();
            CourseScheduling.TestCourseScheduling();
            SnakeAndLadder.TestSnakeAndLadder();
            IsGraphATree.TestIsGraphATree();
            ReverseGraph.TestReverseGraph();
            StronglyConnectedGraph.TestStronglyConnectedGraph();
            ConnectedComponents.TestConnectedComponents();
            ContinentalDivide.TestContinentalDivide();
            CloneGraph.TestCloneGraph();
            Wordament.TestWordament();
            // ShortestPathAlgo
            FloydWarshall.TestFloydWarshall();
            DijkstraAlgorithm.TestDijkstraAlgorithm();
            BellmanFord.TestBellmanFord();
            TravelFromLeftToRightInMatrix.TestTravelFromLeftToRightInMatrix();
            HeuristicSearch.TestHeuristicSearch();
            AStar.TestAStar();
            ShortestPathWhenObstaclesRemoved.TestShortestPathWhenObstaclesRemoved();
            ShortestDistanceFromRoomsToGates.TestShortestDistanceFromRoomsToGates();
            //MaxFlow
            FordFulkersonEdmondKarp.TestFordFulkersonEdmondKarp();
            MinCut.TestMinCut();
            MaximumBipartiteMatching.TestMaximumBipartiteMatching();
            //Minimum Spanning Tree
            KruskalAlgorithm.TestKruskalAlgorithm();
            PrimsAlgorithm.TestPrimsAlgorithm();


            //Heap problems
            BasicMaxHeap.TestMaxHeap();
            BasicMinHeap.TestMinHeap();
            TestMinHeapMap.DoTest();
            TestPriorityQueue.Run();
            MedianForAStreamOfNumbers.TestMedianForAStreamOfNumbers();

            //DisjointSets
            TestingDisjointSet.Run();
            //TestWeightedDisjointSetsWithPathCompression.Run(); // this runs slow, hence commenting it

            //Geometry
            ClosestPairOfPoints.TestClosestPairOfPoints();
            RectangleIntersection.TestRectangleIntersection();
            LineSegmentIntersection.TestLineSegmentIntersection();
            ConvexHull.TestConvexHull();
            KClosestPointToOrigin.TestKClosestPointToOrigin();

            //Greedy Algorithm
            HuffmanCoding.TestHuffmanCoding();

            //Randomized Algorithm
            RandomGeneration.TestRandomGeneration();

            // Bit Algorithms
            IntHaveOppositeSigns.TestIntHaveOppositeSigns();
            Parity.TestParity();

            //Math Problem
            ZerosInFactorial.TestZerosInFactorial();
            GetAllPrimeFactors.TestGetAllPrimeFactors();
            NumberOfFactors.TestNumberOfFactors();
            AllFactors.TestAllFactors();
            MultiplyLongNumbers.TestMultiplyLongNumbers();
            NextLargestPermutation.TestNextLargestPermutation();
            AllPrimesTillN.TestAllPrimesTillN();
            PascalsTriangle.TestPascalsTriangle();
            SubtractLongNumbers.TestSubtractLongNumbers();

            //Search problems
            SearchInSortedRotatedArray.TestSearchInSortedRotatedArray();
            KClosestElementInArray.TestKClosestElementInArray();
            SearchInSortedMatrix.TestSearchInSortedMatrix();
            BinarySearchUnbounded.TestBinarySearchUnbounded();
            LinkedListSublistSearch.TestLinkedListSublistSearch();
            NoOfOccuranceInSortedArray.TestNoOfOccuranceInSortedArray();
            GetSmallestInSortedRotatedArray.TestGetSmallestInSortedRotatedArray();

            //Distributed algorithms
            KWayMerge.TestKWayMerge();


            Console.ReadLine();
        }