84 questions
1 vote
0 answers
145 views
difference between bottom-up parser Precedence climbing and top-down parser Pratt parsing
I encountered with this problem while reading about Precedence climbing and Pratt parsing. This may be duplicate with this QA but that doesn't say much about Precedence climbing and Pratt parsing. The ...
1 vote
1 answer
96 views
Cant initialize a 2d array/matrix to 0 [duplicate]
I am trying to initialize a 2d array (matrix) to 0 but, cant do it: int longestCommonSubsequence(string text1, string text2) { int len1=0; len1=text1.length()+1; int len2=0; len2=text2....
2 votes
1 answer
434 views
Recursive query sum leaf values and pass sum to parents. Values stored in another table
I have a problem to calculate parent account balances. In the database there are two tables: account and monthly_balance. In the monthly_balance table we store only leaf account balances, but I have ...
0 votes
1 answer
104 views
How do you implement the bottom-up and top-down approach in this problem?
I am given a grid or n * n. I need to find how many routes I can take to get from grid[0][0] to grid[n - 1][n - 1]. However in the grid there will be the letter 'H' in some of the spaces. If there is ...
3 votes
2 answers
1k views
How can I add limited coins to the coin change problem? (Bottom-up - Dynamic programming)
I am new to dynamic programming (and C++ but I have more experience, some things are still unknown to me). How can I add LIMITED COINS to the coin change problem (see my code below - is a bit messy ...
0 votes
1 answer
1k views
Count the sum of subsets of size k when the sum is (Greater than or equal to R) or (Lesser than or equal to L)
def knapSack(A,L,R,K,N,Sum): if(K==0): if((L>=Sum)or(R<=Sum)): return 1 else: return 0 if((N==0)and(K!=0)): return 0 else: ...
0 votes
1 answer
95 views
Runtime Error when Trying Bottom Up Approach to Implement Fibonacci function in Swift?
I am trying to implement a Fibonacci function in Swift 5. While I was implementing the function on Xcode Playground (I took the code for the function from CSDojo's youtube video), I was encountered ...
0 votes
1 answer
205 views
when adding new text it appears on bottom and rest of text goes up
I want to display text on the text box that says if I hit and how much damage I do and vice versa for the enemy, but I just can't figure out how to make the text to display in this manner. Here is the ...
1 vote
2 answers
184 views
How to convert the recursive solution to "Moons and Umbrellas" to DP?
I'm trying to come up with a DP solution to Moons and Umbrellas from Code Jam's Qualification Round 2021. Below is my working recursive solution, based on their analysis: import sys from functools ...
2 votes
0 answers
536 views
LR-Parsing-Table: What determines next state in reduce-actions?
as far as I know (read) about generating LR-Parsing tables is that the columns (= token), where the reduce-action is written into a cell for a certain state, depends on the Terminals, that are in the ...
0 votes
1 answer
109 views
Output produced for the given input using the bottom up parsing
I tried solving this question and the answer comes out to be option c. But in few textbooks answer given is option b. I am confused what would be the correct answer? Plz help me out!
0 votes
1 answer
553 views
L-attributed grammar and bottom-up parsing
I am trying to understand what is the relationship between L-attributed grammars and computing attributes during bottom-up parsing. Is it always possible to compute all attributes during syntax tree ...
0 votes
1 answer
324 views
Parsing table size (bottom-up)
I've seen a comparison between sizes of parsing tables constructed for ambiguous and unambiguous grammar (of the same language). The one created for ambiguous was significantly smaller. The used ...
9 votes
2 answers
244 views
Find k out of n subset with maximal area
I have n points and have to find the maximum united area between k points (k <= n). So, its the sum of those points area minus the common area between them. ]1 Suppose we have n=4, k=2. As ...
1 vote
1 answer
686 views
Iterative, bottom up, divide and conquer algorithm
I was reading through this LeetCode article on a common algorithm problem, "Longest Common Prefix." They show a few different approaches, but my question pertains to just "Divide and Conquer." Its ...