1. Home
  2. Explore
  3. Computer Science
  4. Search Algorithms Lecture

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Search Algorithms Lecture

Speaker 1Speaker 2

Search Algorithms Lecture

5:29
0:00-5:29
  1. Simon

    Alright, Hope, so we're diving into search problems today. The lecture started with a review—they had this city block problem where you travel from City 1 to City n forward, then back to City 1 backward. The goal was to figure out which algorithms could handle it: depth-first search, breadth-first search, dynamic programming, and uniform cost search.

  2. Hope

    Right, and the twist was that the edge costs were non-negative but not necessarily zero or equal. So DFS and BFS were out immediately because they rely on zero or equal costs. But DP and UCS could work, even with cycles, if you incorporate the direction into the state.

  3. Simon

    Exactly! That's a key point—defining the state properly. In that problem, you need to track both the city and whether you're going forward or backward. That breaks the cycle and lets you use DP. UCS handles cycles naturally anyway, as long as costs are non-negative.

  4. Hope

    So that review led into the formal definition of a search problem: a start state, actions, a cost function, a successor function, and a goal test. Then they started classifying inference algorithms—tree search like DFS, BFS, iterative deepening, and graph search like UCS and DP.

  5. Simon

    And they spent time on Uniform Cost Search. The pseudocode uses a priority queue for the frontier. You pop the state with the smallest past cost, check if it's a goal, then expand its neighbors, updating the frontier if you find a better path. It's exactly Dijkstra's algorithm but stops when you pop a goal state.

  6. Hope

    There was also a correctness proof. The idea is that when you pop state s from the frontier, its priority—the past cost—is the minimum possible cost to reach s. The proof uses the fact that any alternative path must leave the explored set at some point, and the cost of that path is at least the priority of s because of the order you expand nodes.

  7. Simon

    Right. And then they compared DP and UCS. DP is O(n) but can't handle cycles; UCS is O(n log n) but works with cycles and non-negative costs. For negative costs, you'd need Bellman-Ford, but that's beyond the scope.

  8. Hope

    Now, the interesting shift was from inference to learning. In search, we're given costs and asked to find the optimal path. But what if we don't know the costs? That's the inverse problem: given the optimal path, can we learn the costs?

  9. Simon

    Yeah, and they used the transportation problem as an example. You can walk one step forward with cost w_walk or take a tram to double your position with cost w_tram. If you know the true optimal path for a given n, you can try to infer the weights. They walked through a structured perceptron algorithm.

  10. Hope

    The idea is to start with zero weights, then iteratively compute the predicted optimal path using your current weights. If the prediction doesn't match the true path, you decrease the weights for actions in the true path and increase them for actions in the prediction. That makes the true path cheaper and the predicted path more expensive.

  11. Simon

    And they showed a demo. With true weights 1 and 2, and training data from n=1 to 10, the algorithm converged to those exact weights after one mistake iteration. But if the training data only consisted of walking paths, it couldn't learn the tram cost properly—it would find weights that work for the data but don't match the true values.

  12. Hope

    That's an important point: the algorithm only fits the training data. If you want to recover the true costs, you need diverse data that includes different paths. They also mentioned that the general form uses features, so the cost of a path is w times the sum of feature vectors. That's used in NLP for tasks like part-of-speech tagging.

  13. Simon

    Then the lecture moved to A* search, which is a smarter version of UCS. Instead of ordering by past cost alone, A* uses past cost plus a heuristic that estimates the remaining future cost. This focuses the search toward the goal, making it more efficient.

  14. Hope

    The trick is that A* transforms the original costs: cost_prime(s,a) = cost(s,a) + h(successor) - h(s). Then it runs UCS on those modified costs. If the heuristic is consistent—meaning it satisfies the triangle inequality and h(goal)=0—then A* is correct and returns the optimal solution.

  15. Simon

    Consistency ensures that cost_prime is non-negative and that the total cost of any path using the modified costs equals the original cost minus the heuristic at the start, which is a constant. So optimizing the modified cost is equivalent to optimizing the original cost.

  16. Hope

    And A* is more efficient than UCS because it explores fewer states. UCS explores all states with past cost less than the cost to the goal. A* explores states with past cost less than that minus the heuristic. So a larger, more accurate heuristic leads to a smaller search space.

  17. Simon

    They also mentioned admissibility—a heuristic is admissible if it never overestimates the true future cost. Consistency implies admissibility. And if you have a consistent heuristic, A* is both optimal and efficient.

  18. Hope

    Finally, they talked about how to come up with heuristics: by relaxing the problem. For example, in a grid with walls, you can ignore the walls and use Manhattan distance. For the tram problem with a constraint like 'no more trams than walks,' you can drop that constraint and solve the relaxed problem. The optimal cost of the relaxed problem from each state gives you a heuristic for the original problem.

  19. Simon

    Right, and sometimes you can break the problem into independent subproblems. In the 8-puzzle, you can allow tiles to overlap, making each tile's movement independent. The Manhattan distance for each tile sums to a heuristic. That's a powerful way to get good estimates without solving the full, hard problem.

  20. Hope

    So overall, the lecture covered the full pipeline: formalizing search, performing inference with algorithms like UCS and DP, learning costs from data using structured perceptron, and speeding up search with A* and heuristics via relaxation.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent