Question 75Asked in BPSC TRE 1.0 (2023) Computer Science Class 11-12

What is the time complexity of an infix to postfix conversion algorithm?

  1. AO(N log N)
  2. BO(N²)
  3. CO(N)
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (B) O(N²)

Explanation

Note: the answer key gives (B), but infix-to-postfix conversion scans each symbol once and pushes and pops each operator at most once on the stack, so it takes O(N) time.

From BPSC TRE 1.0 (2023) Computer Science Class 11-12 — Previous Year Paper

This is question 75 of BPSC TRE 1.0 (2023) Computer Science Class 11-12 — Previous Year Paper. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.