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

  • 22Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Search Algorithms Review
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

In the city block problem (City 1 to City n forward, then back to City 1 backward) with costs cij≥0c_{ij} \ge 0cij​≥0, which search algorithms can be used?

Tap to flipClick to flipspace

Dynamic programming (with state extended to include direction) and uniform cost search.

Or swipe the card

22 cards

  1. In the city block problem (City 1 to City n forward, then back to City 1 backward) with costs cij≥0c_{ij} \ge 0cij​≥0, which search algorithms can be used?

    Dynamic programming (with state extended to include direction) and uniform cost search.

  2. Why can't depth-first search be used in the city block problem?

    DFS requires all edge costs to be zero, but here cij≥0c_{ij} \ge 0cij​≥0 and not necessarily zero.

  3. Why can't breadth-first search be used in the city block problem?

    BFS requires all edge costs to be identical (equal), which is not guaranteed here.

  4. How can dynamic programming be applied to the city block problem despite possible cycles?

    By extending the state to include both the city and the direction of travel (forward or backward), breaking the cycle.

  5. Define state in the context of search problems.

    A state is a summary of all past actions that is sufficient to choose future actions optimally.

  6. List the components of a search problem formulation.

    sstarts_{\text{start}}sstart​, actions(s)\text{actions}(s)actions(s), cost(s,a)\text{cost}(s,a)cost(s,a), successor(s,a)\text{successor}(s,a)successor(s,a), and end(s)\text{end}(s)end(s).

  7. Describe the uniform cost search (UCS) algorithm.

    Maintain a priority queue (frontier) ordered by past cost. Pop the state with minimum cost. If it is an end state, return its cost. Otherwise, for each successor, update the frontier with cost = past cost + edge cost.

  8. What is the correctness theorem for uniform cost search?

    When a state sss is popped from the frontier, its priority (past cost) is the minimum cost to reach sss.

  9. Compare dynamic programming and uniform cost search in terms of cycles, costs, and complexity.

    DP: no cycles allowed, any costs (including negative), O(n)O(n)O(n); UCS: cycles allowed, costs must be non-negative, O(nlog⁡n)O(n \log n)O(nlogn).

  10. What is the inverse problem of search?

    Given an optimal sequence of actions (path), learn the cost function that led to it.

  11. Explain the update rule of the structured perceptron algorithm for learning action costs.

    Initialize w=0w = 0w=0. For each training example (true path yyy), compute predicted path y′y'y′ under current www. If y≠y′y \neq y'y=y′, for each action aaa: if a∈ya \in ya∈y, w[a]←w[a]−1w[a] \gets w[a] - 1w[a]←w[a]−1; if a∈y′a \in y'a∈y′, w[a]←w[a]+1w[a] \gets w[a] + 1w[a]←w[a]+1.

  12. In the transportation example with walking and tram, what is the result of structured perceptron with training data containing only walks?

    The algorithm may not recover true costs (e.g., walk=1, tram=2) but finds weights that make walking optimal (e.g., walk=1, tram=3). The ratio matters, and missing data leads to underdetermined solution.

  13. How does the structured perceptron generalize to state-dependent costs?

    Cost is w⋅ϕ(s,a)w \cdot \phi(s,a)w⋅ϕ(s,a) where ϕ\phiϕ are features. Update: w←w−∑(s,a)∈true pathϕ(s,a)+∑(s,a)∈predicted pathϕ(s,a)w \gets w - \sum_{(s,a) \in \text{true path}} \phi(s,a) + \sum_{(s,a) \in \text{predicted path}} \phi(s,a)w←w−∑(s,a)∈true path​ϕ(s,a)+∑(s,a)∈predicted path​ϕ(s,a).

  14. What is the key idea behind A* search?

    Explores states in order of g(s)+h(s)g(s) + h(s)g(s)+h(s), where g(s)g(s)g(s) is past cost and h(s)h(s)h(s) is a heuristic estimate of future cost.

  15. How is A* search implemented as a modification of uniform cost search?

    Replace edge cost c(s,a)c(s,a)c(s,a) with c′(s,a)=c(s,a)+h(successor)−h(s)c'(s,a) = c(s,a) + h(\text{successor}) - h(s)c′(s,a)=c(s,a)+h(successor)−h(s) and run UCS on the modified costs.

  16. Define a consistent heuristic.

    A heuristic hhh is consistent if c(s,a)+h(s′)≥h(s)c(s,a) + h(s') \ge h(s)c(s,a)+h(s′)≥h(s) for all states sss, actions aaa, and successor s′s's′, and h(send)=0h(s_{\text{end}}) = 0h(send​)=0.

  17. Why does A* return the optimal solution when using a consistent heuristic?

    The sum of modified costs along any path equals the sum of original costs minus h(sstart)h(s_{\text{start}})h(sstart​), a constant, so the optimal path under modified costs is also optimal under original costs.

  18. How does A* compare to UCS in terms of states explored?

    A* explores states with g(s)<g(send)−h(s)g(s) < g(s_{\text{end}}) - h(s)g(s)<g(send​)−h(s), while UCS explores states with g(s)<g(send)g(s) < g(s_{\text{end}})g(s)<g(send​). A* explores fewer states, especially when hhh is large.

  19. What is an admissible heuristic?

    A heuristic hhh is admissible if h(s)≤FutureCost(s)h(s) \le \text{FutureCost}(s)h(s)≤FutureCost(s) for all states sss.

  20. How are heuristics typically derived?

    By relaxing the problem: removing constraints to create an easier problem whose optimal cost can be computed cheaply (e.g., closed form, DP, UCS).

  21. Give an example of relaxation for a grid pathfinding problem with walls.

    Remove all walls; the heuristic becomes Manhattan distance from current cell to goal.

  22. How can a heuristic be computed for a problem where the relaxed problem is not trivial?

    Solve the relaxed problem optimally for every state using DP or UCS (with a reverse graph), and use the resulting costs as heuristic values.

Card 1 of 22
Card 1 of 22

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent