public void PrimsAlgorithmExecuteTest() { Func <IGraphEdge, Double> weightFunction = edge => Convert.ToDouble(edge["Weight"]); IDictionary <OperationParameter, Object> parameters = new Dictionary <OperationParameter, Object>(); parameters[GraphOperationParameters.WeightMetric] = weightFunction; parameters[GraphOperationParameters.SourceVertex] = _sourceVertex; PrimsAlgorithm operation = new PrimsAlgorithm(_sourceGraph, parameters); operation.Execute(); Assert.AreEqual(_resultGraph.VertexCount, operation.Result.VertexCount); Assert.AreEqual(_resultGraph.EdgeCount, operation.Result.EdgeCount); foreach (IGraphEdge resultEdge in operation.Result.Edges) { IGraphEdge edge = _resultGraph.GetEdge(resultEdge.Source.Coordinate, resultEdge.Target.Coordinate); Assert.IsNotNull(edge); Assert.AreEqual(resultEdge.Source.Coordinate, edge.Source.Coordinate); Assert.AreEqual(resultEdge.Target.Coordinate, edge.Target.Coordinate); Assert.AreEqual(resultEdge.Metadata, edge.Metadata); } }
public void MinimumSpanningTreeWeightForNeighborNodeIsEqualEdgeWeight() { var sut = new PrimsAlgorithm(); var graph = new[] { new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 0, Weight = 1, To = 1 } } }, new WeightedGraphVertex { } }; Assert.Equal(1, sut.GetMinimumSpanningTreeWeight(graph)); }
public void TestPrimsAlgorithm() { Graph <int> g = new Graph <int>(false); List <Vertex <int> > vertices = new List <Vertex <int> >(); for (int i = 1; i < 15; i++) { vertices.Add(g.AddVertex(i)); } AddEdge(g, vertices, 1, 2, 5); AddEdge(g, vertices, 1, 5, 4); AddEdge(g, vertices, 2, 4, 10); AddEdge(g, vertices, 2, 3, 6); AddEdge(g, vertices, 3, 4, 2); AddEdge(g, vertices, 3, 5, 6); AddEdge(g, vertices, 3, 7, 4); AddEdge(g, vertices, 5, 6, 1); AddEdge(g, vertices, 6, 7, 1); AddEdge(g, vertices, 6, 8, 9); AddEdge(g, vertices, 6, 9, 5); AddEdge(g, vertices, 7, 9, 3); AddEdge(g, vertices, 7, 10, 4); AddEdge(g, vertices, 9, 10, 6); AddEdge(g, vertices, 9, 12, 2); AddEdge(g, vertices, 11, 12, 9); AddEdge(g, vertices, 11, 13, 8); AddEdge(g, vertices, 13, 14, 6); Graph <int> result = PrimsAlgorithm <int> .FindMinimalSpanningTree(g, vertices[0]); Assert.AreEqual(result.ContainsEdge(1, 2), true); Assert.AreEqual(result.ContainsEdge(1, 5), true); Assert.AreEqual(result.ContainsEdge(5, 6), true); Assert.AreEqual(result.ContainsEdge(6, 8), true); Assert.AreEqual(result.ContainsEdge(6, 7), true); Assert.AreEqual(result.ContainsEdge(7, 3), true); Assert.AreEqual(result.ContainsEdge(3, 4), true); Assert.AreEqual(result.ContainsEdge(7, 9), true); Assert.AreEqual(result.ContainsEdge(7, 10), true); Assert.AreEqual(result.ContainsEdge(9, 12), true); Assert.AreEqual(result.ContainsEdge(12, 11), true); Assert.AreEqual(result.ContainsEdge(11, 13), true); Assert.AreEqual(result.ContainsEdge(13, 14), true); Assert.AreEqual(result.EdgeCount, 13); double totalCost = 0; using (IEnumerator <Edge <int> > enumerator = result.Edges) { while (enumerator.MoveNext()) { totalCost += enumerator.Current.Weight; } } Assert.AreEqual(totalCost, 58); }
public void MinimumSpanningTreeWeightIsClculatedForGraphWithCycle() { var sut = new PrimsAlgorithm(); var graph = new[] { new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 0, Weight = 1, To = 1 }, new WeightedGraphNodeEdge { From = 0, Weight = 5, To = 2 } } }, new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 1, Weight = 2, To = 2 } } }, new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 2, Weight = 2, To = 0 } } } }; Assert.Equal(3, sut.GetMinimumSpanningTreeWeight(graph)); }
public void PrimsSolvableTest() { for (int setNumber = 0; setNumber < TEST_SET_SIZE; setNumber++) { PrimsAlgorithm pa = new PrimsAlgorithm(); IMazeFactory factory = pa; ISolver solver = new RecursiveBacktracker(); Maze prismMaze = factory.generate(ROWS_COUNT, COLUMNSCOUNT); Assert.IsTrue(solver.IsSolvable(prismMaze)); } }
public void PrimsAlgorithmGenerateTest() { int rowCount = 10; int columnCount = 10; IMazeFactory pa = new PrimsAlgorithm(); Maze maze = pa.generate(rowCount, columnCount); Assert.IsInstanceOfType(maze, typeof(Maze)); Assert.IsNotNull(maze.Entrance);; Assert.IsNotNull(maze.Exit); Assert.AreEqual(rowCount, maze.RowsCount); Assert.AreEqual(columnCount, maze.ColumnsCount); }
public void MinimumSpanningTreeWeightForOneNodeGraphIsZero() { var sut = new PrimsAlgorithm(); var graph = new[] { new WeightedGraphVertex { } }; Assert.Equal(0, sut.GetMinimumSpanningTreeWeight(graph)); }
public void BuildMaze(int index) { if (MazeWidth < 5 || MazeHeight < 5) { MazeWidth = 5; MazeHeight = 5; } if (seed == null) { seed = "Du hast vergessen einen Seed einzugeben"; } if (index == 0) { dfsScript = gameObject.AddComponent<MazeGeneratorDFS>() as MazeGeneratorDFS; dfsScript.setVariables (XTile, ITile, LTile, DeadendTile, EndTile, StartTile, TTile, wallTile, MazeWidth, MazeHeight, seed, 1, waitTime,useRandomSeed); dfsScript.BuildMaze(); /* if(Application.isPlaying) { Destroy(dfsScript); } else { DestroyImmediate(dfsScript); } */ } else if (index == 1) { primScript = gameObject.AddComponent<PrimsAlgorithm>() as PrimsAlgorithm; primScript.setVariables (XTile, ITile, LTile, DeadendTile, EndTile, StartTile, TTile, wallTile, MazeWidth, MazeHeight, seed, timeToWait, useRandomSeed); if(Application.isPlaying) { if(waitTime) { primScript.mainProgramWithWaitingTime(); }else { primScript.mainProgramWithoutWaitingTime(); } } else { primScript.mainProgramWithoutWaitingTime(); } } else if(index == 2) { kruskalScript = gameObject.AddComponent<MazeScript>() as MazeScript; kruskalScript.setVariables(XTile,ITile,LTile,DeadendTile,EndTile,StartTile,TTile,wallTile,MazeWidth,MazeHeight,seed,timeToWait,useRandomSeed); if(!Application.isPlaying) { kruskalScript.test(false); } else kruskalScript.test(waitTime); } }
public void NodeDiscardedWhenCycleIsFound() { var sut = new PrimsAlgorithm(); var graph = new[] { new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 0, Weight = 1, To = 1 }, new WeightedGraphNodeEdge { From = 0, Weight = 5, To = 2 } } }, new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 1, Weight = 2, To = 2 } } }, new WeightedGraphVertex { } }; Assert.Equal(3, sut.GetMinimumSpanningTreeWeight(graph)); }
public void TestInvalidVertex() { PrimsAlgorithm <int> .FindMinimalSpanningTree(new Graph <int>(true), new Vertex <int>(5)); }
public void TestNullVertex() { PrimsAlgorithm <int> .FindMinimalSpanningTree(new Graph <int>(true), null); }
public void TestNullGraph() { PrimsAlgorithm <int> .FindMinimalSpanningTree(null, new Vertex <int>(5)); }
static void Main(string[] args) { Console.CursorVisible = false; r = new Random((int)DateTime.Now.Ticks); maze = new Maze(mazeWidth, mazeHeight); display = new char[mazeWidth * offset, mazeHeight *offset]; Console.WriteLine("Choose a type of maze to generate:\n"); Console.WriteLine("1: Recursive Backtracker"); Console.WriteLine("2: Randomised Prim's Algorithm"); var mazeOption = Console.ReadKey().Key; IMazeGenerator generator; switch (mazeOption) { case ConsoleKey.D2: generator = new PrimsAlgorithm(r); break; case ConsoleKey.D1: default: generator = new RecursiveBacktracker(r); break; } Console.Clear(); Console.WriteLine("Choose a type of solver, if any:\n"); Console.WriteLine("0: No solver"); Console.WriteLine("1: Recursive Solver"); Console.Write("2: A* Solver"); var solverOption = Console.ReadKey().Key; ISolver solver; switch (solverOption) { case ConsoleKey.D1: solver = new RecursiveSolver(maze); break; case ConsoleKey.D2: solver = new AStar(maze); break; default: solver = null; break; } while (true) { maze.InitialiseNodes(); generator.Generate(maze); Console.Clear(); for (int h = 0; h < mazeHeight; h++) { for (int w = 0; w < mazeWidth; w++) { WriteNodeChar(w, h, maze[(uint)w, (uint)h].Walls); } } if (solver != null) { Random r = new Random(); NodePtr startPoint = new NodePtr((uint)maze.Width + 1, (uint)maze.Height + 1); // Purposefully not valid NodePtr endPoint = new NodePtr((uint)maze.Width + 1, (uint)maze.Height + 1); while (true) { //TODO: Probably refactor var startPointIsValid = maze.IsPointValid(startPoint); var endPointIsValid = maze.IsPointValid(endPoint); if (startPointIsValid && endPointIsValid) { break; } if (!startPointIsValid) { startPoint = new NodePtr((uint)r.Next(maze.Width), (uint)r.Next(maze.Height)); } if (!endPointIsValid) { endPoint = new NodePtr((uint)r.Next(maze.Width), (uint)r.Next(maze.Height)); } } var solution = solver.Solve(startPoint, endPoint); if (solution != null) { WriteSolution(startPoint, endPoint, solution); Console.WriteLine(string.Format("Solving for: Start - {0}x, {1}y; End - {2}x, {3}y", startPoint.x, startPoint.y, endPoint.x, endPoint.y)); } else { Console.WriteLine("Cannot find a Solution....."); } } DrawDisplay(); Console.WriteLine(); Console.WriteLine("Press any key to regenerate, or Escape to exit...."); if (Console.ReadKey().Key == ConsoleKey.Escape) { break; } } }
public static void Main(string[] args) { WordDictionary wd = new WordDictionary(); wd.AddWord("bad"); wd.AddWord("dad"); wd.AddWord("mad"); Console.Write(wd.Search("pad")); Console.Write(wd.Search("bad")); Console.Write(wd.Search(".ad")); Console.Write(wd.Search("b..")); KClosedToOrigin kC = new KClosedToOrigin(); //int[][] points = new int[2][]; //points[0] = new int[] { 1, 0 }; //points[1] = new int[] { 0, 1 }; //kC.KClosest(points, 2); TopKWithSortedDictionary topK = new TopKWithSortedDictionary(); //topK.TopKFrequent(new int[] {1,1,1,2,2,3 }, 2); CourseScheduling_AdjMatrix_Courses courses = new CourseScheduling_AdjMatrix_Courses(); //char[][] grid = new char[4][]; //grid[0] = new char[] {'X', 'X', 'O', 'O'}; // { '1','1','0','0', '0'}; //grid[2] = new char[] { 'X', 'O', 'O', 'X' }; // { '1', '1', '0' , '0', '0' }; //grid[3] = new char[] { 'X', 'X', 'O', 'X' }; // { '0','0','1','0','0' }; //grid[1] = new char[] { 'X', 'O', 'X', 'X' }; // { '0','0','0','1','1'}; SurroundedRegions s = new SurroundedRegions(); //s.Solve(grid); NumberOfIslands n = new NumberOfIslands(); //var arr = new int[5, 4] // { // {1,1, 0, 0}, // {0,0, 1, 0}, // {0,0, 0, 0}, // {1,0, 1, 1}, // {1,1, 1, 1}, // }; //n.numberAmazonGoStores(5, 4, arr); MinCostInAGrid minC = new MinCostInAGrid(); int[][] grid = new int[4][]; grid[0] = new int[] { 1, 1, 1, 1 }; grid[1] = new int[] { 2, 2, 2, 2 }; grid[2] = new int[] { 1, 1, 1, 1 }; grid[3] = new int[] { 2, 2, 2, 2 }; //minC.MinCost(grid); //n.NumIslands(grid); CriticalRoutersInANetwork rt = new CriticalRoutersInANetwork(); //List<List<int>> ls = new List<List<int>> { // new List<int> {1,2}, // new List<int> {2,3}, // new List<int> {3,4}, // new List<int> {4,5}, // new List<int> {5,1}, //}; //rt.CriticalRouters(6,7,ls); // courses.FindOrder(4, prerequisites); // example ex = new example(); // int[] arr = new int[] {4,5,2,7,8 }; //Console.Write(ex.heapSort(arr, 5)); LevelOrder_BottomUp lvlOrder = new LevelOrder_BottomUp(); //TreeNode root = new TreeNode(5); //root.left = new TreeNode(4); //root.right = new TreeNode(8); //root.right.left = new TreeNode(13); //root.right.right = new TreeNode(4); //root.left.left = new TreeNode(11); //root.left.left.left = new TreeNode(7); //root.left.right = new TreeNode(2); //Solution sl = new Solution(); //sl.HasPathSum(root, 22); // lvlOrder.LevelOrderBottom(root); WordLadder_BFS wl = new WordLadder_BFS(); wl.LadderLength_BFS("hit", "cog", new string[] { "hot", "dot", "dog", "lot", "log", "cog" }); // WordLadder_BFS_LessEfficient wlbfs = new WordLadder_BFS_LessEfficient(); // wlbfs.FindLadders("hit","cog",new string[] { "hot", "dot", "dog", "lot", "log", "cog" }); TrieDataStructure obj = new TrieDataStructure(); // obj.InsertWord("spinclass"); //bool exists = obj.Search("spin"); // bool startsWith = obj.StartsWith("spin"); //int nodes = 3; List <List <int> > graph = new List <List <int> >(); //graph = CreateGraph(nodes); //AddEdge(graph, 0, 1); //AddEdge(graph, 0, 2); // AddEdge(graph, 1, 2); //AddEdge(graph, 2, 3); //AddEdge(graph, 3, 4); //AddEdge(graph, 2, 5); //AddEdge(graph, 5, 6); //AddEdge(graph, 6, 7); //AddEdge(graph, 7, 8); //AddEdge(graph, 8, 5); //BridgesAjacencyList bridge = new BridgesAjacencyList(graph, nodes); //List<int> bridges = bridge.FindBridges(); // print the bridges //for (int i = 0; i < bridges.Count/2; i++) //{ // int node1 = bridges[2*i]; // int node2 = bridges[2 * i + 1]; // Console.WriteLine("Bridge is between node1: " + node1.ToString() + " and node2: " + node2.ToString()); //} //ArticulationPointAdjacencyList artAdj = new ArticulationPointAdjacencyList(graph, nodes); //bool[] isArticulationPoint = artAdj.FindArticulationPoints(); //for (int i = 0; i < nodes; i++) //{ // if (isArticulationPoint[i]) // { // Console.WriteLine("ArticulationPoint is at index : " + i); // } //} CriticalConnectionsInANetwork cr = new CriticalConnectionsInANetwork(); //IList<IList<int>> connections = new List<IList<int>>(); //connections.Add(new List<int>() {0,1 }); //connections.Add(new List<int>() { 1, 2 }); //connections.Add(new List<int>() { 2,0 }); //connections.Add(new List<int>() { 1,3 }); //cr.CriticalConnections(4, connections); PrimsAlgorithm prims = new PrimsAlgorithm(); //int[,] pm = new int[,] { { 0, 2, 0, 6, 0 }, // { 2, 0, 3, 8, 5 }, // { 0, 3, 0, 0, 7 }, // { 6, 8, 0, 0, 9 }, // { 0, 5, 7, 9, 0 } }; //prims.PrimsMinSpanningTree(pm, 5); Console.ReadKey(); }
public void BaseLine() { var sut = new PrimsAlgorithm(); var graph = new[] { new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 0, To = 1, Weight = 14 }, new WeightedGraphNodeEdge { From = 0, To = 2, Weight = 9 }, new WeightedGraphNodeEdge { From = 0, To = 3, Weight = 7 } } }, new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 1, To = 4, Weight = 9 }, new WeightedGraphNodeEdge { From = 1, To = 2, Weight = 2 } } }, new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 2, To = 3, Weight = 10 }, new WeightedGraphNodeEdge { From = 2, To = 5, Weight = 11 }, new WeightedGraphNodeEdge { From = 2, To = 1, Weight = 2 }, } }, new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 3, To = 5, Weight = 15 } } }, new WeightedGraphVertex { Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge> { new WeightedGraphNodeEdge { From = 4, To = 5, Weight = 6 } } }, new WeightedGraphVertex { } }; Assert.Equal(33, sut.GetMinimumSpanningTreeWeight(graph)); }
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(); }
public void TestInit() { rng = new Random(1001); // Repeatable tests maze = new Maze(_mazeWidth, _mazeHeight); generator = new PrimsAlgorithm(rng); }