instruction
stringlengths
35
29.1k
Motivation: This question is motivated by my previous question . In that question, my statment of the uniqueness requirement is not interesting since it leads to easily computable function. I am interested in constructing uncomputable function from a simple combainatorial problem. We want to tile $m\times m$-square u...
What does a pseudo-polynomial algorithm tell us about the problem it solves? I don't see how running time improves if the algorithm is exponential in the input length and polynomial in the input value; so how do we explain this shift from exponential to polynomial?
I'm an autodidact who works best with a mix of theory and implementation examples. I'm having a hard time finding resources on implementing algorithms and data structures in Python (2.7-3.X preferably). I found a text ...mastering basic algorithms in the python language but I find it to be far too introductory and thu...
Assume you are given a bipartite graph $G = (U, V, E)$ and you are given an integer $n$. Assume also that for each $v \in V$, you are given two integers $v_{min}$ and $v_{max}$ (where $v_{min} \le v_{max}$). The problem is to find a subset $U'$ of $U$ of size $n$ such that for each $v \in V$, the number of edges coming...
The Halting Problem is defined as: $H_{TM} = \{ \langle M, w \rangle \mid \text{\(M\) halts on input \(w\)}\}$ I'm not sure what it means. Is $H_{TM}$ a collection of Turing Machines such that all of them accept/reject the word $w$? Is that a specific word? Or does that mean any word in their alphabet? Thanks
Given a language, how do you go about deciding if it's decidable or not? For example: Given a DFA $A_0$ and a TM $M_0$ $L_1 = \{ \langle M \rangle \, | \, M \mbox{ is a TM and }L(M) = L(A_0) \}$ $L_2 = \{ \langle A \rangle \, | \, A \mbox{ is a DFA and }L(A) = L(M_0) \}$ What's the intuition/process of figuring out if ...
For example, I know that the non-regular language $a^nb^n$ is in $AC^0$. I would like to know more examples like this.
I'm looking at my textbook here from Michael Sipser and he says that a nondeterministic Turing machine is a decider if all its computation branches halt on all inputs. I think I recall seeing somewhere what you'd call a nondeterministic Turing machine that halts on at least one branch for all inputs, but may loop on ot...
I am taking the Coursera class on compilers and in the lesson about lexers it is hinted that there is a time-space tradeoff between using non-deterministic finite automaton (NFA) and deterministic finite automaton (DFA) to parse regular expressions. If I understand correctly, the tradeoff is that a NFA is smaller, but ...
I am learning about automata and finite state machines. Consider the following automaton, that accepts the word 'ab', does not have to be infinite, just once: alphabet: 'a','b' states: 1,2, 3 (3 is the final state and 1 is the initial state) transitions: state 1, symbol a, state 2 state 2, symbol b, state 3 First part...
So I have the following pseudo-code: Function(n): for (i = 4 to n^2): for (j = 5 to floor(3ilog(i))): // Some math that executes in constant time So far, I know that to find this i will be calculating $\sum_{i=4}^{n^2}\sum_{j=5}^{3i \log_{2}i}C$ where $C$ is a constant, but I am completely lost as to how t...
Any string generated from a PRNG clearly has a very short description. You need the code for the random number generator, the seed, and then the number of times to iterate. So, it seems that all such strings have low KC complexity. If the above it true, then what is an example of a "complex" string, in the Kolmogorov...
Is it possible to have the following condition in a semidefinite programming as a constraint? $ M= \left[ {\begin{array}{cc} a & \sqrt{u} \\ \sqrt{u} & b \\ \end{array} } \right] \geq 0$ where $\geq 0$ means positive semidefinite.
I am reading on concurrent processes and algorithms which find infinite processes by searching the process graph recursively. Most of the material I have found is not for beginners. I am looking for references / algorithms that can help me understand: What are process graphs? How to search for infinite processes in t...
That is, can the running time of every algorithm $A$ be written as $O(f_A(n))$ and $\Omega(f_A(n))$, for the same function $f_A$?
I'm really trying to wrap my head around vectorization but I can't seem to understand it. I don't know if I don't understand how to vectorize, or if I don't understand the array notation that's being used. An example of a loop I'm working on with school is below: for (M=0; M< number_of_iterations/2; M++){ for (i=2; ...
Let us assume that $\mathsf{NP} \neq \mathsf{coNP}$. Consider the graph 3-colorability problem. Since $\mathsf{NP} \neq \mathsf{coNP}$ implies $\mathsf{P} \neq \mathsf{NP}$ and 3-coloribility is $\mathsf{NP}$-complete and its complement is $\mathsf{coNP}$-complete , we have: 3-coloribility is not in $\mathsf{P}$, i.e....
There is a well known definition of parsimonious reduction. The standard definition of parsimonious reduction is very intuitive. It simply means that the two problem have the same number of solutions, when on input of one of them we applied function $f$. We say there is a parsimonious reduction from #A to #B if there i...
Is there an algorithm which decides whether a regular tree grammar $G$ is ambiguous, i.e. there exists a tree $t\in L(G)$ which can be parsed by the grammar in more than one ways, using only leftmost derivations? Is there a proof available about the decidability, or a cite to a paper which proposes such an algorithm?
I am looking for a good survey/study of experimental results of heuristics for Knapsack problem (or implemented libraries in java/c++). Any help is appreciated!
I may have missed something in my classes - but with $A\leq_{P}B$... Does this show that, if $A\in \textbf{NP-Complete}$, that $B\in \textbf{NP}$ or $B\in \textbf{NP-Complete}$? Or maybe I got things backwards. If $A$ is polynomial-time-reducable to $B$, and $B$ is $\textbf{NP}$-complete, does that make $A$ $\textbf{NP...
Basically I am aware of three foundations for math Set theory Type theory Category theory So in what ways are programming languages and foundations of mathematics related? EDIT The original question was "Programming languages based on foundations of math" with the added paragarph of And implementations of theory 1. ...
I'm having a very hard time understanding what's what. $$L_{1}\leq_{p}L_{2}$$ If $L_2$ is stated to be in $\textbf{NP}$, is it necessarily true that $L_1$ is $\textbf{NP}$-Complete? I need to show the following for an assignment, but I'm having a dispute with a fellow student because he claims that I can't claim that $...
I have a question about how you would find a example of a non Turing-recognizable language from the symmetric difference of two Turing-recognizable languages. I believe this is possible, but I am having problems coming up with a example in my head. Does anyone have any hints, or ideas about how to think about this?
How do you say $\delta\colon Q \times \Sigma \to Q$ in English? Describing what $\times$" and $\to$ mean would also help.
I am asking for help to explain some crucial points of the central lemma and it's proof of famous paper NP is as easy as detecting unique solutions by L.Valiant and V.Vazirani. The proof can be found in the section 2. The proof of the paper. The idea of the lemma: lemma shows that there is a randomized polynomial - tim...
In terms of comparing data structures, is a relational database just a >1 dimensional array? I'm just asking because I don't know much about databases, but I know a bit about data structures. I am trying to make this clear in my mind.
Along the same thinking as this statement by Andrej Bauer in this answer The Haskell community has developed a number of techniques inspired by category theory, of which monads are best known but should not be confused with monads. What is the relation between functors in SML and functors in Category theory? Sinc...
The Halting problem is a natural undecidable language which is complete for the set of recursivly enumrable sets. I am interested in undecidable but not Turing-complete language such that we can not reduce the Halting problem to it. What is the most natural undecidable RE problem which is not Turing-complete?
Is every language with a finite number of strings regular? Is the language of all strings regular? I am new to this topic and got confused. Can any one please help me with this?
For regular languages $R, S$ and $T$, which of the following are true? $R \cup S = S \cup R$ $(R \cup S) \cdot T = RT \cup ST $ $R^* \cdot S^* = (R \cup S)^*$
Reading this question "Natural RE undecidable problems but not Turing-complete" the following language came to my mind: If $\Sigma(\cdot)$ is the busy beaver function (maximum attainable score among all halting 2-symbol n-state Turing machines of the above-described type, when started on a blank tape), define the funct...
In the book Introduction to Languages and the Theory of Computation, I'm reading section 2.6 on how to minimize the number of states in an FA. I'm having trouble understanding a notation defined as $L_q$. Here's what the book says: Suppose we have a finite automaton $M = (Q, \Sigma, q_0, A, \delta)$ accepting $L \subs...
It is known that $Parity \notin AC^0$ (nonuniform), but the proof is rather involved and combinatorial. Are there simpler, but weaker lower bounds, say for $NP \not \subseteq AC^0$ or $NEXP \not \subseteq AC^0$? For example, can nontrivial simplifications be obtained in the proof of $NEXP \not \subseteq ACC^0$ to deal ...
I have a simple problem of making a DFA which accepts all inputs starting with double letters (aa, bb) or ending with double letters (aa, bb), given $\Sigma =\{a, b\}$ is the alphabet set of the given language. I tried to solve it in a roundabout way by: Generating a regular expression Making its corresponding NFA Usi...
I have the following question on an assignment, and despite asking my prof, I can't get a grasp on it.. Let $L_1, L_2$ be languages in ${\sf NP}$. Using the definition of ${\sf NP}$ via relations and quantifiers (not the non-deterministic Turing machines) prove that the following language is in ${\sf NP}$: $L=\{ x | ...
I'm wondering this based on several places online that call $\sf NP=$ co-$\sf NP$ a major open problem... but I can't find any indication as to whether or not this is the same as $\sf P=NP$ problem...
I struggle with few definitions in knowledge representation and seek credible help to distinguish between them. I have been searching on wikipedia and many websites for the difference between ontologies and semantic networks (not to be confused with semantic web). While the wikipedia page on semantic network never refe...
I am interested if there exists a following version of the travelling salesman problem: INSTANCE: A finite set $C = \{1,2,\dots,k\}$ of cities, a positive integer distance $\delta(i,j)$ for each pair of cities, and two positive integers $d$ and $B$. QUESTION: Is there a tour that visits every city in $C$, includes exa...
Can someone help with this: $L=\{a^ib^j \mid i,j \ge 0 \text{ and } i \ne 2j\}$ I'm trying to write a grammar for this language? I don't know how to do this. I tried this: $S \rightarrow aaAb \mid aA \\ A \rightarrow aA \mid a$
I have as an assignment question to show that $QuadSat=\{\langle\phi\rangle\mid\phi$ is a satisfiable 3CNF formula with at least 4 satisfying assignments$\}$ is $\sf NP$-Complete. My solution is as follows, which is pretty much copied almost 100% from a textbook example with only an extra requirement for satisfiablity ...
This is a homework problem I have spent several hours on. A "hint" is given that we may use this fact: If $n,j,k \in \mathbb{N}$ satisfy $ n \geq 2$ and $1 \leq j+k \leq n$, then $n^2+j$ does not evenly divide $n^3+k$. I cannot find any way to apply this fact. It leads me to believe I should use the string $0^{p^2}1^{p...
Given a $0,1$ (binary) integer program of the form: $$ \begin{array}{lll} \text{min} & f(x) & \\ \text{s.t.} & A x = b \\ & x_i \ge 0 & \quad \forall i\\ & x_i \in \{0,1\} & \quad \forall i \end{array} $$ Note that the size of $A$ is not fixed in either dimension. I believe this problem has been shown to be hard to a...
Are there NP-complete problems which have proven subexponential-time algorithms? I am asking for the general case inputs, I am not talking about tractable special cases here. By sub-exponential, I mean an order of growth above polynomials, but less than exponential, for example $n^{\log n}$.
I am looking for an efficient algorithm to find streaming data median. Median is described as the numerical value separating the higher half of a sample, a population, or a probability distribution, from the lower half. We have stream of data in our system like 1, 10, -40, 20, 2, 6,.....Our task is find median of data...
In reading Uday Reddy's answer to What is the relation between functors in SML and Category theory? Uday states Category theory doesn't yet know how to deal with higher-order functions. Some day, it will. As I thought Category theory was able to serve as a foundation for math, then it should be possible to derive a...
I am concerned with the question of the asymptotic running time of the Ukkonen's algorithm, perhaps the most popular algorithm for constructing suffix trees in linear (?) time. Here is a citation from the book "Algorithms on strings, trees and sequences" by Dan Gusfield (section 6.5.1): "... the Aho-Corasick, Weiner, ...
I read about the time complexity for modular arithmetic in many books. There is one thing that I don't understand. I read in some books the following: For any $a \mod N$, $a$ has a multiplicative inverse modulo $N$ if and only if it is relatively prime to $N$. When this inverse exists, it can be found in time $O(n^3)$ ...
I have eye-tracking data on two subjects -- a teacher, and a student. It's in the form (x, y, time), so there is a series of these for each subject. What the teacher looks at influences what the student looks at. What method would I use to predict what the student is looking at, using only teacher data? Lets say I can ...
If $A^2$ is regular, does it follow that $A$ is regular? My attempt on a proof: Yes, for contradiction assume that $A$ is not regular. Then $A^2 = A \cdot A$. Since concatenation of two non-regular language is not regular $A^2$ cannot be regular. This contradicts our assumption. So $A$ is regular. So if $A^2$ is r...
Can someone help with this: $L=\{a^ib^j \mid i,j \ge 1 \text{ and } i \ne j \text{ and } i<2j\}$ I'm trying to write a grammar for this language? I tried this: $S \to S_1 \mid S_2 \\ S_1 \to aXb \\ X \to aXb \mid aaXb \mid aab \\ S_2 \to aYb \\ Y \to aYb \mid Yb \mid b \\ $ What do you think?
If I have an infinite language $L$ which fulfills the Pumping lemma for regular languages, does $L^*$ also fulfill the same conditions?
I need to determine if the following languages are regular / context free and to explain. Please help me with that. $$L_1 = \{ a^{i_{1}}b a^{i_{2}}b a^{i_{3}}b a^{i_{4}}b a^{i_{5}}b a^{i_{6}}b a^{i_{7}}b a^{i_{8}}b a^{i_{9}}b a^{i_{10}}b \mid i_1 > i_2 > i_3 > i_4 > i_5 > i_6 > i_7 > i_8 > i_9 > i_{10} ; i_1 < 100 \}$...
Can I use principles of set theory in order to solve the following question? For every $A,B \in \mathsf{co\text{-}RE}$ with $A \cap B = \emptyset$, there is a separating language $C$ with $A \subseteq C$ and $B \cap C = \emptyset$ so that $C$ is recursive.
I have read some complexity papers in which "for infinitely many input sizes" is used. What is the difference in the computational complexity context between "for infinitely many input sizes" and "for all input sizes"?
Between my textbook and various online sources (namely wikipedia), I'm very confused... can somebody clear up which words are synonymous and which mean different things? Many-to-one reduction Mapping reduction Turing reduction Cook reduction Karp reduction Polynomial-time many-to-one reduction Polynomial time turing r...
I am trying to find out why $(\log(n))^{99} = o(n^{\frac{1}{99}})$. I tried to find the limit as this fraction goes to zero. $$ \lim_{n \to \infty} \frac{ (\log(n))^{99} }{n^{\frac{1}{99}}} $$ But I'm not sure how I can reduce this expression.
In Corman, Introduction To Algorithms, 3rd edition, question 2-4 it asks to count the number of inversions in a list of numbers in $\theta( n \lg n )$ time. He uses a modified Merge Sort to accomplish this. However, there is something in his algorithm which seems redundant / unnecessary to me: MERGE-INVERSIONS(A, p, ...
We are given the following language B = {$<M,i>$ : M is a turing machine and $i \in \mathcal{N}$ and M accepts some string in atmost $i$ steps } Is language B decidable ? As per a hint from another fellow user, I decided to construct the following decider for B. Call it D. D = On input Enumerate all the strings in $...
Consider the following problem whose input instance is a simple graph $G$ and a natural integer $k$. Is there a set $S \subseteq V(G)$ such that $G - S$ is bipartite and $|S| \leq k$? I would like to show that this problem is $\rm{NP}$-complete by reducing either 3-SAT, $k$-CLIQUE, $k$-DOMINATING SET or $k$-VERTEX CO...
We know that at the end computation should be done by physical systems which follow laws of physics. I know there are some researches that study the phase transition phenomenon in physics and try to connect it with some properties in complexity theory (such as P and NP famous problem ). Just a quick review for example ...
When minimizing the full adder, I don't understand why $A(\bar{B}\bar{C} + BC)$ reduces to $A\overline{(B\oplus{C})}.$ $(\bar{B}\bar{C} + BC)\to (B\oplus{C})$ is partially decipherable, but why is $(B\oplus{C})$ inverted to $\overline{(B\oplus{C})}?$ Full adder simplification: $ \bar{A}\bar{B}C + \bar{A}B\bar{C} + A\b...
Following the article's notation, I write $\mathcal{F}$ for the category of presheaves on a (suitable) category $\mathbb{F}$, $TV$ for the presheaf of terms, $\delta$ for the context extension, and $\bullet$ for the product of the $\mathcal{F}$-monoid. In Abstract Syntax and Variable Binding [Fiore, Plotkin, Turi], the...
Given an $n \times n$ matrix $\mathbf{A}$. Let the inverse matrix of $\mathbf{A}$ be $\mathbf{A}^{-1}$ (that is, $\mathbf{A}\mathbf{A}^{-1} = \mathbf{I}$). Assume that one element in $\mathbf{A}$ is changed (let's say $a _{ij}$ to $a' _{ij}$). The objective is to find $\mathbf{A}^{-1}$ after this change. Is there a met...
Suppose I am using the Bucket-Sort algorithm, and on each bucket/list I sort with insertion sort (replace nextSort with insertion sort in the wikipedia pseudocode). In the worst case, this would imply that we would have $O(n^2)$ performance, because if every element was in one bucket, then we would have to use insertio...
I have an algorithm where the number of items in my set decrease by $\sigma/(1+\sigma)$ on each iteration until all items are exhausted. $$ \begin{align*} S_0 &= S \\ S_{k+1} &= S_k - S_k \frac{\sigma}{1+\sigma} \end{align*} $$ Here $\sigma$ is a small value. How can I find number of iterations? I know it is a geometri...
I am given the following problem in an Algorithms class: Assume that you are given an array A[1 . . . n] of distinct numbers. You are told that the sequence of numbers in the array is unimodal, in other words, there is an index i such that the sequence A[1 . . . i] is increasing (A[j] < A[j + 1] for 1 ≤ j < i), ...
Being a programmer I appreciate the errors given by a compiler for a programming language and come to rely on the compiler's error as a safety net. In learning category theory I would like to have some tool that also acted as a safety net letting me experiment with diagrams and pointing out my mistakes when I make one....
I am trying to analyze the running time of a bad implementation of generating the $n$th member of the fibonacci sequence (which requires generating the previous 2 values from the bottom up). Why does this algorithm have a time complexity of $\Omega(2^{\frac{n}{2}})$? Where does the exponent come from?
I'm developing software to run variations on a base process flow (see #1, below). A user specifies in a text file what steps in the process to modify. Because each step takes a long time to run, I'd like to minimize the amount of duplicate processing required. For example, if variations occur at step B, I could run ste...
I have a language for sensor networks (generates C code) and I want to define the formal semantics of it. The language has this form: {STATE name_state: EVERY time SELECT {variable [, variable] ...} [SENDIF send_condition] [CHANGEIF change_condition GOTO new_state]; } ... START IN initial_state; The initial state of...
Are all algorithms which have polynomial time complexity belong to P class ? And P class do not have any algorithm which does have not polynomial complexity ? Are all algorithms which have non polynomial complexity belong to NP or NP-Hard or both ? I am just trying to understand the basic relationship.
Are there any problems which can be solved by human brain in a very less time but a computer may take a lot of time or a computer could never solve it ?
I would like to find the height of a d-ary heap. Assuming you have an Array that starts indexing at $1$ we have the following: The parent of a node $i$ is given by: $\left\lfloor\frac{i+1}{d}\right\rfloor$ The $d$ children of a parent at node $i$ are given by: $di-d+1, di-d+2,\ldots di+1$ The height of a heap (which is...
Is there an explanation Christofides's Heuristic for solving TSP which does not simply state the algorithm and go ahead to prove the bound? To be specific: (Disclaimer : I am an engineer who knows very little about graph theory but need this for a logistics course) I understand that I first create an MST. So far, so g...
I am developing a chart and graph library and am having trouble developing an algorithm. **This is not a homework assignment for a student. See my open source project: https://github.com/eddieios/CoreChart The algorithm is to space the Y axis labels in a given coordinate graphical space. It should space the labels at ...
I want to know whether the 2-DNF problem is NP-complete or not? If it is NP-complete, can anyone provide a proof?
I am having trouble understanding the concept of AI. Is AI just a software that uses Probability, Linear Algebra and some advanced Mathematics to make independent decision ? Please give me some simple examples of AI.
I read on Wikipedia and in lecture notes that if a lossless data compression algorithm makes a message shorter, it must make another message longer. E.g. In this set of notes, it says: Consider, for example, the 8 possible 3 bit messages. If one is compressed to two bits, it is not hard to convince yourself that two...
In boolean circuit complexity, a circuit is just defined by a Directed Acyclic Graphs with designated input and output nodes, where the intermediate nodes compute a specific boolean function. A circuit is called a formula if the underlying graph is a tree. i.e., the fan-out of each node is $1$. Is it true that for a fo...
This question is not homework but it's related to material in a general course I take about programming languages, so I don't know whats the site policy about this In ML the following expression: fun f x y z = x (y , z) = x (z, y) ; Evaluates to this: val ('a, ''b) f = fn : ('a * 'a -> ''b) -> 'a -> 'a -> bool I unde...
Suppose I have a script (.vbs, for example) that is stored in a file. How does the code in the file get converted into machine instructions? What is between the vbs file and the processor?
In 2009 Doron has published a paper stating "Using 3000 hours of CPU time on a CRAY machine, we settle the notorious P vs. NP problem in the affirmative, by presenting a “polynomial” time algorithm for the NP-complete subset sum problem.". I've been looking for other people's opinions on this but I haven't found anythi...
So, I know that testing if a regular language $R$ is a subset of regular language $S$ is decidable, since we can convert them both to DFAs, compute $R \cap \bar{S}$, and then test if this language is empty. However, since this requires converting to DFAs, it's possible that the DFAs, and thus the testing algorithm, wil...
Many a times if the complexities are having constants such as 3n, we neglect this constant and say O(n) and not O(3n). I am unable to understand how can we neglect such three fold change? Some thing is varying 3 times more rapidly than other! Why do we neglect this fact?
We are going over the pumping lemma in class and we recently went over the following example: Let $$ L = \{ w \mid w \text{ has a different number of 0s and 1s} \} $$ Consider $$ s = 0^P1^\left(P+P!\right) $$ $ s $ can be divided into $ s = xyz $ Consider $$ y = 0^m; 0 \leq m \leq P $$ Let $ i = \frac{P!}{m} + 1 $ $...
I am trying to define a non terminal symbol in a LALR(1) grammar (with CUP parser). It is requested that the <code> token must appear exactly twice, while the <hour> token must appear at least once. In the end I came up with this definition: section ::= hour_l CODE SC hour_l CODE SC hour_l ; hour_l ::= /* e...
In compiler design, why should left recursion be eliminated in grammars? I am reading that it is because it can cause an infinite recursion, but is it not true for a right recursive grammar as well?
Operator - Generalized Symmetric Difference If you take binary xor and generalize it to other radices you can do so by the absolute value of the difference of each element in a radix vector. However this doesn't have the same properties as the binary symmetric differene. The reason is that in throwing away the "sign" o...
Some sorting algorithms like counting sort/insertion sort can work in $O(n)$ time while other algorithms such as quicksort require $O(n \log n)$ time. As I understand it, it's not always possible to use the $O(n)$ sorting algorithms. What are those cases when they can not be used?
Given an array of size n that holds ones and zeros I need to find an index of a 1 cell that has 0 to his right (in then next cell) there could be more than one pair in a given array, any one of them is fine. The array is not sorted, but we do know that the first element is 1 and the last element is 0. The search shoul...
For any language $L$ over $\{0,1\}^*$, a language $L'$ can be defined as $\{ a | ab \in L \text{ for some } b \in \{0,1\}^* \}$. If $L$ is decidable, is $L'$ decidable? I think that $L'$ should be decidable because we can create a Turing machine for $L'$ that will run the decider for $L$ on the input $w$ for $L'$, acce...
Based on the Wikipedia page for a formal system, will all programming languages be contained within the following rules? A finite set of of symbols. (This seems obvious since the computer is a discrete machine with finite memory and therefore a finite number of ways to express a symbol.) A grammar. A set of axioms. ...
I have some questions regarding tree search and graph search (Uninformed search) as explained in chapter 3 of the book : http://aima.cs.berkeley.edu/ As I see, the only difference between the two is that the graph search handles loops (avoids them). First question: Do both graph search and tree search build dynamic tre...
I read somewhere that, if $A\leq_p B$ and $B\leq_p A$, then it is said that $A\equiv_p B$. What exactly does this mean? Is it saying that both $A$ and $B$ are the exact same level of complexity?
I've just finished studying recursion at university. One thing that stood out for me however was that in both the lectures and in the practical we completed, all the tasks we were asked to do could be performed faster, and in less code, using iterative means. This was something the lecturer confirmed. Could somebody pl...
I was looking at the construction proof showing the equivalence of NFA and DFA from Sipser's text. It started by taking number of states of DFA as $\mathcal{P}(Q)$, where $\mathcal{P}(Q)$ is the set of subsets of $Q$. My doubt is when we construct DFA from NFA, all the subsets may not occur in that DFA. So how could w...
Functional programming employs persistent data structures and immutable objects. My question is why is it crucial to have such data structures here? I want to understand at a low level what would happen if the data structure is not persistent? Would the program crash more often?
Suppose we have a set $S = \{(a_1,b_1),...,(a_n,b_n)\}$ where $a_i < m$, $b_i = m-a_i$, $m \in \mathbb{Z}^{+}$, $m>2$ and $n$ is an even number greater than $3$. What is the most efficient algorithm to determine if it is possible to partition $S$ into two distinct subsets, $C$ and $D$, of equal size such that $\sum_{a ...
The sum divider game for $n$ starts with the set $M_0 = \{1,\dots,n\}$. Player A chooses a number $m_1$ from $M_0 \setminus \{1\}$ and B has to choose a divider $m_2$ of $m_1$ from $M_1 = M_0 \setminus \{m_1\}$. The players continue to choose a number $m_i$ from $M_{i-1} = M_{i-2} \setminus \{m_{i-1}\}$ alternatingly, ...