instruction
stringlengths
35
29.1k
We can always convert our GNF-CFG/CNF-CFG to a two-state PDA but i'm wondering when our PDA is non-deterministic? i'm sure we can not make DPDA for non-Deterministic-CFL , and i suspect that same rule which applied for differing between DCFG and non-Deterministic-CFG also applied here. i mean when we have non-Determini...
Suppose i have the following resource allocation graph with a deadlock cycle, i see why it is a deadlock cycle, what i don't get is how to recover from this cycle i'm thinking about aborting a process, any process here will lead to non-deadlock situation, but doesn't that cause the other process to not execute and hen...
Let us -- using parameters $M, N$ and $L$ -- create an ordered set of size $M$ of $N$-bit long vectors $V$ and initialize them randomly: $V_k[i] = b \sim Bin(n=1, p=0.5)\ \forall i \in \{0\ ..\ N-1\}, \forall k \in \{0\ ..\ M-1\}$. create an N-bit long vector $A_0$ and initialize it to ones. create an $M$-bit long ...
$L = \{w \in \{a,b\}^*\mid \text{the first, the middle, and the last characters of $w$ are identical}\}$. I have my answers, but I need confirmation: Is the empty string $\epsilon \in L$? Yes. Reason: there is no first, middle, or last character to break the rule. A word of even length, assuming the first and last char...
How would you choose the second hash function with for double hashing with string as key? My first hash function is the scalar product of a random int array with the 16 bit number of each character. Is that a good first hash function? And what should I do for the second function now?
Given a set of students $H$ of size $n$, and a set $E \subseteq H \times H $ of pairs of students that dislike each other, we want to determine whether it's possible to divide them into $4$ groups such that: no two students that dislike each other end up in the same group, the size of each group must be at least $\fr...
I am trying to design a CFG that generates the language $\{a^k b^m a^n a^k \mid m \leq n\}$. However, I am having trouble with the $b^m a^n$ where $m \leq n$. How do I solve this?
Am reading a text about computability theory, and according to the text, at each level $k$ of the arithmetical hierarchy, we have two sets, $\Sigma_k$ and $\Pi_k$, where $\Pi_k$ is defined as: $$ \Pi_k=co-\Sigma_k $$ So that for $k=0$, we have the class of decidable sets and $\Sigma_0=\Pi_0$, and for $k=1$, we have $\S...
We are given $2n - 1$ boxes with a total of $B$ black and $W$ white balls. In the $i$-th, box there are $w_i$ white and $b_i$ black balls. It is required to choose $n$ boxes so that, the sum of the white balls is at least $W/2$, and the sum of black balls is at least $B/2$. Solve for $O(n\log{n})$. What I am curre...
I am working on an algorithm that has multiple fixed parameters. The algorithm analyzes time series data and spits out a number. The fixed parameters need to be such that this number is as small as possible. What I found, is that when optimizing the parameters for a specific time period, these parameters don't necessar...
Consider binary integer programming problem with n variables. I think the branch and cut algorithm takes exponential memory. What are existing algorithms without much memory? Please suggest.
Just to understand the topic a little bit better, I would like to know if there is a difference between real-time systems and real-time operating systems. I know that a real-time system is a system for processes that have to meet deadlines and fulfill real-time requirements. If a deadline isn't met, it can lead to dras...
I am trying to calculate the number of iterations of a sequence of nested loops of the form: \begin{equation} N = \sum_{j=0}^{j_T} \sum_{k=0}^{j} \sum_{l=0}^{k} \sum_{n=n_0}^{n_T} 1 \end{equation} where $j_T\ge 0$ and $n_T\ge 0$ are known constants. For $n_0 = 0$ the case is trivial and can be calculated using the stan...
Why is this true: “There are countably many Turing Machines” In the top answer for this question a description of how to enumerate all Turing machines is given. It all is clear except for one part: how do you know if a string is a valid encoding of a Turing machine? In step 3 the algorithm needs to check if a string i...
I have this Fortran code which generates a flat distribution as it produces a single random number centered on 0. The function GRNDM (Geant 4 random number generator) produces equally distributed random numbers between the values of 0 and 1. RDUMMY is the name of the vector filled with the random number and the argume...
I am unable to reason if we can construct a complete binary tree if only one of the following 3 traversals is given: pre-order, post-order, in-order. The following is the definition of a complete binary tree: A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, ...
Given be a binary tree whose elements printed in-order results in [1,2,3,4]. Q1: How many different binary-trees do exist? Q2: How many different complete binary-trees do exist? Q3: How many different full binary-trees do exist? For Q1 I was able to find a solution, by using the catalan number formula: c(n) = (2n)! /...
Pt 1. Given as input the tuple: (word (from an r.e. language we fix), natural number)--does there exist a verifier, that runs faster than simply enumerating that language, that can accept if the word is in the position of the natural number in an enumeration by an enumerator, and reject if it is not (choosing any enume...
I have learned the Master's Theorem from the CLRS textbook (2nd Edition), the form of the Master Theorem given in the above text is associated with the proof of each and every case. So at the end I know how it works and it also explains the intuition behind the same. The form of Master Theorem given in CLRS is as follo...
I have N (~100M) points in 2D and M (~10k) non-overlapping axis-parallel rectangles. I'm looking for an algorithm to assign each point to a rectangle it is contained in (or say that it is outside of any rectangle). I'm looking for a solution that works faster than bruteforce. In 1D, it is achievable in N * log(M) usin...
Let's say I have a directed graph represented as an adjacency matrix, and I'm given two nodes $u,v$ and a parameter $k$. Let's also say that the maximal degree of a node in the graph is $d$. What is the most efficient algorithm to find all paths of length $<=k$ from $u$ to $v$? I know the number of such paths can be ca...
There is a question in my exam that said: Consider the following three processors (x, y, and z) that are all of varying areas. Assume that the single-thread performance of a core increases with the square root of its area. Processor X, core area = A Processor Y, core area = 4A Processor Z, core area = 16A You are...
I was trying to develop an algorithm for maximum capacity problem with constraints but couldn't figure out the necessary changes required for correct output. The problem is: Given an undirected graph with two parameters (weight,cost). We need to find the Maximum Capacity path problem from source to destination such tha...
I am trying to design a context-free grammar that generates the language { x in {a,b}* | the length of x is odd and its middle symbol is a b }. This is really confusing me, I'm having trouble with making sure that b is always in the middle. Any help?
I have to determine the time complexity of a recursive enumeration in the problem of finding n-tuples $(k_i, ..., k_n)$ of naturals greater than 1 with product less or equal to $K$. Problem can be formally expressed as: $$\begin{align}0<\prod_{i=1}^nk_i\leqslant K\in\Bbb N,\ k_i \in \Bbb N^{+}\setminus\{1\}&\ \forall ...
I have a graph G=(V,E). A list of nodes NODE subset of V. I want to find out all the neighbor nodes of each node in NODE and add edge if those neighbors have distance greater than 2. Can anyone here please help me to reduce the time complexity of this code to quadratic time or less. import networkx as nx import random ...
Please help prove the following statement: There exists a single-valued computable enumeration of the family of computably enumerable sets. Definitions: 1) Let $S$ be nonempty countable set (possibly finite). Any surjective map $\nu\colon \omega \twoheadrightarrow S$ from the set $\omega$ of natural numbers onto the...
For the multiplication of two $n$ digit numbers, the best known algorithm has complexity $O(n \log n)$. Has it been proven that this is the best possible, or that an algorithm $O(n)$ is not possible?
I was wondering if it were possible to modify the linux assembler in order to change the function of "-" to "+" and vice versa. I was also wondering if this would affect the whole system making it collapse. I apologize if this question is not appropriate here. Please explain why if it is the case. E.g: 2+2 = 0 2-2 = 4 ...
A parameterized problem is a subset $L \subseteq \Sigma^* \times \mathbb N$, where $\Sigma$ is a finite alphabet. A parameterized problem is fixed parameter tractable, if it could be decided in time $f(k)|x|^{O(1)}$ for some $(x,k) \in L$. In terms of the problem definition, a Turing machine for $L$ has access to the p...
I'm trying to understand how the number of intersected areas by a vertical line in a KD-tree is equivalent to sqrt(n) If you draw a balanced KD-tree with 7 nodes. And then draw a vertical line l. The number of areas this line intersects should be equivalent to sqrt(N) where N is amount of nodes. (7) When I count th...
So I'm learning coq. And I came across the proof for associativity in addition forall (a b c : nat) Appearntly when we do induction a. after intros a b c., it creates 2 subgoals and afterwards we simply need to show that the two sides in both subgoals are equivalent, and the proof is completed. So I'm just wondering...
Assume I have a graph representing the control flow and the call graph of a given program. I also have a first and a second statement. I now want to figure out if it is possible to execute both statements (in order) within the same program execution. Control Flow Graph: I have a graph with all the statements of the pro...
How to solve recursion $T(n)=T(n/2)+T(n/3)+n$? I do not really know how to approach this kind of recurrence.
I came across the following interview question There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th person to city B is costs[i][1]. Return the minimum cost to fly every person to a city such that exactly N people arr...
I faced a problem. What is the proof to say that if yx is in a Context-Free Language we can say that xy is also in a context-free language. C is a Context-Free Language. I think we can use the PDA defining C and edit final states. Any ideas? thank you.
This is indeed a Computer Science Question. As far as I am concerned casting down (up) does not require any mathematical operation. It is just shrinking down (leveraging) the significant bits. e.g Long: 0x00000000ffffffff casts down to Int: 0xffffffff However, this does not work with the representation of double and ...
I have a question of understanding about the Delta Rule: $\Delta w_i = (y - \hat{y}) \times x_i$ Why does $x$ have to be multiplied again after the difference? If the input is $0$, the product of $w$ and $x$ remains $0$ anyway. Then, it should not matter if the weight changes with an input of $0$. Let us take the follo...
The student project allocation problem I am trying to solve goes as follows. There is a set $S$ of students and $P$ of projects such that $|S| \leq |P|$. Each student makes a top $3$ of their preferred projects. Each student should be allocated to exactly one project. Each project has a maximum number of students whic...
Given: A list of slots (A, B, C, ...) Every slots supports a list of choices (C0, C1, C2, C3...) Every choice has a value All slots must be filled with at most n different choices. The sum of the values should be maximized. Example: Choice-Values: C0 = 4 C1 = 3 C2 = 2 C3 = 1 Slots: A: C1, C3 B: C0, C1, C3 C: C...
If we have the language $nHALT=\{<M,w,n>;$ $M$ halts on input $w$ in less than $n$ steps$\}$ Is this language also undecidable in the same way that $HALT$ is undecidable? And if so, $nHALT\notin P$, right?
Consider the language $L$ of rectangular matrices written down as a comma separated list of integers where each list represents a row of the matrix and rows are separated by a semicolon. There may be an arbitrary number of rows, but each row must contain the same number of integers. For example: $[3, 5, 6; 8, 9, 10; 7,...
I am trying to find in the literature how to solve the following problem: Suppose we have a list of $n$ jobs. Some of the jobs should be scheduled after other jobs (i.e., job a should be done after job b), other jobs need to be mutually exclusive (i.e., job c cannot be done concurrently with job e). Each job $i$ has a ...
Does there exist a coding language where 1. It is always possible to determine whether a computer program will halt or run forever. And 2. The answer is not always yes. (or always no) So languages that don't allow loops, even if finite are right out.
I wonder if all the linear languages are in NL? I was thinking that we can take an input-language $L$ and convert it to linear normal form. If this is not possible, the machine rejects. If the language can be written in linear normal form, the machine accepts. The work tape only needs to store the current production, ...
I am struggling to answer these two questions: Prove or wrong: Both are given the assumption that NP != coNP. For any 2 decision problems S, S', if there is a Cook reduction from S' to S then there exists a Cook reduction from S' complement to S complement. The class NP intersection coNP is closed under Cook reduction...
There is $n$ lists (of integers) of the same length. I want to find the zeros global intersections of those lists. Example: $A = [4,6,3,0,7,0,0,0,1,0,0]$ $B = [6,6,7,1,7,0,0,0,4,0,0]$ $C = [2,4,7,0,7,0,0,0,3,0,0]$ The output are the position of those intersections: The positions are $5, 6, 7, 9$ and $10$ Other...
We all know this classic problem, "there is some hidden number and you have to interactively guess it.", which could be solved using binary search when we know that maximum number that we can guess. But what if the interactor may lie to us in one case? For example, the number is $3$ and the maximum number we can guess...
I have implemented genetic algorithm for a problem where I have an objective function which I need to minimize: Cost = ax + by + cz -> min The genetic algorithm should have found the optimal solution if objective function is satisfied. The function will never reach 0 or below, so I just need to minimize it. Now, since...
I am interested in finding the rows of a matrix where all entries are equal to zeros except for one. Example: Given the following matrix: \begin{bmatrix}0 &0 &3 & 8\\ 0 & 4 & 0 & 0 \\ 0 &1 & 0 & 1\end{bmatrix} Only the second line has this property. Of course, the brute force way is to go over the entries and check ...
We are given the following letters with the respective frequencies: \begin{equation*}\begin{matrix}a/2 & b/4 & c/7 & d/6 & e/4 & f/5 & g/8 & h/10 & i/3 & j/11\end{matrix}\end{equation*} For that I have applied the Huffman code and I got the following tree: Now it is asked for the total weight of the code. How do we ca...
knowing that Moore's law states that is the observation that the number of transistors in a dense integrated circuit (IC) doubles about every two years. is it worth looking for more algorithms?
I have a set path of $N$ destinations to be visited in order, knowing the distance $D_i$ between each one of them. I can traverse one node $i$ with the cost of $D_i \times r$ or traverse any $5$ nodes in order with a set cost of $B$. How can I find the most cost effective way to visit all the destinations using dynamic...
I want to know if there is some optimized method (constant complexity preferred) to obtain the quotient when the dividend and the divisor contain the same number of digits. I know about algorithm D of "The Art of Computer Programming" but there Knuth describes how to find quotient digit when the dividend is $n+1$ in le...
For instance, consider L = {k : the binary expansion of sqrt(2) contains k consecutive 1s}. Obviously Rice Theorem would not work. I also tried the method of how it is to PCP undecidable but still no luck. How to prove that this is undecidable?
there's this small part of my homework that I just can't figure out. Let us denote $p(L)$ as the minimum pumping length of some language $L$. I'm supposed to find two regular languages $A,B$ so that $$ p(AB)=p(A)+p(B) $$ But whatever I try, I can only find languages so that $$ p(AB) < p(A)+p(B) $$ I've been sitting at ...
Normally I put the question before the context, but in this case I want to admit the possibility that the context and my understanding nullify the question. Plus it helps me think through my question. I recently started reading Category Theory for Programmers (Bartosz Milewski), and this is my understanding of categori...
Suppose a new, more complicated, instruction is desired for this simple pipelined MIPS processor. Suppose, also, it could be implemented by either (a) adding new logic to the execute stage of the pipeline, or (b) adding a new stage (i.e a 6th stage) altogether. Assume that choice (a) would slow the execute sta...
Given a sorted array of integers and a target integer, find the number of occurrences of the target integer. It is well-known that a binary search has time complexity $O(\lg n) $ where $n$ is the size of the array. For example, given an array $[1,2,3,3,4,5]$ and a target $3,$ the algorithm should return $2$ since t...
How to trigger a thread to start working using semaphore? I have find a lot of explanation about thread and semaphore but i still don't understand, any help please
I am a new graduate student in Computer Science who would like to be able to read and understand modern and new distributed systems research papers. My current background / courses and understanding is in the level of undergraduate and beginner graduate level courses in: Networks (TCP/IP stack and applications) Distri...
I am interested in how computers work but I have no idea how the concept of 0's and 1's converts to making possible for people to control a computer by programming. I would like to understand from very fundamental levels of computer and continue studying more in depth until I am satisfied. Where should I start? Is ther...
If we start with the definition of L being in NP if "there exists a polynomial NTM that decides L" (where polynomial for an NTM means the length of the worst run as a function of the size/length of the input / the maximal tree depth) There is a proof that L is in NP iff there exists a polynomial TM verifier for L. Rega...
I am solving a discrete Markov chain problem. For this I need a Markov chain whose stationary distribution is uniform(or near to uniform distribution) and transition probability matrix is asymmetric. [ Markov chains like Metropolis hasting has uniform stationary distribution but transition probability matrix is symmet...
Question There are plenty of algorithms for solving the #SAT problem, with one being the DPLL algorithm and is implemented for all kinds of programming languages. As far as I've seen, they all take a boolean formula on CNF as input and outputs the number of satisfied interpretations. Mathematical constraints, on the ot...
I recently read about the process address space and PCB and trying to link them together. I don't find much literature on their relation. Is the process address space a part of the PCB data structure?
I have this question: I have an undirected graph G(V, E) (where V = set of vertices, E = set of edges). Consider the maximum path between two vertices s and t: LPATH = {⟨G,s,t,k⟩|There is in G a simple path as long as at least k from s to t} A simple path is a path without any repeated vertice, i.e. every vertice can ...
What would be the practical consequences of ZPP=exptime. It would be pretty ridiculous if the was true but what if it was?
i need to prove that and i find it struggle: given: for deciding problem S: a non deterministic algorithm $A(x)$ is strong deciding algorithm if: $x \in S =>$ fo every run of $A(x)$ returns "Yes" or "Maybe", and there exist run which $A(x)$ returns "Yes" $x \notin S =>$ for every run of $A(x)$ returns "No" or "Maybe",...
I can't wrap my head around this statement: One common drawback of using composition instead of inheritance is that methods being provided by individual components may have to be implemented in the derived type, even if they are only forwarding methods It's from here.
Show that if $d(n)$ is $O(f(n))$, then $ad(n)$ is $O(f(n))$, for any constant $a > 0$? Does this need to be shown through induction or is it sufficient to say: Let $d(n) = n$ which is $O(f(n))$. Therefore $ad(n) = an$ which is trivially $O(f(n))$
Given an input $S$ (set of elements) find an exact three cover for a list of 3-element sets named $C$. $S$ = 1,2,3,4,5,6 $C$ = [1,2,3],[4,5,6],[3,1,2] Algorithm 1.Sort list and delete occurrences of sets that repeat in $C$. (eg. $[1,2,3]$ repeats because of $[3,1,2]$. Of course leave one of the sets.) 2.Remove sets t...
I've read here that in HoTT, compilers could swap out less efficient representations of data for more efficient ones and I'm wondering whether my interpretation of that statement is correct. Say we have two different ways of representing the natural numbers, unary (zero and successor) and binary. Here is a function tha...
This is a homework problem that I have In a multicore system, you are running the code on the right on each core, and it suffers from false sharing. You can assume t_id is set to a unique thread identifier (e.g. 0-15). How could you change the code to reduce false sharing? for (int i=0; i<N; i++) totals[t_id] += a[...
I have a single resource that will need to shared for running multiple parallel jobs. Think of the resource as a straight line numbered from 1 to 100. The jobs occupy part of the line while they are running. Each job has a start and end unit associated with it and it can only be run between those ranges. For example l...
I have a problem with this exercise. For language $$L_1 = \{ w \in \{0, 1\}^* : \exists k \in \mathbb N \ w = \text{bin}(n)(\text{bin}(2^{k+1}n + 1))^R \},$$ where $\cdot^R$ reverses a string and $\text{bin}(n)$ is the representation of $n$ in base 2. I need to determine if this language is regular, context-free or n...
What are some of the most ridiculous possible claims in computer science that we haven't disproved? E.g. For example the claim that ZPP=exptime is absurd but has not been disproven.
A proof for a language $L$ belonging to a complexity class $C$ can be framed as there existing a verifier $V$ that accepts this proof as the first part of their input and the language as the second. The verifier verifies this language is a member (a word) in the language representing the complexity class. Verifier: (Pr...
I am referring to this paper: http://www.vldb.org/pvldb/vol8/p1816-teller.pdf My question is regarding section 4.1.2 where it says: When XOR is non-zero, calculate the number of leading and trailing zeros in the XOR, store bit ‘1’ followed by either a) or b): (a) (Control bit ‘0’) If the block of meaningful bits f...
I just came across this asymptotic bound : $(\log n)!= \Theta \left(n^{\log \log n}\right)$ Which had the following remark: Hence, polynomially lower bounded but not upper bounded. I found this here: https://gateoverflow.in/12928/%24-log-and-log-log-are-polynomially-bounded-anybody-can-prove I am confused on how ...
I read from Savitch's theorem that given a fully space-constructible function $S(n)$, we have $$ NSPACE(S(n)) \subseteq DSPACE(S(n)^2) $$ Am wondering, what happens if $S(n)$ is fully time-constructible instead, could we have the stronger result $NSPACE(S(n)) \subseteq DSPACE(S(n))$ ? ... For instance, for fully time-c...
I have recently been focussing on DP formulation and space optimization in dynamic programming of some problems. I have gone through the standard questions such as 0-1 Knapsack and Coin Change problems. In the space optimization part, I haven't understood in which order should I fill the table to get the desired resu...
Player $A$ thinks of number between 1 and $n$ and ask $B$ to guess the number with minimum number of decision queries (yes or no type). Game : $A$ chooses an element in $\{1,2,\dots,n\}$. $B$ tries to guess this number by asking Yes/No questions. Binary search is a way to solve the problem, so $\log n$ many queries ...
Lets say we have some arbitrary grammar for which we would like to know how many different syntax trees does it generate. For example the following: S -> A1|1B A -> 10|C B -> C1 | $\varepsilon$ C -> 0|1 This is a quite simple language and the number of unique trees is not hard to figure out by just going through all of...
I need to prove $: L=\left\{\langle M\rangle\mid M \text { is a } T M \text { and } L(M)=L\left((01)^{*}\right)\right\} \notin Re$ at first observation it looks like it's immediate from Rice's extended Thm, but is it really? Rice's extended Thm requires that the set won't include sigma star and won't be empty, as I bel...
Are there any problems that are known to be in ZPP but not in p?
Question: Given a tree representing a neighbourhood where each node is a house. Assign an antenna to each node such that the whole tree is covered. An antenna of strength 0 can only provide a signal to itself. An antenna of strength j can provide a signal to itself and nodes that are j steps away from it. The c...
Firstly consider the problem: given $L_H = \{R(M)w : M \in TM_0, w\in L(M)\}$ where $R(M)$ are encoded transitions of $M \in TM_0$. Assume for contradiction $\overline{L_{H}}$ is semi-decidable, then there is $Q \in TM_0$ with $L(Q) = \overline{L_{H}}$ therefore for every $M \in TM_0$ we have the following $$Q \ accep...
In CNF SAT, each clause (A or B or C or...) must contain at least one true literal. The resolution rule applies to pair of clauses who have exactly one opposite literal. (A or B or C) and (!A or D or E) => (B or C or D or E) I say that this rule is complete, in the sense that if a formula is unsatisfiable, I can prov...
What are the $EXP^{NP}$, $EXP^{PSPACE}$, and $EXP^{EXP}$ equal to? I suspect that their, NEXP, ESPACE and 2EXPtime respecitvely. And what bout $NP^{EXP}$
I understand that both algorithms are very different, but what I don't understand is whether they achieve the same thing in the end. 2PC is for atomic commits and 2PL is for serializable isolation. But don't they both achieve the two things? don't these goals imply each other in the end?
Given N points in a 2D plane, if we start at a given point and start including points in a set ordered by their distance from the starting point. After including every point, we check if there is a convex hull possible, we move all these points to a visited set and continue. Every time we determine a convex hull, we on...
I am new to backtracking and recursion. I have seen numerous explanations on how on to find the minimum number of coins needed to make a particular amount. This involves a top down dynamic approach with mermoization and a bottom up using dynamic programming. Even the brute force apporach always starts using a top down ...
If I had a graph representing the USA with each node representing a state, and each edge linking adjoining states, is there a graph algorithm that would give me every possible unique group of 4 states that are linked (order of states is not important)? By 'linked' I mean that all states in valid group should be reachab...
Is a program available to translate a Turing Machine program to Boolean tableau format as used for example in proofs of the Cook-Levin theorem?
According to Wikipedia, and also a very common definition of a recursive function found in several books, "functions that call themselves from within their own code". I agree that this solves the problem for most of what I think recursive functions are, but, suppose you have the following "iterative" code written in C:...
I came across this problem which asks to prove: $$NSPACE(S(n)) \subseteq DTIME(c^{S(n)})$$ for $S(n) \geq \log{(n)}$, with $S(n)$ being fully time-constructible... As an attempt, isn't the proof for this problem almost exactly the same as the proof for $$ DSPACE(S(n)) \subseteq DTIME(c^{S(n)}) $$ The proof for $DSPA...
An example of this would be: 1+2*3+4 Expression = Expression Arithmetic Expression | number Arithmetic = + | - | * | / Through just breaking down 1+2*3+4, it was easy to find that the answer was 5 trees. 1+((2*3)+4) ((1+2)*3)+4 1+(2*(3+4)) (1+2)*(3+4) (1+(2*3))+4 But doing it in this brute force manner wouldn't wo...
I need to find the first $n$ coefficients of $$\prod_{i = 1}^{i = q}(1 + x^{a_i})^{b_i}$$ modulo a NTT favourable prime. Can someone suggest an algorithm with worst-case complexity $O(n\log n)$ or $O(q\log q)$? I think this is to be done using NTT but cannot get an exact method. I tried Divide and Conquer but it is $O(...
How to construct regular expression for language L={a,b,c} which contain all words starts with bab and ends with babc?