Which search method takes less memory? A. Depth-First Search B. Breadth-First search C. Linear Search D. Optimal search

Depth-First Search
Breadth-First search
Linear Search
Optimal search

Breadth-first search (BFS) takes less memory than depth-first search (DFS) and linear search.

In BFS, the algorithm starts at the root node and expands all of its neighbors before moving on to the next level of the tree. This means that the algorithm only needs to keep track of the current node and its neighbors at any given time.

In DFS, the algorithm starts at the root node and expands one branch of the tree at a time until it reaches a dead end. This means that the algorithm needs to keep track of the current node, all of its ancestors, and all of its unexplored neighbors.

Linear search is a simple algorithm that searches for a value in a sorted list by starting at the beginning of the list and comparing the value to each element in the list until it finds the match or reaches the end of the list. This means that the algorithm only needs to keep track of the current element in the list.

Therefore, BFS takes less memory than DFS and linear search because it only needs to keep track of the current node and its neighbors at any given time.