卷別
資料結構
選擇國立中央大學 2026 · 考試 · 第 9 題
Given a "Perfect Binary Tree" (i.e., every level is full), with a height of (total number of nodes ), compare the worst-case space complexity of using a stack for depth-first search (DFS) versus using a queue for breadth-first search (BFS).
- (A)Depth-first search (DFS) is relatively memory-intensive because of its deep recursion depth.
- (B)BFS is relatively memory-intensive because a queue needs to store all the leaf nodes at the lowest level.
- (C)Both consume roughly the same amount of memory .
- (D)Both consume roughly the same amount of memory