instruction
stringlengths
35
29.1k
I have two PDAs one with $\{a^i b^j \mid i > j\}$ and the other $\{a^i b^j \mid i < j\}$. I know how to combine these two PDAs non-deterministically. My question is how do I combine these two PDAs into one deterministic PDA? What's the process and could I get a visual example of how to do it?
Are they exactly 32bits for a 32-bit CPU?
Googling "large horse walks into house" also returns results that contain "large horse in a house" and "the house has large horses". How is Google able to return near-matches and not just direct matches? What are the methods that search engines use to perform such queries so quickly? I know about phrase search and prox...
Are they exactly 32bits for a 32-bit system ?
In the papers introducing The Bandit Gradient Algorithm as Stochastic Gradient Ascent, the following relationship: is always considered as a preliminary and lacks proof for it. Does anyone know how does this relationship come about? ($\pi_t(x)$ is the probability of choosing action $x$ at time $t$ and $q_*(x)$ is the ...
I'm trying to see if the language $L/w = \{x\mid wx\in L\}$ is regular given that $L$ itself is regular. It seems to me that if $L=L(A)$ for the NFA $A = (Q, \Sigma, \delta, S, F)$, then the NFA $A'$ should accept $L/w$, where $A' = (Q', \Sigma, \delta', S', F')$. Each component is defined as: $Q' = $ all states in $Q...
QUESTION: Can we Implementing priority queue with hash table please? As I understand, dictionary/hash table does not have sorting mechanism inside. It adds pairs of $<key,value>$ to hash table. So the keys in PQ would correspond to keys in hash table, however, keys are added such that elements are assigned a priority (...
I will be working on a project soon and as I'm clearly not a star (see what I did?) in CS, I'm not sure what to think about this. To put it simply, the problem is the following: We want to go from point A to point B, nice and simple, we can easily find the shortest path. Each cell on our grid has a certain value, let'...
I recently learned AVL Trees but I still lack a complete understanding of the concept. I understand that an AVL tree is a Binary search tree that checks for the height of the tree, but I still don't understand how I would apply that to the question. Any help is appreciated!
I have been asked as an exercise how to prove that this is not a regular language. first I tried to use the pumping lemma, but I got stucked. Th erxercise hust said to prove thata this isn't a regular language, I would appreciate if the answer could e given step by step, I really wnat to understand how it works . Thank...
Given a simple graph $G(V,E)$, what is the LP formulation for the minimum edge covering? Minimum weight edge covering would also work here. If there are none, then that is an answer too. I took a class on Theory of Algorithms and Operations Research last semester, and remembered there was an IP formulation for the mini...
I am working on some binary-search-tree research and was surprised to find no mention of an algorithm to join two Scapegoat Trees. This is where two trees $L$ and $R$ are joined to create a single tree $T$, given that all values in $L$ are less than all values in $R$ and that all values are unique. For this problem, th...
There is a lot of information on time complexity analysis. For example, we know that for calculating the time complexity we study the number of operations (e.g. traversal, swapping, comparisons etc.) an algorithm performs. I have not been able to lay my hands on the considerations for space complexity analysis. Q) Wh...
I would like to clarify to myself the way that an algorithm that proves the statement in the title works: I think the idea should be like this: We assign the input values to the bit nodes We calculate the incoming edges values for each logical operator node We finally get to the output node, and we have our result Wh...
I have a directed graph $G$ with a set of nodes $N$ and a set of edges $E$ with the following property : if $(A\to B)\in E$ and $(B\to C)\in E$, then $(A\to C)\in E$, for all nodes $A,B,C$. I would like to find the subgraph $G'$ with the same set of nodes $N$ and a set of edges $E'$ such that: The "connectivity" (not ...
I have recently read the definition of $coNP := \{L \ \mid \ \overline{L} \in P\}$, where $L$ denotes a language. However, I am wondering what the difference between $P$ and $coNP$ is, since an elementary result of the theory of Turing Machines is that if $L \in P$, then $\overline{L} \in P$. So is $P = coNP$ or is the...
I am wondering why the following "proof" of $coNP = NP$ does not work: $\subseteq:$Let $L$ be a language in $coNP$, that means there is a non-deterministic Turing Machine $M$ that decides the complement of $L$, denoted by $\overline{L}$, in polynomial time. Then the Turing Machine $N$ that decides $L$ in polynomial tim...
how can you find if a regex call is a subset of another regex call on an predictable set of data I have a string (chess Forsyth–Edwards Notation (FEN) stringrnbqkbnr/pppp1ppp/8/4p3/3P4/8/PPP1PPPP/RNBQKBNR w KQkq e6 0 2) If I use /(.)/g it matches the super set of any possible chess position, i.e. /(r/)/g matches r/ , a...
I recently learned about the one-way 2-party model of communication complexity in some lecture notes. It seems that all algorithms studied in this model are either deterministic or randomized Monte Carlo, i.e., they fail with some nonzero error probability. This made me wonder if there is an obvious reason why we don't...
Without restriction (e.g. continuity or convexity are not guaranteed), we're given an W x H raster-based shape that needs to be placed on an infinite tiling of M x M squares. The shape can placed at any integer positional offset within those squares. The goal is to minimize the number of squares containing any part of ...
I came across this post about how we can get to all shortest paths from source (u) to destination (v) . If the algorithm is working in O(E + V), why can't we use it (after slight modifications) for weighted graphs? Why do we use a priority Queue in Djikstra's Shortest path Algorithm?
I just read this Why doesn't Python need a compiler? I know that Python isn't absolutely compiler or interpreted but it is both of them it's maybe an interpretive, high-level, and all-purpose programming language. Python uses PVM(interpreter) and Bytecode(that is output of a compiler). after all, why do we classify Pyt...
I am looking to prove the following: Each binary tree with $n \ge 2$ nodes has an edge whose removal results in two trees, each having at most $\lceil (2n-1)/3 \rceil$ nodes. I am not sure how to approach this, or find some way to detect such an edge. Would appreciate any hints.
How to find a saddle point in a binary tree. where saddle point is a node in a tree whose value = min(the node and all its ancestors) = max ( the node and all its descendants)
My question I have two complexity classes, $L$ and $Mod_kL$. I'm confident these classes satisfy $L\subsetneq Mod_kL$, as I'll explain below but you can take for granted for a moment. From these two classes I defined new classes, by allowing arbitrary processing of half the inputs for some fixed partition of the inputs...
Can there be a computer without software (only hardware) which can produce meaningful output? "Software" would be for example an operating system (whether in the level of "firmware" or not). "Meaningful output" would be for example anything useful for the user, but a practical example might be the solution to any "mat...
Question: Describe an efficient algorithm that, given a set $\{x1, \cdots, x_n\}$ of points on the real line, determines the smallest set of unit-length closed intervals that contains all of the given points. Attempt: If we sort the points in any order we would like to start with, we will get $S=\{y_1, \cdots, y_n\}$. ...
I was reading distributed algorithms (by Nancy lynch) and there is a part that I would kindly like to get a simpler explanation for. I know the book mentioned no algorithm can solve mutual exclusion between n processes with less than n variables. But I fail to fully understand the proof, can someone please give a sligh...
Question: Given integer $n \geq 2$ and two lists of size $n$, $A$ and $B$, of non-negative integers, determine if there exists an $n \times n$ matrix whose $i$-th row has $A[i]$ $1$s and whose $j$-th column has $B[j]$ $1$s. If it does exist, then find it. My attempt: An extremely inefficient algorithm would be to fin...
This is my homework question Given an array A[1..n] of n integers, we want to decide if there exist i and j, where 1 ≤ i , j ≤ n, such that A[i] + A[j] = α for a given value α. Give an O(n^2) algorithm to solve the problem. Can anyone understand what the question like to ask?
Can someone please give me an example of two algorithms, one where "Big-O" is the most appropriate expression of how time complexity grows with input size, and one where this would be Θ? Can you please be very clear about whether the statements refer to best, average or worst case, and about implicit assumptions about ...
Given a 3SAT problem with the additional constraints that: No clause or set of clauses is the 3SAT instance is 'redundant'. Thus, this 3SAT cannot eliminate any clauses. For any/every clause, the triplet of 3 variables in it are guranteed to occur in at least 1 other clause. What is the computational complexity of ...
Assuming we have a K-Partite DAG (edges are directed from one level to the next) with edge weights either 0, 1 or 2. We are looking for the shortest path between a node from group 0 to group k-1 (path of length k). Is that correct that the algorithm will pick a path with minimal number of edges of weight 2? If so, how ...
I've taken the following steps to prove that the minimum pumping length (PL) of the above language, $L= 01^*0^*1$: Set a PL. I chose $p=2$ Choose a string from $L$ where $|w|\geq p$, I chose $w=011$. $|w|=3 \geq p=2$ Split the word, $w$ into constituent parts, $x,y,z$ such that the following are true: $y\neq\varepsi...
Actually, I know that there are many examples showing how this is a contex-free language, but I can't find any that show it isn't regular. I would appreciate if I could have a solution step by step for this case Show that {xy : x,y ∈ {a,b}*, |x| = |y|, x ≠ y} is not a regular language
I'm new here on the site, I'm a final year student in computer science. In a machine learning course, there was a question on a test that I could not understand. The question goes like this: Suppose that $ F\subseteq\{0,1\}^\Omega $ is some collection of Boolean functions over $\Omega $. Define $\Omega'=\Omega\times\{...
Are there any methods for computing the "similarity" between two algorithms? Intuitively, selection sort and merge sort are more similar to each other than merge sort and radix sort. I want a formal method that computes an algorithm similarity metric. I know similarity is vaguely defined here. I'm interested in any pub...
What algorithm can be used to find a balanced edge in a binary tree? If we remove that particular edge, the tree is split up nearly equally. Each tree will have at most $\lceil{(2n-1)/3}\rceil$ nodes.
I am looking at a variant of TSP in which rather than visiting every node, there is a given collection of (possibly overlapping) subset, and the salesman must pass through one node from each subset. Concretely, I have a graph with vertices $V$ and a family of subsets $S = \{S_1, S_2, ..., S_n \}$. I'm looking for a sim...
We all know that the RUN Time of most of our program are Big O of linear time, quadratic time, cubic time or log time. But Can this be in unusual or uncommon poly time like $x^6-y$ or cosine function time ?
I wish there were more, but the subject pretty much captures my whole question. Is there a non-Turing-complete model (some constrained term rewriting system or automaton or what have you) which is known to be able to enumerate the prime numbers, all of the prime numbers (well, til you pull the plug on the algorithm), a...
Which of the below choices is related to the number of instructions a CPU can handle at one time? A) 32bit word size B) 3GHz clock speed I think should be (A). 2^32 instruction at one time?
According to the formal definition of an instance, it is a set of input data containing the values of the parameters of some problem (What is an instance of NP complete problem?). So, two problems may formally have the same class of instances, as long as they share the same parameters, even though they might have, e.g....
GeeksForGeeks We are given an array arr of $n$ element. We need to count number of non-empty subsequences such that these individual subsequences have same values of bitwise AND, OR and XOR. For example, we need to count a subsequence (x, y, z) if (x | y | z) is equal to (x & y & z) and (x ^ y ^ z). For a single eleme...
I have a lot of difficulty with the turing machines. I understand the theory well, but I need help with a lab exercise... Design a SINGLE TAPE Turing Machine that accepts the language $a = > b \times c$ (or $1^{^{mn}}= 1^{^{m}} \times 1^{^{n}} )$, this means that this language only accepts unary multiplications. Some ...
Planar graphs are graphs which can be drawn on the plane without edges crossing. Disk contact graphs are graphs obtained as follows. Place some disks in the plane without overlaps, allowing touching. Create a vertex per disk, and connect vertices by an edge if the corresponding disks touch. As stated by graph classes, ...
Question: I came a cross a problem where we have a set of numbers $W= \{x_1, \cdots, x_n\}$ where repetition of numbers is allowed. We would like to find out whether we can find out 3 disoint sets where the sum of numbers in each set is equal, e.g., $W=\{1,5,2,4,3,3\}$ can be split into 3 disjoint sets $(1,5), (2,4), (...
Given a distance matrix for 50,000 points, how do I select $N$ points so that the sum of all distances between the $N$ points is maximized? $N$ could be as high as 100. To calculate the sum of distances for all sets of $N$ points would be exponential, which would not scale to 50,000 points. What is the fastest algorith...
It is clear to me that if some heuristic $h(x)$ is admissible, then $A^*$ is guaranteed to find a least-cost path. But is it also possible that $A^*$ is optimal if $h(x)$ is not admissible? In other words, should this be an if and only if relation? One example that I am considering is graphs in the Euclidean plane. Ins...
Assume a given NFA for a regular language with $n$ states. It is clear that determinizing it may result in an DFA with $\Omega(2^n)$ states. However, the minimization might decrease the number of states. Is there a counterexample which would show that the minimized version might aswell be of superpolynomial size? I.e. ...
I try to prove the equivalence between the two following properties of an NP-Complete problem $P$: (A) $P$ is unary NP-Complete if it is NP-Complete even if we encode the integers of the inputs with unary encoding. (B) $P$ is strongly NP-Complete if there exists a constant $c \in \mathbb{N}$ such that $P$ is NP-Complet...
On a lot of messaging applications, regex search isn't enabled due to a "linear scan". I'm not sure why this is the case. Can someone explain?
The "graph homomorphism problem" can be stated as: given two graphs $G$ and $H$, determine if there exists a homomorphism $f$ such that $f: G \rightarrow H$. This is a famous problem that is well-known to be NP-complete. Now I'm thinking about a related problem: given two homomorphic graphs $G$ and $H$, find $f: G \rig...
I see the following notations used: $O(1)$-approximation $O(n)$-approximation $\Omega(n)$-approximation Can someone please explain what they mean? I know what an approximation is with a normal constant approximation (2-approx, 2/3-approx, etc). And I know what $O(n)$, $\Omega(n)$ mean, but I just don't understand wha...
From my reading and research it appears it's one way, however my lecturer states that it goes both ways in his examples. Let me show you what i mean by this. He claims that a binary tree built from a heap with numbers 1 - 7 appears as: 1->2->3 2->1->4->5 3->1->6->7 4->2 5->2 6->3 7->3 Whereas i would say it appears as:...
Prove that if for every proposition $\psi\left(p_{0}, \ldots, p_{n}, p\right)$ there exists $\phi\left(p_{0}, \ldots, p_{n}\right)$ in which $\psi\left(p_{0}, \ldots, p_{n}, p\right) \rightarrow\left(\phi\left(p_{0}, \ldots, p_{n}\right) \leftrightarrow p\right)$ is a tautology then $\phi$ is a definition of $p$ in te...
Is it possible to build a linear bound automata that decides A(NFA)? A(NFA)=Accepting Non deterministic Automata - language that contains the encoding of all the NFAs together with the strings that the NFA accepts I tried to look online, in summaries and handouts and even in several books (including Sipser's book), but...
Below are the two problems Im working on and my attempt at a solution (understanding the question). My first question is am I interpreting the question from the symbols right, second can you help explain what I need to do for these questions? Ive been reading through chapter 4 of Sipser 3rd ed. Intro to theory of compu...
We define an $i$ - access PDA as a PDA that can manipulate the top $i$ characters in the stack, where $i>0$. Given a transition function of the form $\delta(p,x,c,d) \to (q,c')$, where $d \le i, d > 0$, we read it as "When in state $p$, upon reading an input $x$, the stack has depth at least $d$, with $c$ at the $d$th ...
Let $$ x_{k+1} = x_k + u_k, \qquad x_0 = 5 $$ where $k \in \{ 0,1,2,3 \}$, define the return function $$ - \sum_{k=0}^3 \left( x_k^2 + u_k^2 \right) $$ with the following inequality constraints on the control inputs $$0 \leq x_k + u_k \leq 5$$ where $u_k \in \Bbb Z$. I would like to apply dynamic programming to find an...
I am not asking about if it is possible to build a computer using only NAND gates, since that question has been asked infinite times. I wonder if it is possible to replace the “ALU” in the cpu of a computer, with just a single NAND gate. And, then implement the rest of the ALU with software. CPU seems to basically get ...
I have seen that most standard college textbooks of Database Management Systems use this method to classify whether a schedule is view serializable or not. I know the definitions of Conflict Serializability and View Serializability, but I am unable to think of a generalized proof that the above flowchart is actually c...
Let's say I have a list of intervals on a number line. The "depth" of a point on this number line corresponds to the number of intervals in the list that contain it [the point]. So for instance if I have the intervals [(1, 8), (3, 12), (4,6)], the deepest points comprise the interval (4, 6). What is the fastest algorit...
Learning Computer Graphics - Can similarity transformation be linear transformation? Similarity T is a rigid transformation (translation and rotations) with uniform scaling. so I guess a similarity transformation can be linear. Am I missing someting? Thank you
Suppose $A$ and $B$ are both languages over $\Sigma=\{0,1\}$. We use $n_0(x)$ and $n_1(x)$ to represent the number of $0$s and $1$s in the string $x$ respectively. Consider the following two operations: $$ A\cong_0 B=\{x\in A\mid\exists y\in B,\ \text{s.t. }n_0(x)=n_0(y)\}\\ A\cong_{01} B=\{x\in A\mid\exists y\in B,\ \...
The model is as followed: Consider an infinite horizon discounted problem $(0 < γ < 1)$ in which the state space is finite, with $n$ states, and there are only two possible decisions: stop or continue. If at time $t$ you are at state $s$, and you decide to stop, you incur a stopping cost $γ^t g(s)$, and move to a cost-...
Hello everyone I am new to the site, I have a question that was in the test and did not understand the parts that are in the question. This question from a test I failed to pass, in a machine learning course. the question: Suppose that $ F\subseteq\{0,1\}^\Omega $ is some collection of Boolean functions over $\Omega $...
I need to know the analysis of time complexity of this case? for k=1:(N-1) for i=1:N-1 for j=1:N if (Groups22(i,j)==Groups2(k,I)& AA(i,j)==AA(k,I)& BB(i,j)==BB(k,I)) Groups22(i,j)=nan; end
Is it consistent with the current knowledge that there is an algorithm solving a 3-SAT instance in $n$ clauses in quasilinear time in $n$?
Everybody knows that if you try to register to a website with an email that does not exist, the website labels the email as "invalid". How do they know that?
We define an operation three on strings as three(c1c2c3c4c5c6...) = c3c6... then the above-described definition is extended to languages. Prove that the class of regular languages is closed under this operation.
I've been trying to create a function in TypeScript for converting to and from base58. I'm pretty familiar with base conversion generally: divide a number by a target base, and take each remainder as a digit of the conversion from right to left, until it equals 0. But this took me into Bitcoin's source code, which does...
I have a set $X$ of $n$ points in a $poly(n)$-dimensional $L^\infty$ space. Does there exist a way to map the points into $poly(n)$-dimensional $L^2$ space so that the distances between points in $X$ are approximately preserved? Formally, let $S_1$ be the original $L^\infty$ space with $dim(S_1) = O(n^k)$ ($k$ is known...
One advantage claimed for scapegoat trees over other balanced trees like AVL or red-black(RB trees - just mentioning AVL henceforth) is not needing to store additional balance information. But can't an AVL tree node do without additional storage for balance information? (I'm not considering possibilities to hide it in ...
We say that a language $L$ is prefix-free if for every word $s\in L$ there does not exist a nonempty string $w\in\Sigma^*$ such that $sw\in L$ (i.e. no word in the language is a prefix of some other word in the language). For any given language there is a smallest prefix-free sub-language constructed by finding any tw...
I'm trying to devise an algorithm to seat people at a table. The basic premise is as follows: Given a list of $n$ tables, each with a different number of seats (e.g. $2, 4, 4, 5$), and a dictionary of who a person would like to sit next to: Person A wants to sit next to Person B and Person C. Person B wants to sit nex...
as the title says does having a mutable transition function make the Turing machine more powerful by mutable I mean we have a set of transition functions that we can choose one of them arbitrary based on the current state and symbol in definition of Turing machine from wikipedia instead of $\delta$ we have a set $\Delt...
I have a set of 2D geometric figures in Cartesian space, as shown in the image. Each geometric figure has a start point and an end point (among other characteristics). For closed geometries, such as a circle, the start and end points are the same and for open geometries, such as lines, both points are different. I nee...
I need an algorithm to optimally stack a set of bricks in a 2D plane so that the resulting wall is as vertically short as possible. Bricks are defined as a pair of integers $(x_1, x_2)$ corresponding to the horizontal span of $\textit{width} = x_2 - x_1$ and are of equal height. Bricks cannot be translated left or righ...
For entropy, the most common one is Shannon entropy, however, it ignores time series of data. For instance, data 0x00001111 and 0x01010101 are given the same entropy. It is obvious that the second data is more disordered than the first one which mean the entropy of the second one should be larger. So, I find the second...
I'm currently studying the ALU architecture (of a Hack computer) and how it works. As part of my assignments, I have been asked the following question: If we want the ALU to compute the function y-1, what should be the value of the zx (zeroed) and nx (negated)? a. zx = 1, nx=1 b. zx = 0, nx=1 c. zx = 1, nx=0 d. zx = 0,...
I have a database $D$ of n-dimensional numerical vectors, and I want to do an incremental KNN (IKNN) search over the vectors in $D$. More precisely, given a query vector $v_q \in D$ I need to find $k$ vectors $v_i \in D \setminus \{v_q\}$ sorted by value of $Euclidean(v_q, v_i)$ from low to high where $Euclidean(v_q, v...
Given a random $3SAT$ instance $(S_0)$ with $C_0$ clauses, $I_0$ variables. Objective: For any given value $C_1$ ($C_1<C_0$), create an 'equivalent' $3SAT$ instance $(S_1)$ with $I_0$ variables, $C_1$ clauses such that: For any set of values for variables $I_0$, $S_0$ is satisfiable iff $S_1$ is satisfiable. What is th...
I need to cite a reference that the minimum makespan problem on ($>2$) identical machines is NP-hard. I've seen Garey and Johnson cited as a reference, but it I'm not sure which of the problems is exactly equivalent to this one.
Given the following language: $$ L=\left\{\,(\,C,\,\{v_i\}_{i=1}^m, \,x\,) \enspace :\enspace \substack{C(x) \text{ is a boolean circuit with } m \text{ gates} \\i\text{'th gate value is } v_i \text{ on input } x} \right\} $$ I need to find out to what known class $L$ is complete to with respect to logspace reduction...
In number theory progress is sometimes guided by people stating a specific Diophantine equation that they don't know how to solve. Is there anything similar in the field of Boolean satisfiability? More specifically what is the smallest 3-SAT instance (measured by fewest number of variables) that people have tried to so...
We want to write n in terms of multiplication of numbers from A = [1,...,n] such that the total cost is maximum. The cost of choosing the ith number is cost[i]. Note that cost[1] = 0 and we can choose 1 number multiple times. For example : n = 12 A = [1,2,3,4,5,6,7,8,9,10,11,12] cost = [0,1,2,0,0,0,0,0,0,0,0,20] 12 = 1...
I'm basically trying to figure out if the following problem has a common name and/or a standard solution in computer science. Let assume we're given $N$ two-dimensional tuples $(x_i, y_i)$. This data is fixed/static and we want to pre-compute a data structure that allows to run interval queries returning the max or min...
I need to say Is language $a^mb^nc^n, m \not= n$ context free I managed to find a grammar for $L1 = $ { $a^lb^mc^n | l=m$ or $m = n$ }, but I couldn't find the one I needed. Maybe it is impossible, but than why? If it may be helpful, that is the grammar for L1 wich i found: $A \rightarrow \epsilon |aAb, B \rightarrow \...
I came across this question in a job interview and I couldn't solve it. In a n*m matrix some cells are blocked.The robot can only move in direction of (x-1,y+2) or (x+2,y-1). Is it possible to reach B from A? If yes how many minimum paths exists?
Consider an array $X$ with shape $H \times W$. Let $Y$ be the other array of the same shape and $Z$ is an array of shape $h \times w$. We want to construct an array $R$ of shape $(H-h + 1, W-w+ 1)$ by the following rule: $$\displaystyle R[k, l] = \sum_{i, j} (X[i,j] - Y[i,j])^2 +$$ $$ \sum_{i=0}^{h-1}\sum_{j=0}^{w-1}[...
I'm trying to understand this algorithm : https://en.m.wikipedia.org/wiki/Expected_linear_time_MST_algorithm As described in the wiki article, it works in 5 steps to find the MSF for a graph $G = (V, E)$: Do two iterations of Boruvka resulting in a graph $G'= (V', E') $ Select each edge from $E'$ with probability $1/...
This Question can be found in the book: ODS: An Introduction (Chapter 6) Suppose we are given a binary tree with pre-, post-, and in-order numbers assigned to the nodes. Show how these numbers can be used to answer each of the following questions in constant time: a. Given a node n, determine the size of the subtree r...
The task: You are standing in front of a gigantic forest of syntax trees. One tree looks more fascinating than the other. In front of the forest is a sign: "Every tree in this forest arises from a derivation with exactly two steps and has exactly 2021 leaves." If you can figure out how many different trees are in the f...
Given an undirected connected graph $G = (V, E)$ with weights $w : $E → $R$$^+$, define for a spanning tree T the value $λ$(T) = $max_e$∈$T${w(e)} (the maximal edge weight in T ). I need to find a linear deterministic algorithm of finding a spanning tree T with minimum maximum edge e. We were given a hint of using bina...
Let's say you have this mapping of symbols and codewords: $$ \begin{array}{cc} \hline \text { Symbol } & \text { Codeword } \\ \hline \text { A } & 101 \\ \text { B } & 100 \\ \text { C } & 01 \\ \text { D } & 00 \\ \text { E } & 110 \\ \text { F } & 111 \\ \hline \end{array} $$ How is it possible to determine the prob...
A full $m$-ary tree with $n$ vertices and $i$ internal vertices has $n = m \cdot i + 1$ vertices and $l = (m − 1)i + 1$ leaves. How can I prove it? I know that $m$-ary tree is a rooted tree such that every internal vertex has no more than $m$ children. The tree is called a full $m$-ary tree if every internal vertex ha...
The text Introduction to Algorithms by Cormen, et. al. defines the Ackermann Function $A$ as follows: For integers $k \geq 0$ and $j \geq 1$, we define the function $A_k(j)$ $$A_{k}(j) = \begin{cases} j+1 &\quad\text{if } k=0\\ A_{k-1}^{(j+1)}(j)&\quad\text{if } k \geq 1\\ \end{cases}$$ The inverse of th...
I am studying LALR(1) parser and I have this question: Consider the following Grammar S - > V = E E - > F | E+F F - > V | int | (E) V - > id Construct the LALR(1) parsing table for this Grammar. While generating the item-set DFA for this problem, I encountered a problem in the fifth set. According to this website, htt...
I am working with a piece of software code which transforms a character array into a single integer. For example, if I have the array [ a, b, c ], then it becomes 97 + 98 + 99 = 294, for ASCII 'a' = 97, et cetera. So this code converts an arbitrary-length sequence of characters into a single number. The transformation ...