CST 370 - Design and Analysis of Algorithms - Week 3

 



This week in CST370, we focused on understanding various brute force and exhaustive search algorithms, such as string matching, depth-first search and breadth-first search. I learned that brute force is a straightforward approach to solving problems by directly applying the problem's definition. For instance, selection sort and bubble sort are classic examples of brute force algorithms where elements are compared and swapped until the array is sorted. The brute force string matching algorithm was particularly insightful, as it involves searching for a pattern in a given text through character by character comparisons. We also learned about its efficiency in terms of best case and worst case scenarios, noting that its average case efficiency is linear, Θ(n). This helped me understand the importance of time complexity when analyzing algorithms and how different cases affect performance.

In addition to brute force algorithms, we learned about exhaustive search approaches, such as the Traveling Salesman Problem (TSP), knapsack problem, and assignment problem. The TSP requires generating all permutations of cities to find the shortest possible route, which results in a time complexity of (n-1)!, making it inefficient for large inputs. Similarly, the knapsack problem deals with selecting the most valuable subset of items under capacity constraints, requiring 2ⁿ subsets to be considered. The assignment problem introduced the concept of permutations where n! unique job per person assignments must be evaluated to find the optimal solution. Finally, we covered graph traversal techniques such as Depth-First Search (DFS), which processes vertices systematically using a stack and mark array. I learned more about DFS's time efficiency when using adjacency matrices versus adjacency lists, helping me see how different data structures impact performance.

Comments

Popular posts from this blog

CST 334 - Operating Systems - Week 6

CST 363 - Introduction to Database - Week 3

CST 311 - Intro to Computer Networks - Week 1