Brute Force Design Techniques and Divide-and-Conquer
This week, we learned about different exhaustive search algorithms that used a Brute-Force design technique. Exhaustive search algorithms consider every possible case before coming to a conclusion. The first algorithm discussed was the sequential search and matching algorithm. This algorithm was presented in the form of searching a string to find a pattern, such as the one below. In this algorithm, every character in a string is checked for the pattern until the end of the pattern is reached. The efficiency of this algorithm is dependent on the text and pattern. In the example below, there are 16 characters in the text and 4 characters in the pattern that we are looking for. Since we are considering all comparisons and cases, we should have 13 shifts and 52 comparisons.

Another exhaustive search was conducted for combinatorics problems. An exhaustive search can be used to solve problems such as the Traveling Salesman Problem, Knapsack Problem, and the Assignment Problem. In a video for the week, we were tasked to complete the work for the Assignment problem, which gave the number of hours each person could complete a job. Our task was to use the exhaustive method to find out what job was assigned to what person so that all jobs were completed within the minimum number of hours.  |
Job Table |
.png) |
Work for Assignment Problem |
In addition to applying exhaustive searches to combinatoric problems, we also applied exhaustive searches to graph problems. The two algorithms presented depth-first search and breadth-first search. The depth-first search uses a stack and a mark array to determine a graph traversal. The stack is used to determine if a node has been visited. It is pushed in the stack when it is first visited and popped out when it is visited again. The breadth-first search uses a queue and a mark array. In this algorithm, the vertex and its neighbors are added to the queues and popped off when it is visited. Both depth-first and breadth-first traversal need to be processed alphabetically/numerically. See below for a visual on the difference between breadth-first and depth-first searches.
Comments
Post a Comment