cswork / OA打开练习工作台

IntuitOA #11

MCQ Questions

估计简单概念题评测数据准备中,可先阅读题面

考点(AI 标注)单调栈与堆迭代器设计

Q1: Output of pushing 1, 1.1, 'z', "Hello" onto a C# Stack, then iterating via foreach?

Answer: Hello, z, 1.1, 1 Explanation: C# non-generic Stack accepts any boxed value; foreach walks the stack top-to-bottom (LIFO), so it prints the last pushed first.

Q2: An input-restricted deque allows inserts at only one end but removes from either end. It can be used as:

Answer: both as a queue and as a stack Explanation: Pushing at the rear and popping from the rear gives a stack; pushing at the rear and popping from the front gives a queue.

Q3: Inorder traversal of the tree where root is F with left subtree B(A, D(C, E)) and right subtree G(_, I(H, _))?

Answer: A B C D E F G H I Explanation: Inorder = left, root, right. Visiting: A B C D E F G H I.

Q4: Bug in the binary-search snippet (mid = l + (r-l)/2; if arr[mid] > x recurse on [l, mid+1])?

Answer: There is an error in line 8. Explanation: When the target is smaller than arr[mid], the recursion should narrow to [l, mid-1], not [l, mid+1].

Q5: Complexity of int a = 1; while (a < n) a = a * 2;?

Answer: O(log₂ n) Explanation: Each iteration doubles a, so the loop runs about log₂(n) times.

Q6: Time complexity to find an element in a singly linked list of length n?

Answer: O(n) Explanation: No random access — every search walks the list from head, O(n) in the worst case.