instruction
stringlengths
35
29.1k
In the following let $\Sigma=\{0, 1\}$. I'll prove that every language over $\Sigma$ is recognizable. Let $L\subseteq\Sigma^*$. Let $w_1,w_2,\ldots$ be the list of words in $L$. For every $i=1,2,\ldots$, let $M_i$ be the Turing machine that decides the language $\{w_i\}$, which trivially exists. Consider a Turing machi...
I am currently working my way through Language Models are Few-Shot Learners , the initial 75-page paper about GPT-3, the language learning model spawning off into ChatGTP. In it, they mention several times that they are using 175 billion parameters, orders of magnitudes more than previous experiments by others. They sh...
The language is: L1 = {w | n0(w) or n1(w) is prime} n0 means number of 0s and n1 means number of 1s I can show a^n (n is prime) is not context-free. But I can't find any solution for this one.
Introduction I have simple polylines as sequences of points. I need a triangulation with a configurable width. The goal is to get a 2D 'band' from the input polyline without self-intersections. Description: Input is a 2D point sequence {P1, ..., Pn} (Polyline) and a target width of the triangulated band. Output is the ...
I am trying to create a circuit based on this truth table below: can you describe how to make the circuit using only logic gates In_1 In_2 In_3 Out 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 This is what I hav...
I have a binary search tree of size $N$. The tree is height balanced: difference of heights of a node's subtrees is no more than 1 (true for RB or AVL trees). $K$ is the number of nodes that have a non-empty right subtree. If the tree is intentionally created to minimize $K$, then what is $\min(K)$?
I have found two ways of applying dynamic programming to the coin change problem of finding the minimum number of coins from a given set of denominations to make a given sum. I wanted to know if one is better than the other: def money_dyn1(m, coins): a = [[float("+inf") for j in range(m + 1)] for i in range(len(coi...
How can a 4-bit two's complement operation be implemented using boolean NOR gate? I search lots of 4-bit two's complement videos and articals, but most of them are using XOR gate.
How can a 7 segment decoder operation be implemented using boolean NOR gate ONLY? Question: Here's my truth table and k-map: Normal circuit diagram:
Let $M$ be a $m\times n$, in which rows and columns of $M$ are sorted in increasing. Problem. Find $k^{th}$ smallest number in $O(m\log(mn))$. My attempts. I merge all rows in a single sorted array in time $O(mn\log(mn))$ but this idea isn't efficient and I think there is a solution with running time $O(m\log(mn))$. Af...
I came up with a thought experiment on the limits of artificial intelligence that I was hoping to get advice on how to solve as well as any recommendations for further reading that explain relevant concepts for solving/dissolving the thought experiment. Suppose some superpowerful artificial intelligence A1 attempts to ...
While working on a job distribution problem, I ended up hitting a graph problem that I can't seem to get a foothold on. Consider a not-necessarily connected graph, like one shown below. Each step, we can delete up to N vertices from the graph, but can't delete two nodes if they are connected, only one or neither of the...
How to solve this recurrence relation: T(n) = R(n-1) + n log n R(n) = T(n-1) + n^2
FOO = {M | The length of language that M accepts is less than infinity} M: a turing machine M such that |L(M)| is less than inifinity: a turing machine such that the length of the language that the machine accepts, is less than infinity. For example, We have |M1| <3, it means this TM only accepts less than three wor...
Suppose i have 3 coins: A, B, C. Each one of them have different value: a, b, c. And if want to exchange coins A for coins B, i need to be able to give exactly a units of currency A and get exactly b units of currency B in return. The problem is to find how many different triples of coins i can have? For example, if i ...
By pumping lemma, we choose the word $w=a^{p^2}$ that the decomposing is $[a^sa^ta^{p-s-t}]^p$ such that $u=a^s,v^i=a^t,x=a^{p-s-t}$ $[a^sa^{it}a^{p-s-t}]^p=[a^{p+it-t}]^p$ We choose i=p+1,we get $ [a^{(1+t)p}]^p $ $=a^{(1+t)p^{2}}$ we see that the power $(1+t)p^{2}$ has 4 dividers thus doesn't belong to the Language L...
I'm Nestor Mermoz Thea. I have two definition over the Directed strong pseudoforest and Directed weak pseudoforest that I don't really well understand. Directed weak pseudoforest: A directed weak pseudoforest is a digraph, in which every weakly connected component contains at most one directed cycle. The class of all d...
I know the Independent set problem is NP-complete. But could there be a more efficient way to count the exact number of different independent sets in an arbitrary, given graph?
I was trying to figure out how I can perform multiplication of 2 big integers using FFT and convolutions, I ran into the following article: http://numbers.computation.free.fr/Constants/Algorithms/fft.html I understand the main points behind the algorithm but I can't understand this part: 2.3  More on the complexity of...
I've been thinking about this for a day now,can someone help me ? what language does S->aaSbb|SS|epslion make?
The Valeriepieris Circle is a circle within which it is supposed that the majority of the World's population lives. I'm interested in general-case and average-case algorithms for finding such a circle. I'm aware that this can be done in $O(nm)$ and perhaps $O(n + m)$ where $n $ is the number of pixels and $m$ is the nu...
I am studying theoretical computer science using the book "Foundations of Logic Programming" by J. W. Loyd. I am in the part about declarative semantics of definite programs. In the book, if $P$ is a definite program, we denote by $B_P$ the Herbrand base of $P$ and we define $T_P$ as: Definition. Let $P$ be a definite...
Hey guys, Got a tricky question here. I need to determine if this TM will ever halt on a empty word "". Seems like it will halt but I can't proof it. Can anyone help?
Given $m$ sorted arrays $A_1,A_2,\dots,A_m$, also $\mid A_i\mid=n$ for each $i=1,2,\dots,m$. How we can compute $k^{th}$ smallest number in union of $A_i$s (i.e. $\cup_{i=1}^nA_i$) in at most $O(m\log mn)$? $I.$ If I use Minheap to find $k^{th}$ element, th running time will be $O(m+k\log mn)$, so that $k$ can be $O(nm...
What would be an example of an algorithm that's in O(f(n)), but not in Θ(f(n))? The only thing I could think of, is an algorithm that behaves differently for different problem sizes, such as an algorithm that performs n operations for even problem sizes and n^2 operations for odd problem sizes. Such algorithms are rare...
I have the following problem. Imagine a fully connected undirected graph, and I wish to calculate the optimal route for a traveller across that graph. Each vertice can only be visited once or not at all. Each vertex visited gives a positive payoff. However, each edge has a negative cost associated with its distance. Th...
So I've been trying to understand endianess for the past couple of days but I'm not sure if I'm overthinking this or not and I don't have anyone I can ask to confirm things. Here is how I look at things.. Say you have a defined value which represents the amount of pebbles there are in my city. Decimal: ‭1193046‬ Hex: 0...
I have a set of sets, for example { {1, 2, 3}, {1, 2}, {2}, {2, 4} } I want to find all sets which are not subsets of another set. For example, {2} and {1, 2} are both subsets of {1, 2, 3}, so my answer would just be {1, 2, 3} and {2, 4}. Let's call these "max sets". There is a clear brute-force solution to this, ...
Echo state networks are theoretically equivalent to DFAs/NFAs, but how would you use an ESN to parse a regular language? Would you just feed many different input strings, some from the language and some not, and then train it to output one or zero to indicate whether the string belongs to the language?
I need to write recursive function in pseudocode for n-th number term of $a_n=n!+2^n$. Whole code should be contained in one function with $n$ as function argument.
I am having troubles in understanding why this proof is done like that. Why do we need to make a reduction to Ld which isn't even in RE to disprove Lu being rec? And why does the book (Automata Theory, Languages and computation by Hopcroft, Motwani, ullman) constructs a machine for Ld to get a contradiction? This is th...
Let's say we have a NFA such as follows: We know it's equivalent DFA is follows, after minimization: We know that when converting from NFA to DFA, the resultant DFA would have around 2^( number of states in NFA ). This is where I get a bit confused: Should we consider the "dead state" of NFA when converting to DFA. B...
I am reading Michael Sipser's "Theory of Computation" 2nd edition, chapter 1 , Topic "Non determinism" ( Section 1.2 ) Let's use this E-NFA as an example My question is, do we transition along "epsilon transition" before reading any input or after reading any input? assume input is "a" Case 1: Before reading any input...
Possibly related to this. Let $T$ be the text and $n$ be the length of the pattern. I understand that if substrings of $T$ are interpreted as base-$d$ numbers where $d$ is the alphabet's size, then for all suitable $k$: $$T[k+1\text{..}k+n] = (T[k\text{..}k+n−1] − T[k]\cdot d^{n-1})\cdot d + T[k+n]$$ What I don't under...
I don't think it's a CFL, but I'm having a hard time using the pumping lemma to prove this. Is there any way I can use homomorphism? Maybe h(a)= a, h(b) = lambda... If the pumping lemma is more appropriate then maybe... let m = constant of pumping lemma for some string w = a^nb^k let w =xyz such that |xy|<=m and |y|>=1...
For a project I'm working on, I need to generate some data to test the Gzip compressor, and I wrote my own implementation of Markov chain for it, and it's a 2-level nested one. But when I generate data using my script and feed it to Gzip, it always - without exception - expands the data, as if there's no redundancy in ...
I have no idea how to approach this question... How would I go about proving or disproving this? any explanation is appreciated.
If we think of the algorithmic problem of doing a convolution of two arrays, it turns out that converting them to the frequency domain first and then doing an element-wise product is equivalent. And this leads to an efficient algorithm where we invoke the FFT to go to the frequency domain efficiently (in $O(n \log(n))$...
To my knowledge, in block-structured programming languages, there are 2, maybe 3 main ways of delimiting a block. Using start and end tokens, this can be brackets or reserved words etc Using indentation, like python, which uses the offside rule to delimit blocks Using prefix notation for control structures, like lisp/...
I'm working on the implementation of a cantor set on a 2-dimensional plane. It looks like this. Honestly, There is the obvious algorithm for the cantor set, but it includes a recursive method call. Unfortunately, My environment(Houdini vex) does not support recursive function calls, so I have to design the algorithm wi...
I have the following problem: Given a context-free grammar $\mathcal{G}$ and a finite state automaton $\mathcal{A}$, where both are over the alphabet $\Sigma=\{0, 1\}$. Is it decidable whether $L(\mathcal{G})=L(\mathcal{A})$? I assume this is undecidable, since I already know the following fact: It is undecidable wh...
Problem A time based followship is defined as a person changing to a new job, and there is an existing employee there in the new company whom he used to work together. In this case, the old guy gets 1 follow. Challenge I wrote some simulation code, but the complexity is quadratic and already taking a few minutes for 10...
I have 2 arrays, A and B, which each contain the same N elements, but in a different order. (A different permutation) There are also no duplicates in A and B. I'm trying to devise an algorithm which generates a series of moves, which changes A into B. A move means to move one element in an array to another position (no...
I am studying theoretical computer science using Ayala's book "Fundamentos da Programação Lógica e Funcional" (the book is written in Portuguese), but the part I am studying right now is based on Lloyd's book "Foundations of Logic Programming". I am currently in the part about definite programs, trying to solve the fol...
This question deals with how to find the maximum matching in a tree. I understood the answers, but for one part. Choose a root arbitrarily. For each subtree, calculate the maximum matching within the subtree, as well the maximum matching within the subtree that doesn't touch the root of the subtree. You can think of i...
I apologize in advance for asking this, since I'm sure this site is flooded by amateurs like me asking about P and NP. If there's a better platform to ask this on, please let me know, but this question has always bothered me. Suppose you have a perfect binary tree of depth $d$. Each node contains a boolean. Of the $2^{...
I have had a somewhat hard time trying to understand how ChatGPT can "solve" some tasks that cannot be entirely cast as language-model-based rephrasing of textual subsets of the internet directed by a textual query. For example, ChatGPT seems to be able to do calculations, even if not always appropriately used, execute...
In a directed graph $G=(V,E)$ we denote a vertex $s\in V$ to be a 'source' if there exists in $G$ a path from $s$ to all other vertices $u \in V$. The problem asks for an efficient algorithm to return the 'source', in case there isnt any, return false. I've been able to come up with a naive approach to his problem: $\f...
Can someone help with an example of a function such that $f(m ,n)$: $f(m ,n)$ takes 2 parameters $(m, n); \ m, n \in \mathbb{Z^+}$ The optimal running time to compute is $C(|m|^{|n|})$ in the worst case, where $|n|$ and $|m|$ is the size (number of bits) of $n$ and $m$ respectively. The value of $f(m, n)$ is dependent...
(Diestel, Graph Theory) Corollary 1.5.2: Every tree has an enumeration of the vertices $\{v_1, v_2\ldots v_n\}$ such that each vertex $v_i$, with $i\geq 2$, has a unique neighbour in $\{v_1, v_2\ldots v_{i-1}\}$. I am wondering if there is an efficient algorithm that could produce such an enumeration in $O(n)$.
This was one of my exam questions and the answer is apparently no. Can someone explain why because I don't understand.
I have a number of agents and tasks. In my case, the agents and the tasks have time constraints: so agent1 loves doing task1, but task1 must be done at 10am or 11am, and agent1 is only available after 1130am, also, task1 and task2 can happen at the same time, but the cost increases if so. Is there a way to introduce d...
I want to compare two trees: I will consider the trees equal if they are: Isomeric-i.e have the same structure. Nodes in both trees have the same values but the order of the children nodes are not necessarily the same. A picture is worth a thousand words: eg: A) B) C) D) ...
I have a graph of vertices and connected edges as shown in the image below. I have a function that iterates from every single vertex and finds closed loops in order to find all polygons in the graph. Here is an example of my graph which has found all the polygons in the graph: Now if i add a new segment (seen in red) ...
I am trying to learn about approximation algorithms. In some research papers, it is mentioned about the absolute approximation ratio. what does the absolute approximation ratio mean? is it different from the asymptotic approximation ratio? if there is any resource that might help to understand more about this, please l...
I am trying to understand the difference b/w functional and decisional problems. The core as I understand is this: Functional Problems: Given an input $x$ we calculate some function $f(x)=y$ over it. Decisional Problems: Given inputs we output YES or NO depending on some logic or algorithm. As far as I have read a func...
I have an algorithm that recursively connects together pairs of nodes into new nodes. It looks like the Huffman code algorithm, except that a node can be re-used after it has been part of a merge. The result is a graph where each node has two parents, but can have any amount of children. Is there a term for such a grap...
This is a paragraph from the book CLRS: What we need is known as an optimal binary search tree. Formally, we are given a sequence $K = (k_1, k_2, ..., k_n)$ of $n$ distinct keys in sorted order (so that $k_1 < k_2 < ... < k_n$), and we wish to build a binary search tree from these keys. For each key $k_i$, we have a p...
As a side-project, I had the idea to write some kind of an algorithm that would evaluate all participations in our weekly Pub quiz, to then calculate the average strength of the participants. This is the information that I have available: The final score of the group All members of the group for a particular week As ...
Lets take an example of the range of N=32 bits 2^32 = 4294967296 00000000000000000000000000000000 00000000000000000000000000000001 00000000000000000000000000000010 00000000000000000000000000000011 ... 11111111111111111111111111111100 11111111111111111111111111111101 11111111111111111111111111111110 1111111111111111111...
How can I update values in Binary Search Tree without affecting its properties (all the nodes in the left subtree have values that are less than the value of the root node and all the nodes of the right subtree have values that are greater than the value of the root node). I tried deleting and inserting the new Value, ...
I want to prove this language $L=\{a^nb^{n^2+n}:n\in\Bbb N\}$ to be nonregular by the pumping lemma. This is my attempt, is this a correct way of doing it? Let's suppose $L$ is regular. Let $s = a^kb^{k^2+k}$ such that $k \geq 0$ as a pumping length. So we have $s \in L$ and $|s| \geq k$. Then, by the pumping lemma, ...
I have an optimization problem and I am wondering if there is a better way to solve it than using a naïve brute force method. I have a number of tasks T that must be completed, and a number of agents A to do work in parallel to one another. For this, T > A. What I would like to do is write a program to figure out the o...
I want to prove (or disprove) the following conjecture: Let $\Sigma$ be a finite alphabet, and let $L \subseteq \Sigma^*$ satisfy that there are no $v, w \in L$ such that $v$ is a proper substring of $w$. Then $L$ is finite. I have the intuition that this is true, haven't been able to find a counter example, but am u...
I need a data structure/algorithm to efficiently retrieve borders and update changes. There may be many (unconnected) regions of the same color. The shape of regions changes frequently over time and pixels may be randomly inserted - although most changes happen along the borders. In this case, a pixel borders another i...
I proved this language $L = a^nb^nc^m; n,m \geq 0$ is not regular the following way: Let $L \cap a^*b^* = a^nb^n$ We know that $a^nb^n$ is not regular, and $a^*b^*$ is regular. Thus, if $L$ is regular, then $a^nb^n$ is too, but since the latter is not, $L$ is not. Is that safe to have as a proof?
Consider the language definition: $L = \{<M>| M$ is a DFA and $M$ accepts some string of the form $ww^{r}$ for some $w\in \Sigma^{*}\}$ The language $L$ is : A) Regular B) Context-free but not regular C) Recursive but not context-free D) Recursive enumerable but not recursive Solution provided: Is to create a product m...
Let's assume that $L_1 = a^nb^{2n}$ and $L_2 = a^na^{2n}$, knowing that $L_1$ is not regular, and $L_2$ is. We also know that regular languages are closed under intersection and union, and complement. What can we say about $L_3 = L_1^\complement$ and $L_4 = L_2^ \complement$? It seems correct to say $L_4$ is regular, b...
I want to prove this language $a^nb^m; 0 \leq n< 3m+2$ to be not regular by the pumping lemma. This is my attempt, is this a correct way of doing it? Let's suppose $L$ is regular. Let $s = a^{3k+1}b^{k}$ such that $k \geq 0$ as a pumping length. So we have $s \in L$ and $|s| \geq k$. Then, by the pumping lemma, $\exis...
The question of the relationship between Kolmogorov complexity and data compression is rather difficult. However, at the heuristic level, the complexity of an object and the rate of its compression by known algorithms are related. I used the built-in function Compress[] of Mathematica to estimate the compression ratio ...
GAP is a computer algebra system (CAS) that Wikipedia tells me is written in C, a procedural programming language. Does this mean we can say GAP's language is procedural? Or is this characterization a misunderstanding of what a CAS is, and what programming paradigms are?
I am looking for an efficient way to perform nearest neighbor searches within a specified radius in a two-dimensional plane. According to Wikipedia, space-partitioning data structures, such as : k-d trees, r-trees, octrees, quadtrees, cover trees, metric trees, locality-sensitive hashing, and bins, are often used for...
Consider the following approximation algorithm for the problem of finding a maximum clique in a given graph $G$. Repeat the following step until the resulting graph is a clique. Delete from $G$ a vertex that is not connected to every other vertex in $G$ and also delete all its incident edges. Show that this greedy app...
I have two sets of 2-dimensional coordinates on an integer grid, $A$ and $B$ $A = \{(x_{A1},y_{A1}), (x_{A2}, y_{A2}), (x_{A3}, y_{A3}), \dots\}$ $B = \{(x_{B1},y_{B1}), (x_{B2}, y_{B2}), (x_{B3}, y_{B3}), \dots\}$ I need to find all coordinates in $B$ that are directly above, below, or to the left or right of any coor...
As of recently I've been trying to get better at algorithms and I've stumbled onto one that I can't seem to solve. The idea behind the algorithm is to try to find as many different ways as possible to store each object of size K in an array of N*N given certain restraints. So take this grid right here .X.X .XX. ...X .....
Consider the set of all valid Turing Machines descriptions $T_{All}$, and the set of functions that denote the real (not asymptotic) running time of Turing Machines in $T_{All}$, lets call it $R_{All}$. Since there are infinite functions, not all of which might represent the running time of a valid Turing Machine, how ...
I am having a problem understanding the following: This is the background of the lemma: To prove the lower bounds, we use the classical lower bound construction from [5, 9]. We have an input instance L with three regions of items. In the first region, there are items of size close to 1/6, in the second region come ite...
My understanding is an "Enumerator" is a Turing Machine that: instead of taking an input string, then going through a series of transitions and "halting" or "not halting" on it, it does not accept any input string and it starts with a blank string and builds the final string according to the rules of the language For e...
Let's say we have a NFA as follows: It has 3 states, q1 - q2 - q3 and can make transition from q1 to q2 on 0 or epsilon and from q2 to q3 on 1 or epsilon My question is do we take epsilon transition before reading input or after reading input and after reading the input, if we reach a state where we have epsilon trans...
OpenAI's Chat-GPT told me: There is no known exact algorithm for finding the largest bipartite subgraph in a graph in polynomial time. This problem is generally believed to be NP-hard, which means that there is no known polynomial-time algorithm for solving it. Is this correct?
Trying to solve an ILP optimization problem with a number of potential boolean variables and then express constraints on these variables based on those boolean results. Let's say I am doing 5 coin flips and allowing people to choose heads or tails for each coin flip. They are able to choose one or more specific flips a...
When I want to judge whether two regular forms represent the same language, I have learned the next method: create the (non-deterministic) finite-state automata which accepts the language the given regular form represents for two regular forms respectively. convert the two NFA into DFAs. Judge whether the two DFAs a...
I am reading Michael Sipser's "Introduction to theory of computation" 3rd edition, page 55 - 56, the topic "equivalence of DFAs and NFAs" Case 0: Michael Sipser asks us to handle the transition function of "non epsilon NFAs" as follows: δ'( R, a ) = $\bigcup_{_{r \epsilon R}}^{}δ(r, a)$ Case 1: Michael Sipser, then, ...
I stumbled across this game in Simon Tatham's puzzle app. It's called cube. The description according to the game is: You have a grid of 16 squares, six of which are blue; on one square rests a cube. Your move is to use the arrow keys to roll the cube through 90 degrees so that it moves to an adjacent square. If you r...
As the title states, I am asked to prove that a directed graph $G=(V,E)$ is strongly connected iff for all non-empty subsets $\emptyset \neq S \subset V$, the cut $\delta(S) \neq\emptyset$, where $$\delta(S)= \left\{ (u,v)\in E \mid u \in S,\; v\in V \setminus S \right\}.$$ I've shown that if $G$ is strongly connected,...
I'm reading https://ilyasergey.net/CS4212/_static/lectures/PLDI-Week-07-more-parsing.pdf On page 11, there's the definition of Sum Grammar: S -> E + S | E E -> number | (S) Just wondering if this grammar same as follows: S -> number | (S+S)
I'm interested in analyzing the randomness of strings using relative count for 1-, 2-, etc tuples. E.g. for a long string "abbccba.." with an alphabet ["a", "b", "c"] , the quantities ["a", "b", "c"], ["aa", "ab", "ba", "bb", "ac", "ca", "cc", "bc", "cb"] etc should be approximately equal for every kind of tuples. Of c...
A sequence $(a_1,a_2, \dots, a_n) $ and natural numbers $n$ and $k$ are given. We want to calculate the longest (strictly) increasing subsequence of sequence $(b_1,b_2, \dots, b_n)$ for which there exist an interval of pointers $[l, r]$ and an integer $x$, $-k\le x\le k$, such that $b_i = a_i + x$ for $i \in [l, r]$, a...
I am learning Markov algorithms and came across the paper Markov Algorithm by CHEN Yuanmi. I am trying to understand the following example (well, any of the examples in the paper). Example 3: Multiplication. MA3 = $\{\Sigma, P, P_0\}$ $\Sigma = \{a, A, B, C, \#\}$ Productions in $P$: $p_1: Ba \to aB$ $p_2: Aa \to aB...
Let's say, initially we have an epsilon NFA in which the start state, say state 1, has epsilon transition to state 3 We know when converting from epsilon NFA to NFA, we apply the following formula for each state: E(T(E(state), input)), where E = epsilon closure and T = transition function. In this stage the start state...
I'm looking for a good mathematical symbol to represent the conversion from a double-precision floating value to an unsigned 32-bit integer value. Does anyone have suggestions for a good Greek letter or a math symbol to express this? The best candidate I can think of is to use a symbol for a floor function with a subsc...
I asked the chatbot at you.com, "what is an advantage of dynamic scoping?" and it said the following on the pane titled YouChat. (If you click the link, you will probably see a different reply by YouChat since, apparently, there is some random/live factor in its algorithm). One of the main advantages of dynamic scopin...
The definition of "Single Connected" is that for every $u,v \in V$ there is at most a single simple path from $u$ to $v$, and at most a single simple path from $v$ to $u$. The objective is to find an efficient algorithm to decide whether the graph is "single connected". I've managed to come up with the following algori...
I am working through (1) "GLL Parsing" (2) "GLL parse-tree generation" and (3) "Structuring the GLL parsing algorithm for performance" by Elizabeth Scott and Adrian Johnstone. An example grammar given in (3) 2.1 is S ::= b a c | b a a | b A c A ::= a When parsing bac the following packed forest is shown as the result....
I'm attempting to search through all the integers between 10^15 and 10^16 to check if they are in the oeis sequence A277274, and the entirety of the program can be summarized as mostly equivalent to : for n in range(int(10**15),int(10**16)): if pow(3, n, n) == 11: print("Found one: {}".format(n)) Since the...
Problem: we have a sequence of numeric values, e.g. [102, 25, 77, 17, 2, 13]. We need to implement 3 operations, each can be at most logarithmic time complexity. insert(i, v) - inserts value v at index i. remove(i) - removes value at index i. peek(i) - returns value at index i. What I've tried: AVL tree, where node k...
There are n houses in a city T, some of which are connected by streets in such a way that there is exactly one path between any two houses (i.e. the graph of houses and streets is a tree T). Tanya has already prepared $m$ gift bags but she ran into a problem. After all, she herself also needs to find a house in the cit...
I am not sure if this is a math question or a computer science question, so please direct me to a better suited community if needed. Given a bounded space G,and a set of points P, I want to create two sets of polygons of Q, and R where Q is a set of polygons where a point in P is the center of each polygon in Q, and R ...
In an older question I asked about stack, the statement came up that recursive functions cannot be inlined (link). I am interested in whether this statement is actually true or not. I understand that it is extremely impractical. But, is it impossible, in theory? To my intuition, it seems like it should be possible. But...
In an abstract rewriting system $\langle A, \rightarrow\rangle$, confluence may be stated by using set inclusion. Namely, a rewriting system is confluent iff ${\leftarrow^*\rightarrow^*}\ {\subseteq}\ {\rightarrow^*\leftarrow^*}$ (or equivalenty as the Church-Rosser theorem, ${\leftrightarrow^*}\ {\subseteq}\ {\rightar...