• edited by
1,919 views
2 2 votes

Which of the following is correct?
a) Top-down parser complexity is O(n4)
b) Bottom-up parser complexity is O(n3)

(A) True, False
(B) False, True
(C) True, True
(D) False, False


can anyone explain how to analyze this complexity?

1 Answer

Best answer
5 5 votes

The top down parser actually takes O(n4) if the grammar is left recursive else O(n3) time to parse the string.

Whereas in case of bottom up parser , it will take O(n3) using CYK algorithm which is a dynamic programming solution and takes O(n3)...

Further there are grammars known as S- grammars which takes O(n) time to parse the string..

Reference :  Read the Time and space complexity of top-down parsing part of https://en.wikipedia.org/wiki/Top-down_parsing

Hence both statements given in the question are true..

• selected by
Position:
Show:

Related questions

0 0 votes
0 0 answers
364
364 views
Anusha Motamarri asked Oct 29, 2016
364 views
0 0 votes
0 0 answers
264
264 views
Abhisek Tiwari 4 asked Nov 16, 2018
264 views
State true or false:S1: The depth of a breadth-first search tree on an undirected graph G = (V, E) from an arbitrary vertex v ∈ V is the diameter of the graph G. (The dia...
1 1 vote
0 0 answers
2.0k
2.0k views
Anusha Motamarri asked Feb 3, 2017
1,976 views
here SJF is given as well as priorities are given, given answer followes only priority schedulingbut i think priority is used in case where there is a tie between two pro...
2 2 votes
2 answers 2 answers
1.2k
1.2k views
Anusha Motamarri asked Oct 25, 2016
1,237 views
explain