instruction
stringlengths
35
29.1k
For language $L$ over an alphabet $\Sigma$ denote $\gamma_L(n)$ as the number of words of length $n$ in the language $L$. It is known that for regular languages this function represents a sequence with rational generating function (which is equivalent to that $\gamma_L(n)$ is linear-recurrent for sufficiently large coe...
If there is a finite set of Instances of size n and the set of (reasonable) deterministic algorithms is finit. Can any randomized Algorithm be seen as a probability distribution over the set of deterministic Algorithms? And if yes, why?
I am comparing two comparison and binary data structure based sorting algorithms, the Tree Sort, and the Heap Sort. I am measuring the time taken for both algorithms to sort an increasing size of an integer dataset. However, I am wondering if there are any other variables which I can modify, for example standard deviat...
I read that the following language is r.e. but not not-Turing recognizable $L$: On input $M$ (where $M$ is a Turing Machine), $M$ accepts at least 20 inputs I am not sure why it is not not-Turing recognizable., since I could perhaps make the following reduction from $\overline{A_{TM}}$ to $L$ given this procedure $R$ n...
The following is the definition for Proximate Sorting given in my paper: An array of distinct integers is k-proximate if every integer of the array is at most k places away from its place in the array after being sorted, i.e., if the $i$th integer of the unsorted input array is the $j$th largest integer contained in th...
I'm looking into implementing RLNC as a project, and while I understand the concept of encoding the original data with random linear coefficients, resulting in a number of packets, sending those packets, and thus the client will be able to reconstruct the original data from some of the received packets, even if a few o...
It is simple to decide powers of 2 in $O(n)$ time because it's just "0-bit Unary" after bit-1. (eg. $1000$ is a power of 2 in binary). I haven't found many other trivial powers of $K$ that can be decided in polynomial-time with the binary-length of the input. Question Can we decide if a number is a power of any given $...
Please tell me why the expression i>0 && nums[i] == nums[i-1] && !used[i-1] works on getting unique permutations. And what is the math behind it? The problem is as follows: Given a collection of numbers that might contain duplicates, return all possible unique permutations. Example: Input: [1,1,2] Output: [ [1,1,2], ...
The problem is: count all increasing subsequence of s. def main(): print(count([3,2,4,5,4])) def count(s: list) -> int: n = len(s) counter = 0 result = {} if n == 0: return 0 for i in range(n): counter += recurse(s[i+1:], s[i], result) return counter def recurse(s: list...
Today I presented about IP address during my online class based on Computer Networks by Andrew S. Tanenbaum and during QnA session, I was asked about private IP Address range. 10.0.0.0 – 10.255.255.255 172.16.0.0 – 172.31.255.255 192.168.0.0 – 192.168.255.255 The questioner asked my why private IP address is determine...
On page 235 of Turing's 1936 paper, in the figure marked (C), the illustration appears not to match the description. The description states that space has been made on the left of the scanned symbol, and the m-configuration written in its place but the illustration (repeated on p. 242 using SD encoding) shows no scan...
I recently came across the question: Show that there are at most $\lceil n / 2^{h + 1} \rceil$ nodes of height hh in any nn-element heap. I looked for some solutions and found this one: Binary heap: prove that number of nodes of height h is not bigger than $\lceil \frac{n}{2^{h+1}} \rceil$ But I got confused with the a...
I've written an answer to this question, which asks about the following: What is the time complexity for the given code that prints prime numbers from start to end? Is it $O(end*\sqrt{n})$? /** * Print prime numbers between start and end inputs * Time-Complexity: O(end * sqrt(n)) * Space-Complexity: O(1) only one va...
Consider a sorted list of numbers $C_{0}=\{0,1,2,3,...,n-1\}$ from where one element will be eliminated at each step. We are also given a value $L$ in $[0, 1)$ and let the indexing start from $0$. Given a value $L_{0} = L$ in $[0, 1)$, we find $a_{0} = ⌊L_{0}⋅n⌋$ and remove the $a_{0}^{th}$ element $p_{0}$ from $C_{0}$...
$L_1 ,L_2$ are regular language. We form a new language $L_{12}$ as follows: $$L_{12}=\left \{ w_1\cdot w_2\mid w_1\in L_1\land w_2\in L_2\land |w_1|=|w_2| \right \}$$ In this exercise I am not given any alphabet and I'm required to build a PDA for $L_{12}$. But by definition $M=\left \{Q,\sum,\Gamma,\delta ,q_0,\dashv...
Consider an undirected graph $G = [V,E]$. Let $V$ be the set of vertices: $V = \{v_1,..,v_n\}$ and $E$ be the set of edges. Let $C$ be the connected component that contains vertex $v_1$. I want to find the connected subgraph (not sure about this terminology) with maximum number of edges, among all the connected subgrap...
The fake proof: We know that $\mathbb{R}$ is uncountable, hence we cannot enumerate over it. But what we do know is that $\mathbb{Q}$, the set of rationals, is countable, and even denumerable. We also know that we can construct $\mathbb{R}$ through what are called Dedekind cuts. We choose to let the partition itself d...
I'd like to read up on non-recursively enumerable languages. Which textbooks should I look into to get a decent understanding about the subject? Thank you.
A few minutes ago I asked a question about a "proof" that $\mathbb{R}$ is enumerable that crossed my mind: What's wrong with this "proof" that $\mathbb{R}$ is enumerable? I was told to look into ordinal numbers, and that after crossing $\omega$ we stop considering something to be an enumeration. Why is this the case? A...
Assume an undirected graph and a DFS traversal on it. I am interested in the DFS tree which encodes the discoverer/discovered (parent/child) relationships of the traversal. Just to make sure we are on the same page, define a discovered vertex x as one that has been visited but descendants of it are still being processe...
global volatile RingBuffer queue; global Lock queueLock; global CV queueEmptyCV; global CV queueFullCV; public method producer() { while (true) { task myTask = ...; // Producer makes some new task to be added. queueLock.acquire(); while (queue.isFull()) { //#### wai...
I am given a Finite Automaton and the question is to design an Equivalent PDA for it. This is my FA: Is this PDA correct or do I need to add a stack to it? If its right when is the stack needed?
In Computer Science μ-function is used to extend set of primitively recursive functions to generally recursive functions, and I can't understand what this function does. There is a lot of formulae, but I can't understand what is is. Let's say I'm writing in Python (or any other general purpose language). What are examp...
With my application, I have Collection X: thousands of floating-point numbers with the value range [0, 1], not sorted. Collection Y: 11 floats ranging from [0, 1], sorted. The size of X is known. Let it be L. The goal is to quantize X and map it onto Y, so that we get a hash array of indices of Y for X. Eventually Y ...
Why do programmers write parallel programs instead of giving them the ability to automatically convert from serial to parallel?
I'm trying to analyze the following streaming algorithm for counting triangles (see below). It supposedly works also for dynamic graphs (i.e. "turnstile model", where edge deletions are allowed). What am I missing? According to my (buggy) analysis of the reported estimator's variance, the variance equal to 0 (see belo...
I need a data structure, which allows efficient queries for 'give me the group of x'. Let me give you an example: Group 1: [a, b, c] Group 2: [d, e] Group 3: [f] getGroupOf(d) -> [d, e] There are no significant constraints on storage or construction time. I only need getGroupOf to be O(logn) or faster. I am thinking...
Assume I have two Krom formulas $\psi_1, \psi_2$. Krom formulas are propositional formulas in CNF that have 2 literals in every clause. Each literal can be negated or unnegated. In other words, $\psi_1,\psi_2$ are 2-CNF formulas. For instance: $(x_1 \vee \neg x_2) \land (\neg x_2 \vee x_3 ) \land (x_3 \vee x_4)$ I ...
Suppose we have the following directed graph. When I click on - say - node $e$, it should make the in-pointing neighbors and out-pointing neighbors of node $e$ red, as shown in the below Expected Result. My purpose is that when I click on any node of a directed graph it should tell me what nodes it is influencing (out-...
I'm working on an e-commerce application where users can add stand-alone products like speaker or they can add a bundle product like desktop that has options like mouse, keyboard etc. All the products and options are finally added as cart items to the cart. For example Desktop - Mouse - Keyboard Speaker After addi...
In this paper (https://arxiv.org/pdf/1706.06708.pdf) the authors prove that optimally solving the $n\times n\times n$ Rubik's Cube is an NP-complete problem. In the process, they must show that the relevant decision problem belongs in NP (section 2.5 on page 6). To do this, they describe an algorithm that nondeterminis...
Consider a bipartite Garph $G=(L \cup R, E)$. Naturally, a b-Matching problem is to find a set of edges $M \subset E$, such that each node in $L$ and $R$ are adjuscent to maximum $b$ neighbors, and a weight function $w(e), e \in E$ is maximized. What if we have different $b$? e.g., $b(v)=5, \forall v \in R$ and $b(v)=2...
Knowing that all Recursive languanges are Decidable and All Not R.E. Languages are Undecidable (correct me if I am wrong), Are all languages which are R.E. but not Recursive also Undecidable? R.E. ==> Recursively Enumerable
Decision Problem: Is $2^k$ + $M$ a prime? The inputs for both $K$ and $M$ are integers only. The solution is the sum of $2^k$+$M$. (Use AKS to decide prime) The powers of 2 have approximately $2^n$ digits. Consider $2^k$ where $K$ = 100000. Compare the amount of digits in $K$ to the amount of digits in it's solution! Q...
Given a sequence $A$ of $N$ distinct integers, does there exist a strategy to get at least one subsequence with size $\geq \lfloor \frac{N}{2} \rfloor$ of the sequence in sorted order in $O(n)$ time? For example, let's say that $A = [4, 11, 6, 2, 9, 7]$. Then, one of the required sequences can be $[2, 7, 11]$, which is...
The following excerpts are from the section Fibonacci Heap from the text Introduction to Algorithms by Cormen et. al The potential function for the Fibonacci Heaps $H$ is defined as follows: $$\Phi(H)=t(H)+2m(H)$$ where $t(H)$ is the number of trees in the root list of the heap $H$ and $m(H)$ is the number of marked ...
I have to count the number of one's in last $m$ bits in a stream of bits and $m \leq n,$ where $n$ is the window size and it should take polylogarithmic space in $n$. I could only store last $n$ bits and then count the number of one's in those $n$ bits but it takes $O(n)$ space. How to achieve it in $O(\log^k n)$, $k>0...
Wikipedia claims that the Game of Life is P-complete (or the decision problem version of it is; the function version, I suppose, would then be FP-complete). Colloquially, P-complete and FP-complete problems are difficult, if not impossible, to parallelize. However, most software for evaluating the Game of Life is para...
I need to form PDA for this language: {$a^nb^m|n=m \vee n=2m$} I know the idea of building each one separately but how do I combine them into 1 PDA? LHS: for every 'a' I push 'A' inside stack and for every 'b' I eject 'A'. RHS:for every 'a' I push 'A' inside stack and for every 'b' I eject 2 times 'A'. How can I combin...
Can we do multiprocessing on single core system ? I thought that single core means that ONLY one process/thread can execute at any time. For multiple processes , there can be concurrent execution to appear as they are executing Simultaneously.
Assume I have two Horn formulas $\phi_1, \phi_2$. Horn formulas are CNF formulas so that each clause has at most one unnegated literal. For example: $x_1 \wedge (\neg x_1 \vee \neg x_2 \vee x_3 )\wedge (x_3 \vee \neg x_4)$ I want to decide whether $\phi_1,\phi_2$ are logically equivalent, i.e., $\phi_1 \leftrightarr...
Given an array composed of pairs, like this: [[3,5],[1,5],[3,2],[1,4]] Each element in the array (call it pair) means that pair[0] and pair[1] are adjacent in the original array. Note, they can come in either order. For instance, for the sample array above, the original array would be: 4,1,5,3,2 (or the reversed versio...
I want to determine the transitive reduction of this graph: as of now, I only found the first step of doing this: represent the transitive closure of the graph as an adjacency relation, so this is what I did: (a,b) (a,c) (a,d) (a,e) (b,d) (c,d) (c,e) (d,e) I'm not sure that this is the correct transitive clos...
Knowing that O(n^2) > O(nlogn) > O(n) > O(sqrt(n)) > O(logn) > O(1) and having below python code: import math def f1(n=9): return math.sqrt(n) def f2(n=10): return [math.sqrt(i) for i in range(n)] Am I correct to infer that O(f1(n)) = O(1) Am I correct to infer that O(f1(n)) = O(n)
This is from Kleinberg's Algorithm Design text (Theorem 6.14) Let $M$ be an alignment of $X$ and $Y$. If $(m, n) \notin M$, then either the $m^{\text{th}}$ position of $X$ or the $n^{\text{th}}$ position of $Y$ is not matched in $Y$. The theorem does not state that $m, n$ must be the last elements of $X$ and $Y$ respec...
Decision Problem: Given integers as inputs for $K$ and $M$. Is the sum of $2^k$ + $M$ a $prime$? Verifier m = int(input('Enter integer for M: ')) sum_of_2**K+M=int(input('enter the sum of 2^k+m: ')) if AKS.sum_of_2**K+M == True: # Powers of 2 can be verified in O(N) time # make sure there is all 0-bits after the ...
I am curently working on automatic label placement, so for evaluating a model, one metric is to calculate the Area A: A is the sum of every part of a rectangle covered by another. So if two rectangle overlap, A = 2 * Arectangle, if three rectangle overlap A = 3 * Arectangle, ... Because i am working in real time, i nee...
Is $L=\{<M> | L(M) \ is \ finite\} $ decidable ? M is a TM. I think its relative simple to proof with the theorem of rice. But I am interested in a solution which does not use the Rice theorem. This my try : Let f(<m,w>) be a function which works in the following way : Run w on M If M accepts Construct a TM Mwhich ac...
I would like to write a grammar to convert EBNF description to a list of CFG production rules, instead of an algorithm. Can CFG production rules is generated from an EBNF description by a rewrite system rewrite EBNF description to halt state that final string is composed by CFG production rules and separate character f...
I'm working on a game-related application, and I'm trying to find the middle point of the most populated area in my map. Example: Positions (format [x, y]) : [48, 49] [51, 50] [49, 50] [51, 49] [49, 48] [130, 150] [129, 148] Excepted output : [50, 50] or something close enough like [49, 51], [51, 50] To create this ...
I encountered a problem which asks to give an example of an undecidable language $B$ such that $B \leq_m \overline{B}$... However, I could find it hard to construct an example ... my difficulty is that given an undecidable but Turing recognizable language, say $A_{TM}$, its complement $\overline{A_{TM}}$ is not Turing ...
Given a planar 1-in-3 sat formula, can someone reduce that formula into a graph that asks the question when ever there is an independent set for it, that's also planar?
I want to model the absorption of CO2 with multiple different materials such as cement, limestone, wood, etc? I know Matlab is capable of these types of physics simulation according to this research paper: Research Paper, however, I am not sure if Python or another programming language could complete this task easier.
I am pretty new in λ calculus. And I am now trying to understand Alpha equivalence. Basically can I think it in this way: as long as I make sure all the bound variables and their corresponding abstractions are noted as the same letter, the new expression is alpha equivalent to the old one? Here is one example: (λx.(λx...
I was wondering if it can be said that $\mbox{NL}^\mbox{NL}=\mbox{NL}$. That is, a decision problem $S$ can be decided using a nondeterministic TM using logarithmic space with oracle calls to $S'\in \mbox{NL}$ iff $S\in \mbox{NL}$. My intuition is yes, because if $S'\in \mbox{NL}$ then there is a NDTM $M$ that decide...
I have this doubt for long time. When i save a notepad file, it takes the memory for the information in the file. let's say, I type 'ABC' in notepad and saved the filename as stack, it shows that the memory consumed 3 bytes for the file but what about the file name " stack" ? Where does it store that particular informa...
If $j \in Z^+$ and $k \in R^+$ and $j − 1 < \log k < j$. Why is $j = O(\log k)$? (All log's are in base 2) I know I have to find constants where $j <= c \cdot \log k$ but I need some help with it.
I have this piece of code for counting sort and it is "counting" sort, because it actually counts occurrences. And it doesn't use cumulative sum. I want to ask why it is bad to not to use cumulative sum in counting sort algorithm? (BTW it has O(n) runtime complexity) def my_counting_sort(lst): counts = (max(lst)+1)...
I am wondering if there are some particularly rich problems that have a large intersection with algorithms and data structures. An example could be the travelling salesman problem. Any other suggestions ?
I'm confused about the definition of prime implicates in Horn formulas. For example in the paper of Kira 2012 on page 109 it is stated: Now in the paper of Boros 2010 on page 82 the following definition is used: My goal is to decide whether a Horn formula is prime or not in polynomial time. For that I want to assume ...
Given an alphabet, say $\Sigma = \{0,1\}$, I can make a one-to-one mapping from all possible strings $x \in \Sigma^*$ to $\mathbb{N}$. This could be done by ordering $\Sigma^*$ lexicographically and assigning the $i$th string $x_i$ to number $i \in \mathbb{N}$. But given strings $x_i,x_j \in \Sigma^*$, is there any spe...
The following is an excerpt from a material on NP-Theory: "Let G be an undirected graph and let s and t be vertices in G. A Hamiltonian path in G is a path from s to t using edges of G, on which each vertex of G appears once and only once. By HAM-PATH we denote the problem of determining, given G, s and t, whether G c...
It seems that the General Number Field Sieve (GNFS) became number one and then RSA stopped its factoring challenges and there have been no advances in factoring algorithms besides quantum computers. So are there faster algorithms after GNFS for classical computers? Note that the 1980s and 1990s saw a series of new fact...
This is taken from an old exam of my university that I am using to prepare myself for the coming exam: Given is a language $\text{Goto}_{17} \subseteq \text{Goto}$. This language includes exactly those $\text{Goto}$ programs in which no constant is ever greater than $17$. Show that every $\text{Goto}$ program can be si...
I need to implement piecewise linear functions (this is not homework, it is for my own personal project). However, I have been having difficulties to get it right. Below, I describe the characteristics of the function, operations, and what I have tried so far. Function: It is defined by linear segments. It may be disco...
I have shared the question above. My current algorithm does the calculation in O((n^4)*(2^n)). Can someone please help me out to solve this faster?
$$L=\left \{ a^nb^m|n\leq m\leq 2n \right \}$$ Is this even context free? I am asking because by looking at the condition, for an expression that holds:$n< m<2n$ can be written as : $a^nb^nb^c (c<n)$. Following this term(taken from geeks for geeks https://www.geeksforgeeks.org/check-if-the-language-is-context-free-or-n...
This question has two facets that are related. Is the general problem of protein folding really NP-hard? The hydrophobic-polar protein folding model (Ken Dill et al., 1985) stated the problem on a lattice (similar to self-avoiding walk): Simplification significantly reduces the computational effort in handling the mod...
Intuitively I think the answer is no since I don't think every certificate can be checked in polynomial time but I don't know how to give a formal proof. Is the statement true? Why or why not?
I want to show that $L_1 = \{\langle M\rangle \mid \emptyset \subseteq L(M)\}$ is decidable/undecidable - without rice theorem (just for the case that I can apply it). Every language contain the $\emptyset$ as a subset. So my guess is that the language is decidable. Therefore, let us assume that $L_1$ is decidable. Let...
It is not hard to see that SAT for a CNF formula with $n$ variables and a constant number of clauses can be solved in polynomial time. On the other hand, it is not hard to see that a CNF formula with $n$ variables and $O(n)$ clauses is enough for NP-hardness (consider for example the instances of SAT associated with th...
A convex polyhedron can be represented by a set of linear inequalities. If the inequalities involve $n$ variables, then the polyhedron can be $n$-dimensional, but it can also be of a smaller dimension - in case some of the inequalities in fact define equalities. As a simple example, the following inequalities: $$x_1 \g...
I'm studying for an upcoming exam and my book gives the following definition: Let $M$ be a Turing machine, then the accepted language $T(M)$ of $M$ is defined as $T(M) = \{x \in \Sigma^* \mid z_0 x \vdash^* \alpha z \beta; \alpha, \beta \in \Gamma^*; z \in E\}$. As a side note, $\vdash$ denotes the transition from one ...
Is QMA known to contain Co-NP? If not, would Co-NP being contained in QMA have any implications for other complexity classes. (e.g. Causing the polynomial heirachy to collapse.)
This is taken from an old exam of my university that I am using to prepare myself for the coming exam: Given is a language $\text{Goto}_{17}^c \subseteq \text{Goto}$. This language contains exactly those $\text{Goto}$ programs in which no constant is ever above $17$ nor any variable ever above $c$. $Goto$ here describe...
I am confused about calculating the PARTITION procedure's running time. PARTITION procedure is used in the Quicksort Algorithm to partition the array $A[p...r]$ I analyzed the PARTITION procedure provided in the book Introduction to Algorithms: PARTITION(A, p, r) 1. x= A[r] 2. i= p-1 3. for(j = p to r-1) 4. ...
in theoretical computer science I learned for every recursive enumerable language there would be an enumerator and a grammar. So since word problem and halting problem are recursively enumerable, I was wondering what kind of grammar and enumerator could this be. And let the Wordproblem be $ L = \{ \langle M, w \rangle...
I know that, removing left factoring is a simple task. And i understand following procedure: $S→aA | aB$ Becomes: $S→aS'$ $S'→A|B$ Yet I'm running into problems with this particular grammar: $S→AD|bbS|bScS|BS $ $A→aAbb | abb$ $B→aB|ba|b$ $D→cDd|cccd$ How to remove left factoring from it, I'm trying to convert it in...
Given a two rectangular binary matrices $A$ and $B$ with dimensions $c\times a$ and $c \times b$ respectively, does there exist an invertible binary matrix C with dimensions $c \times c$ such that the total number of 1 entries in $CA$ and $C^TB$ is below a target threshold $t$? Here we are working in $GF(2)$, where m...
Given a list of numbers $S$ where $0 < s_i < 100$, find the minimum sum group of numbers with a sum bigger than $X$. Each number can be used multiple times. Ex: for $S = [3,4.1], X = 10$ the solution is $[3, 3, 4.1]$ Is it a known problem? What will be the best way of solving it? For now, my best solution is to randoml...
In the programming language theory world, there are two important terminologies, i.e syntax, and semantics. I can understand these two terminologies: syntax is about sentence's structure (e.g. a valid sentence by some grammar) semantics is about sentence's meaning (e.g. operational semantics, denotational semantics, et...
I was living in a country where Internet wasn't that fast so the younger me had the following idea for compressing data Let say 2 parties want to send data to each other, we know that data can be represented by a number literally any data no matter the size can be just a giant number. So let say the 2 parties have this...
I was reading the section of data structures for disjoint sets from the text Introduction to Algorithms by Cormen et. al .I faced difficulty in understanding few steps in the proof of the lemma as given in the question title. Here we assume we follow union by rank and path compression heuristics. Before we move into ou...
Preface So this is a question that came from an idea for a game. This game is voxel-based, and I am interested in calculating structural integrity, with some blocks that break after a limit has been reached. I know Medieval Engineers and 7 Days to Die implemented something along these lines, though I would like to see ...
Is this problem algorithmically decidable? L1 and L2 are both regular languages with alphabet $\Sigma$. Does L1 = L2? I think that it is decidable because you can write regular expressions for each language and see if they are the same. But I'm not sure how to prove it since I see that you prove something is decidable ...
In many programming language string is a token. For example: token ::= '"' string | digit nat string ::= char string | '"' nat ::= digit nat | ϵ This is a LL(1) grammar for some programming language's t...
I'm still new to Data Structure and Algorithm and therefore I would like to ease my doubts. I'm required to find the Big-O running time of myMethod(): Static int doIt(int n) { for ←1 100 do -> 100 for ←1 do -> n x 100 ←1;← -> 1 while < do -> lg n...
Let's consider the edge weighted online matching problem. The Vertices arrive online and reveal all their current edges and edge-weights $w_e>0$. The goal is to maximize the matchings weight. An edge can only be added once and irrevocably to the matching. As so often, we consider basically consider the setting from KVV...
Here is my problem. Problem Given two words and a dictionary, find out whether the words are equivalent. Input: The dictionary, D (a set of words), and two words v and w from the dictionary. Output: A transformation of v into w by substitutions such that all intermediate words belong to D. If no transformation is possi...
Based on the order by asymptotic growth rate which is more efficient?
For example if I've this: if a == false then return true else if a == true and b == false return true else if a == true and b == true then return false can be simplified to if a == false || b == false then return true return false; Truth Table would look like this: F T = T F F = T T F = T T T = F I want to come up w...
I have received a problem to solve and I am not sure what algorithm to use. TLDR; Find the shortest path to get to every node in a undirected graph The problem states that one must visit every station in the shanghai metro in the shortest path possible. Interchange Stations ('edges') can be reused and you can start / ...
I am looking at this post: Jamie is walking along a number line that starts at point 0 and ends at point n. She can move either one step to the left or one step to the right of her current location , with the exception that she cannot move left from point 0 or right from point n. In other words, if Jamie is standing at...
I tried to decide wheter the given Language $ L = \{ \langle M \rangle | M \space is \space TM \space and \space \exists \space w´,w´´\in L(M):|w´´|-|w´| \space is \space prime \} $ is recursive or recursive enumerable. I tried to prove not recursive (undecidability) through Rice's theorem, since there exists $M_1, M...
Assume that we represent a complete d-ary tree in an array[1,...n] (this is a 1-based array of size n). The formula for indices of children of node no. i is given as: {(1-i)d+2, ... , min{n,(1-i)d+d+1}} I am not able to get the intuition to arrive at this formula. Can someone please help ?
I have to design an algorithm to parse an array of terms and conjunctions into a grouped boolean expression. I never studied computer science and don't usually need this for web development, but today is different and I'm stumped. I'm getting input like so: a == 1 and b == 2 or c == 3 and d == 4 which I must turn into...
I was reading the book by Jurafsky and this is written by the author on HMM Although in principle the forward-backward algorithm can do completely unsu- pervised learning of the A and B parameters, in practice the initial conditions are very important. For this reason the algorithm is often given extra information. Fo...
From my understanding, the EDF (Earliest Deadline First) rule is essentially an iterative "version" of the EDD (Earliest Due Date) rule, which allows for preemption. At every point in time, EDF looks at all the processes present and sorts them into the processes with the earliest deadlines first and the latest deadline...
I was studying automata theory and formal languages and came across this question: If a grammar $G$ is left and right regular, why $||L(G)|| \leq ||P||$ ? I've searched the theory but I am missing something. And I cant find the answer anywhere, so I am asking here. Definitions: $P$ = set of rules Right-regular rule: gr...
Let ||L|| be the sum of all lengths of words in L und N(L) the number of equivalence claesses for the Relation $\equiv_L$ from Myhill–Nerode theorem. Proof, which values d can have with $d:=||L||-N(L),d\in\mathbb{Z}$ Some conclusions I came up with so far: |L|| is infinite, when L is infinite. Then d is not defined. W...