Tuesday, January 28, 2025

CST370 - Week 3

In this week's module, we covered brute force & exhaustive search, breadth-first search, depth-first search, and the master theorem. Brute force is a simple method of solving problems by just trying every possible outcome. For example, when considering the traveling salesman problem, just attempt all the possible paths and compare them to find which is the least cost. Breadth-first searches consider all the nodes at one level of a graph, before moving onto the next while depth-first searches involve following a path to its deepest point before coming back and checking other routes. Luckily, these were problems I'd practiced often in the path so I felt a little more confident with the material this week.

For the first part of the homework, we were to output a mark array after simulating a depth-first search. This part wasn't so bad to implement once I drew out the logic. The second part was a little more tricky to figure out. We needed to use permutations to solve the traveling salesman problem. I managed to pass all the available tests, but I feel the way that I stored the data and compared routes was a little.. messy.. to say the least. Hopefully, I will have time to review my code with the professor or the TA once it has been graded.

No comments:

Post a Comment