What is the space complexity of the CYK algorithm for the P table, where n is…

2026

What is the space complexity of the CYK algorithm for the P table, where n is the number of words in the sentence and m is the number of non terminal symbols in the grammar?

  1. O(n3)

  2. O(nm2)

  3. O(n2m)

  4. O(n2m2)

  1. A.

    1

  2. B.

    2

  3. C.

    3

  4. D.

    4

Attempted by 44 students.

Show answer & explanation

Correct answer: C

The space complexity of the CYK (Cocke–Younger–Kasami) algorithm is (O(n2 .m)), where (n) is the length of the input string and (m) is the number of non-terminal symbols in the grammar. This is because the algorithm uses a two-dimensional table to store results for all possible substrings of the input, and there are (O(n2)) such substrings. For each table entry, a set of non-terminals (up to (m)) is stored to indicate which symbols can generate that substring. Therefore, the total space required is proportional to (n2 times m), giving a space complexity of (O(n2 .m)).

Explore the full course: Mppsc Assistant Professor