1. Home
  2. Explore
  3. Computer Science
  4. Search in AI

Study methods

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

Search in AI

  • 28Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Agents: Reflex vs Planning

What is the key characteristic of a reflex agent?

28 questions

  1. 1

    What is the key characteristic of a reflex agent?

    1. A

      It chooses actions based on current percept and memory, without considering future consequences.

    2. B

      It uses a model of the world to simulate long-term outcomes.

    3. C

      It replans its actions after every step based on new information.

    4. D

      It always considers the future consequences of its actions before deciding.

    Correct answer
    A

    It chooses actions based on current percept and memory, without considering future consequences.

    Explanation

    A reflex agent selects actions based on its current percept and possibly memory, but it does not consider the future consequences of its actions. Planning agents do consider future consequences.

  2. 2

    Can a reflex agent be rational?

    1. A

      Yes, because it always follows a precomputed optimal policy.

    2. B

      Yes, in specific circumstances where the reflex happens to produce the optimal action.

    3. C

      No, because it never considers future consequences, so it cannot be rational.

    4. D

      No, because rationality requires considering all possible future states.

    Correct answer
    B

    Yes, in specific circumstances where the reflex happens to produce the optimal action.

    Explanation

    A reflex agent can be rational in specific circumstances if the reflex action matches the rational action, but in general it cannot be rational because it cannot handle every possible state.

  3. 3

    What must a planning agent have to make decisions based on consequences?

    1. A

      A large table mapping every state to the best action.

    2. B

      A model of how the world evolves in response to actions and a goal test.

    3. C

      A reflex that always works in all environments.

    4. D

      A random action selector to explore all possibilities.

    Correct answer
    B

    A model of how the world evolves in response to actions and a goal test.

    Explanation

    A planning agent needs a model of the world's dynamics (successor function) and a goal test to evaluate possible future states. It cannot rely solely on reflexes or precomputed tables.

  4. 4

    Which of the following is NOT a component of a search problem?

    1. A

      A set of states

    2. B

      A successor function with actions and costs

    3. C

      A start state and a goal test

    4. D

      A heuristic function to estimate distance to the goal

    Correct answer
    D

    A heuristic function to estimate distance to the goal

    Explanation

    A search problem consists of states, a successor function (actions and costs), a start state, and a goal test. A heuristic function is used in informed search, not in the definition of the search problem itself.

  5. 5

    What is a solution to a search problem?

    1. A

      A sequence of actions that transforms the start state into a goal state.

    2. B

      A set of all possible paths from start to goal.

    3. C

      A state that satisfies the goal test.

    4. D

      A single action that immediately achieves the goal.

    Correct answer
    A

    A sequence of actions that transforms the start state into a goal state.

    Explanation

    A solution is a plan (sequence of actions) that, when executed from the start state, leads to a goal state. It is not just a single action or a set of paths.

  6. 6

    Why is abstraction used in search problems?

    1. A

      To ignore irrelevant details of the real world, making the problem feasible.

    2. B

      To increase the state space size for better planning.

    3. C

      To ensure the search algorithm is complete.

    4. D

      To include every possible detail for accurate modeling.

    Correct answer
    A

    To ignore irrelevant details of the real world, making the problem feasible.

    Explanation

    Abstraction simplifies the real world by keeping only details relevant to the problem, reducing the state space and making search feasible. Including all details would make the problem intractable.

  7. 7

    In the Pac-Man pathing problem, what constitutes the search state?

    1. A

      Pac-Man's coordinates and the positions of all walls.

    2. B

      Pac-Man's coordinates, dot positions, ghost positions, and direction facing.

    3. C

      Pac-Man's coordinates and the positions of all dots.

    4. D

      Pac-Man's coordinates only.

    Correct answer
    D

    Pac-Man's coordinates only.

    Explanation

    For pathing, the goal is to reach a specific location, so only the current coordinates are needed. Dot positions, ghosts, etc., are irrelevant for that goal.

  8. 8

    In the eat-all-the-dots problem, what additional information must the search state include compared to the pathing problem?

    1. A

      The positions of all ghosts.

    2. B

      A Boolean for each possible dot location indicating whether the dot is still present.

    3. C

      The total score accumulated so far.

    4. D

      The direction Pac-Man is facing.

    Correct answer
    B

    A Boolean for each possible dot location indicating whether the dot is still present.

    Explanation

    To know if all dots are eaten, the state must track which dots remain. Ghost positions and direction are not needed for the basic eat-all-dots goal.

  9. 9

    If the goal is to eat all dots and keep ghosts perma-scared, what extra element must the search state track?

    1. A

      The current score.

    2. B

      The number of ghosts still alive.

    3. C

      The remaining time of the scared effect.

    4. D

      The positions of power pellets only.

    Correct answer
    C

    The remaining time of the scared effect.

    Explanation

    To keep ghosts scared, the agent must know how much time is left before they become dangerous again. This timing affects future actions and must be part of the state.

  10. 10

    What is the difference between a world state and a search state?

    1. A

      A world state is a subset of the search state.

    2. B

      They are the same thing; the terms are interchangeable.

    3. C

      A search state includes future predictions, while a world state is only the present.

    4. D

      A search state includes only details needed for planning, while a world state includes every detail of the environment.

    Correct answer
    D

    A search state includes only details needed for planning, while a world state includes every detail of the environment.

    Explanation

    The world state is the complete configuration of the environment, while the search state is an abstraction that contains only the information relevant to planning.

  11. 11

    In the state space graph of a search problem, how is each state represented?

    1. A

      Each state can appear multiple times depending on the path taken.

    2. B

      States are connected by actions, but some states may be repeated.

    3. C

      The graph is a tree with no cycles.

    4. D

      Each state occurs only once.

    Correct answer
    D

    Each state occurs only once.

    Explanation

    A state space graph is a mathematical representation where each distinct state is a node, and arcs represent transitions. Each state appears exactly once, unlike a search tree where paths can lead to the same state multiple times.

  12. 12

    Why can the search tree be infinite even if the state space graph is finite?

    1. A

      Because cycles in the graph produce infinite paths in the tree.

    2. B

      Because the branching factor is infinite.

    3. C

      Because the goal test is never satisfied.

    4. D

      Because the search tree includes all possible worlds.

    Correct answer
    A

    Because cycles in the graph produce infinite paths in the tree.

    Explanation

    If the state space graph contains cycles, the search tree can have infinitely many nodes corresponding to repeated states via different paths. Each cycle can be repeated indefinitely.

  13. 13

    In the general tree search algorithm, what is the fringe?

    1. A

      The set of all nodes that have been expanded.

    2. B

      The set of goal states.

    3. C

      The set of partial plans (paths) under consideration for expansion.

    4. D

      The set of actions available from the current state.

    Correct answer
    C

    The set of partial plans (paths) under consideration for expansion.

    Explanation

    The fringe (or frontier) contains the leaf nodes of the search tree that have not yet been expanded. These represent partial plans that will be considered for further exploration.

  14. 14

    What data structure does depth-first search (DFS) use to manage the fringe?

    1. A

      A priority queue ordered by path cost.

    2. B

      A queue (first-in, first-out).

    3. C

      A set of visited states.

    4. D

      A stack (last-in, first-out).

    Correct answer
    D

    A stack (last-in, first-out).

    Explanation

    DFS uses a stack, so the most recently added node is expanded first, leading to deep exploration before breadth.

  15. 15

    Under what condition is depth-first search complete?

    1. A

      If the branching factor is at least 2.

    2. B

      If the state space is finite and cycles are avoided.

    3. C

      If the search tree has a finite maximum depth.

    4. D

      If all actions have uniform cost.

    Correct answer
    C

    If the search tree has a finite maximum depth.

    Explanation

    DFS can get stuck in infinite loops if there are cycles. It is complete only if the search tree depth is bounded (e.g., by a depth limit) or if cycles are explicitly prevented.

  16. 16

    What is the time complexity of depth-first search in the worst case, assuming a maximum depth m and branching factor b?

    1. A

      O(mb)O(m^b)O(mb)

    2. B

      O(bm)O(bm)O(bm)

    3. C

      O(b+m)O(b+m)O(b+m)

    4. D

      O(bm)O(b^m)O(bm)

    Correct answer
    D

    O(bm)O(b^m)O(bm)

    Explanation

    In the worst case, DFS may explore the entire tree, which has 1+b+b2+...+bm=O(bm)1 + b + b^2 + ... + b^m = O(b^m)1+b+b2+...+bm=O(bm) nodes.

  17. 17

    What is the space complexity of depth-first search in the worst case?

    1. A

      O(bm)O(b^m)O(bm)

    2. B

      O(bm)O(bm)O(bm)

    3. C

      O(m)O(m)O(m)

    4. D

      O(b)O(b)O(b)

    Correct answer
    B

    O(bm)O(bm)O(bm)

    Explanation

    DFS only stores nodes along the current path and their siblings. At maximum depth m, it stores up to bbb nodes at each of the m levels, so O(bm)O(bm)O(bm) space.

  18. 18

    Which of the following is a property of breadth-first search (BFS)?

    1. A

      It is optimal only if all actions have the same cost.

    2. B

      It uses a stack and expands the deepest node first.

    3. C

      It has space complexity O(bm)O(bm)O(bm).

    4. D

      It uses a queue and expands nodes in order of depth.

    Correct answer
    D

    It uses a queue and expands nodes in order of depth.

    Explanation

    BFS uses a FIFO queue, expanding nodes level by level. It is optimal when all step costs are identical, and its space complexity is O(bs)O(b^s)O(bs) where s is the depth of the shallowest solution, not O(bm)O(bm)O(bm).

  19. 19

    What is the space complexity of breadth-first search in the worst case?

    1. A

      O(bs)O(b^s)O(bs) where s is the depth of the shallowest solution.

    2. B

      O(s)O(s)O(s)

    3. C

      O(b)O(b)O(b)

    4. D

      O(bm)O(bm)O(bm) where m is the maximum depth.

    Correct answer
    A

    O(bs)O(b^s)O(bs) where s is the depth of the shallowest solution.

    Explanation

    BFS stores the entire fringe, which at the deepest level before finding the solution can be up to bsb^sbs nodes (the number of nodes at depth s).

  20. 20

    When would you prefer depth-first search over breadth-first search?

    1. A

      When all step costs are different.

    2. B

      When memory is limited and a solution exists at a reasonable depth.

    3. C

      When the branching factor is very high.

    4. D

      When you need the optimal solution.

    Correct answer
    B

    When memory is limited and a solution exists at a reasonable depth.

    Explanation

    DFS uses much less memory than BFS (O(bm)O(bm)O(bm) vs O(bs)O(b^s)O(bs)). It can be useful when memory is constrained, though it may not find the optimal solution and may not be complete.

  21. 21

    What is the main advantage of iterative deepening search over BFS?

    1. A

      It does not require a goal test.

    2. B

      It always finds the cheapest solution regardless of costs.

    3. C

      It is faster than BFS in all cases.

    4. D

      It has the same space complexity as DFS (O(bd)O(bd)O(bd)) while being complete and optimal (for unit costs).

    Correct answer
    D

    It has the same space complexity as DFS (O(bd)O(bd)O(bd)) while being complete and optimal (for unit costs).

    Explanation

    Iterative deepening runs DFS with increasing depth limits. It combines DFS's space advantage (O(bd)O(bd)O(bd)) with BFS's completeness and optimality (for unit costs), at the cost of some time overhead.

  22. 22

    How does iterative deepening search avoid the huge time overhead of repeatedly expanding nodes at shallow depths?

    1. A

      It uses a heuristic to prune branches.

    2. B

      It remembers previously expanded nodes across iterations.

    3. C

      Most of the work is at the deepest level, so shallow levels are visited relatively few times.

    4. D

      It only expands nodes that are on the path to the goal.

    Correct answer
    C

    Most of the work is at the deepest level, so shallow levels are visited relatively few times.

    Explanation

    In a tree with branching factor b, the deepest level contains about bdb^dbd nodes, while shallow levels have exponentially fewer. The overhead of re-expanding shallow levels is small compared to the deepest level.

  23. 23

    What data structure does uniform cost search use to manage the fringe?

    1. A

      A queue (FIFO).

    2. B

      A stack (LIFO).

    3. C

      A set of visited states.

    4. D

      A priority queue ordered by the cumulative path cost.

    Correct answer
    D

    A priority queue ordered by the cumulative path cost.

    Explanation

    Uniform cost search (UCS) uses a priority queue where the node with the smallest total path cost is expanded next. This ensures it explores in order of increasing cost.

  24. 24

    When does uniform cost search return the goal node?

    1. A

      When the goal node has the smallest heuristic value.

    2. B

      As soon as the goal node is added to the fringe.

    3. C

      After all nodes have been expanded.

    4. D

      When the goal node is popped from the priority queue (i.e., when it is about to be expanded).

    Correct answer
    D

    When the goal node is popped from the priority queue (i.e., when it is about to be expanded).

    Explanation

    UCS waits until the goal node is the minimum-cost node in the fringe (i.e., when it would be expanded). This ensures that no cheaper path to the goal exists, guaranteeing optimality.

  25. 25

    What condition is necessary for uniform cost search to be complete?

    1. A

      The goal must be reachable from the start.

    2. B

      The branching factor must be finite.

    3. C

      The state space must be finite.

    4. D

      All action costs must be positive and bounded below by some epsilon>0epsilon > 0epsilon>0.

    Correct answer
    D

    All action costs must be positive and bounded below by some epsilon>0epsilon > 0epsilon>0.

    Explanation

    If action costs can approach zero (e.g., 1/2, 1/4, ...), UCS could expand infinitely many nodes with decreasing costs. A positive minimum cost ensures it will eventually expand all nodes with cost less than the optimal solution cost.

  26. 26

    What is the time complexity of uniform cost search in the worst case?

    1. A

      O(bC∗/epsilon)O(b^{C^*/epsilon})O(bC∗/epsilon) where C∗C^*C∗ is the optimal cost and epsilonepsilonepsilon is the minimum action cost.

    2. B

      O(nlogn)O(n log n)O(nlogn) where nnn is the number of states.

    3. C

      O(bs)O(b^s)O(bs) where sss is the shallowest solution depth.

    4. D

      O(bm)O(b^m)O(bm) where mmm is the maximum depth.

    Correct answer
    A

    O(bC∗/epsilon)O(b^{C^*/epsilon})O(bC∗/epsilon) where C∗C^*C∗ is the optimal cost and epsilonepsilonepsilon is the minimum action cost.

    Explanation

    UCS explores all nodes with cost less than or equal to C∗C^*C∗. The maximum depth explored can be up to C∗/epsilonC^*/epsilonC∗/epsilon, leading to worst-case exponential time in that depth with branching factor bbb.

  27. 27

    In the videos comparing DFS, BFS, and UCS on a maze with varying water depth (cost), which algorithm explored more area in shallow water first?

    1. A

      Breadth-first search.

    2. B

      Depth-first search.

    3. C

      They all explored in the same pattern.

    4. D

      Uniform cost search.

    Correct answer
    D

    Uniform cost search.

    Explanation

    UCS prioritizes low-cost regions, so it explored shallow (low-cost) water first, avoiding deep water until necessary. DFS and BFS do not consider cost.

  28. 28

    If all action costs are equal, how does uniform cost search compare to breadth-first search?

    1. A

      They are essentially the same, both exploring in order of depth.

    2. B

      BFS expands fewer nodes than UCS.

    3. C

      UCS is slower because it uses a priority queue.

    4. D

      UCS is optimal while BFS is not.

    Correct answer
    A

    They are essentially the same, both exploring in order of depth.

    Explanation

    When all step costs are equal, the cumulative path cost is equivalent to depth. Both algorithms expand nodes in non-decreasing depth order, so they behave identically.

Question 1 of 28
Question 1 of 28

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent