CST 370 - Module 3
Week 3,
This week's module started off with the continuation of Brute Force. This time using Brute Force with string matching problems. In short, when given a string of text and a pattern, find the pattern within the text. Using brute force, you would compare the strings character by character, and if there is a mismatch, shift a character and re-compare. This could have a fast best case scenario, however, worst case is longer than you would initially think.
The next topic involved Exhaustive Search, an algorithm which determines all possible scenarios of a solution to the problem, compares each of them, and selects the fastest/lowest cost result. For example, the Traveling Salesman Problem requires you to find the shortest path to visit all nodes once, and return to the starting nodes. Using the Exhaustive Search approach, you would first find out all the different combinations of paths to take when starting from the first node, find out how much it costs for each path, then choose the fastest path.
The following two topics are similar algorithms (Depth-First Search & Breadth-First Search) used to solving graph type problems, but have unique differences from each other. Often, graph problems require visiting all vertices and edges of a graph. Both DFS and BFS have the same goal, use an array to keep track of the order of vertices visited, and visit vertices alphabetically/chronologically. The main difference is that DFS will visit every vertex by visiting one adjacent vertex at a time, repeating the process with each iteration. Whereas BFS will visit every vertex by visiting all adjacent vertices first, then repeating the process with each iteration. It is hard to keep this explanation short and understandable within text considering this is a graph type problem. However, explaining in greater detail would take up too much of your time.
Lastly, the module included information on the Divide and Conquer technique. This involves having a problem divided into several smaller problems recursively, and if necessary, combine the divided problems' answers. An example of this is finding the sum of numbers in an array. This problem can be solved another way but it is easy to explain Divide and Conquer this way. To solve, split the array in half, and find the sum of those arrays. If you want, split those resulting arrays in half again, and find the sum of those arrays. Once all the sub-arrays have been solved, combine the results together to get the total sum of the array.
Another important aspect to the Divide and Conquer technique is finding it's time efficiency. However, this journal entry is getting too long, so I will leave it for you to research yourself.
Comments
Post a Comment