instruction
stringlengths
35
11.4k
I don't even know the right words to describe my problem, so I'll start with an example: "aabaa", "ccrcc", "ffaff" are equivalent to some extent, because they all have the same length and follow the same formula: twice one letter, once another letter and finally twice the first letter again. As I said, I lack even the ...
The PCP-Theorem states that $PCP(log(n), 1) = NP$. So can anyone explain, where $PCP(1,1)$ is located in relation to other classes? My thoughts: $P \subseteq PCP(1,1) \subseteq PCP(log(n)) = NP$ Is there some theorem like "$P \neq NP \implies PCP(1,1) ...$" What is the relation to the probabilistic classes like $BPP$ ...
There are $n$ points in a plane. The decision problem is to identify whether there exists a set $S$ of $k$ or less points from the $n$ points such that all $n$ points are at most $d$ distance from the selected set of points. I am trying to use the sensor coverage problem where the idea is to place sensors in the plan...
I'm trying to come up with loop invariant for the following program. k = a[0] m = 1 p = 1 while p < n: if a[p] == k: m += 1 p += 1 return m I belive this program returns the number equal to the number of occurences of element a[0] in my array "a". I thought maybe this is a good cadidate: |{i: 0 <= i <...
I've been told that if you understand a pipeline then you should be able to make it with any depth, but I can only do 4 stages and maybe 5 if the memory is not too slow. How can I learn how to make infinite pipelines?
All we know what is Deterministic Selection Algorithm: Line up elements in groups of five (this number $5$ is not important, it could be e.g. $7$ without changing the algorithm much). Call each group $S[i]$, with $i$ ranging from $1$ to $n/5$. Find the median of each group. (Call this $x[i]$). This takes $6$ comparis...
The book computers and Intractability mentions that Hamiltonian Path problem is not NP-complete in DAG. But if Hamiltonian Cycle is NP-complete in digraph then I can split a vertex and create two vertices ${s,t}$ which will make the graph acyclic and then ask for $s\rightarrow t$ hamiltonian path in that DAG. These tw...
I'm reading about the reservoir sampling technique called Algorithm R. The idea is we can take a sample of size $n$ from a population of size $N$ even when $N$ is unknown/too expensive to retrieve in $N$ time. I quote a sample implementation from wikipedia: (* S has items to sample, R will contain the result *) Reser...
I have a directed graph, $G = (V,E)$ (a dependency graph actually) and I want to find groups of nodes that can be considered as a single unit. I define a group as a set of nodes, $A$, such that any node outside of the group, $v \in A^c$, that has an edge to a node inside, must have an edge to every other member of the...
So, I'm given an arbitrary set of points $(p_1, p_2, p_3,\ldots)$ with an $x$ and $y$ coordinate. I have no information about the order they're given to me. I need to write code that will take in a point, $p_0$, and will find the point $(p_1, p_2, p_3\ldots)$ closet to $p_0$. This will of course be found my minimizing...
Let's say we have given $N$ intervals in the form $[x, y]$, both $x,y$ are integers , we want to find the number of integers covered by at least one interval of all $N$ intervals, (look in the example for better understand). The intervals may or may not intersect. Example: Let N = 3, and the intervals: $a_1 = [1, 5],...
I am looking to solve a variant of the traveling salesman problem with a certain set of constraints: the graph is not complete, i.e. some nodes are not connected to each other the weight of an edge between any pair of connected nodes is always 1 What is the best way to model and solve this problem? AFAIK the Concorde...
I am trying to implement a rubiks cube solving program,and I am trying to figure out which algorithm to use,so far I have only come up with using breadth first search to find a shortest path from the initial configuration node to the solution node. Each edge of the graph would be a 90 degree turn of a face of the rubik...
Is it possible to solve the FACT (integer factorization) problem in polynomial time if we know the polynomial Subset Sum algorithm? We assume that we know the algorithm solving the problem of Subset Sum with complexity: $n ^ 4 \cdot m ^ 4$ (for example), where $n$ is the number of elements in the set, and $m$ is the si...
Given this definition of weak bisimilarity: A configuration relation $\mathcal{R}$ is a weak bisimulation provided that whenever $P\ \mathcal{R}\ Q$ and $\alpha$ is $\mu$ or $\tau$ action then: $P \to^\alpha P'$ then $Q \Rightarrow^\widehat{\alpha} Q'$ for some $Q'$ s.t. $P'\ \mathcal{R}\ Q'$ $Q \to^\alpha Q'$ the...
Given 2 sets of Vectors in 3 dimensional space: A and B, what are the fastest algorithms to find the vector in set A furthest from any in set B?
It's been a long time since I've studied time complexity in school, but I've been tasked with finding the time complexity of an algorithm. Here is the algorithm in a pseudo-pseudocode (yes, two pseudos because I'm not good at creating pseudocode. Haha!). main() { list = methodImportFromCSV(...) // Don't care abou...
Reference: Page 4 of this document Given two polynomials $p(x)$ and $q(x)$ each of degree $n$ represented in coefficient form, it takes $\mathcal{\Theta}(n)$ time to evaluate given some input $x$. In the reference linked, in order to get product of these two polynomials, $c(x) = p(x)q(x)$, via brute force, we have to c...
Let's consider bit string as a program for some computational model. If after $k$ steps program represented by number $n$ halts and outputs bit string $s$, then complexity of s is (n+1)*k. For example complexity of result of program $101$ after 3 steps is (5 + 1)*3 = 18. Have this or similar complexity measure been stu...
is the string aabb in the language of this Turing machine ?? as upon reading aa it goes to the final state but upon b there is no transition defined so won't it result in a dead configuration?
I have to solve the following recurrence equation and I thought to solve it with case #3 of the master theorem. Can I do that? $$T(1) = c>0 $$ $$T(n) = 9T(n/3) + f(n)$$ $$f(n) = n^2\cdot lg^3 (n) + n^3 \cdot lg(n)$$ I think that $f(n) = \Omega(n^{log_ba})$ where $a=9, b=3$ so $n^{log_ba}=n^2$. Since $f(n) = n^3 lg(n)$...
I'm looking for a clever algorithm to generate a list of all possible graphs with maximum degree D and diameter at most P such that any two graphs of this list are not isomorphic. Any ideas ?
I want to add a points one by one into sorting tree. I have less then function to order them by angle from absciss: for points $\mathbf p_i = (x_i,y_i)$ and $\mathbf p_j = (x_j,y_j)$ it just sign of cross product of radius vectors to them: $$ f_<(\mathbf p_i, \mathbf p_j) \stackrel{def}{\equiv} (x_i \cdot y_j < x_j \cd...
A perfect natural number is that which is equal to the sum of it's divisors. For example 6 is perfect: 1+2+3=6 also 28 is perfect. Prove the following language is NP hard: L={< n> | n is a perfect natural number}. You can use the fact that if $$n=p_{1}^{m_{1}}p_{2}^{m_{2}} \cdot \cdot \cdot p_{k}^{m_{k}}$$ where $p_{...
I have a list. I have to find median of absolute difference of all pairs of array. Eg - A={1,2,10} Difference for all distinct pairs : 1-10=9 1-2=8 2-10=8 The new list is A'=[8,8,9] and the median is 8. Now I took all the pairs and made a list with difference of them and median is A'.length()/2th element i.e. 8. But...
I was reading a book about compiler design, then in the CFG section, they introduced the dangling-else problem. They offered to match the the else with the last if. I still don't see how this solves the problem. Can somebody give me an explanation? I searched before I put the question and none answered my question
I am working on the famous maximum independent set problem on a graph class called progressive $k$-partite graph, and it is defined as follows. Given a graph $G = (V_1, V_2, \dots, V_k, E)$, where $V_i\ |\ i \in \{1,2,\dots, k\}$ are the partitions and $E$ is the edge set. We assume that the vertices of each partition ...
Reading up on TTA CPU designs and the wikipedia article states that Some TTA implementations support conditional execution. The trick to make an TTA ISA Turing-complete with an unconditional MOV instruction escapes me. Can anyone explain how that would work? (or share some resources where it is explained)
How do I efficiently find the median of $k$ sorted arrays each of length $n$? Note that the total number of elements will be $nk$. I know it can be done in $O(nk \log k)$ time using merge technique. Is there a more efficient algorithm? For two arrays it can be done in $O(\log n)$ time, but I can't see how to apply that...
Lets say, we have a lot of lists (sequences of variable length) of some limited set of elements: [A, B, D, E, Q], [A, D], [A, C, E, F, G, H, Y, Z], [B, A, E, D, Z, Y], ... The problem is to get the single order, based on "how typical" some position is, eg, in our case it can be (coincidence with alphabetical order is ...
I couldn't figure out how to answer the following question: Suppose we want to transmit a string of 3 ASCII characters, and in order to be able to detect or correct the message, we append the sum of the chars at the end of the binary string. e.g.: encode("abc") == `110000111000101100011100100110` what is the distance...
Given L is regular, Prove/Disprove that the following language is regular or not. $EXP = \{w| w^{|w|} ∈L\}$
Consider the family of graphs of degree $6$ with vertex set $V_n=(a, b, c)$ for all $0\leq a, b, c \leq n-1$ with $(a,b,c)$ being connected to $(a-1, b, c),(a+1, b,c), (a, b-1, c), (a, b+1, c), (a,b,c-1), (a,b, c+1)$, with all operations modulo $n$. Show that this is not a family of expander graphs. I've been strug...
Assume a language with statements such as $x := e$, $\text{assume}(e)$, etc., and particularly a $\text{split}\ stmt_1 ... stmt_n$ statement, constructed from $n$ statements. Informally, the semantics of this statement is that each statement is evaluated separately, and if exactly one such evaluation terminates (i.e. i...
Would this proof work? Given a language $L$ that is Turing recognizable and a TM M that recognizes it and a homomorphism $f$, we build a NTM M' that recognizes $f(L)$, M' looks like this: On input $w$ : -Non-deterministicly feed words from $\Sigma^{*}$ to $f$ until you obtain w. -run M on $f^{-1}(w)$, if M accepts acc...
Let's say we have a directed graph with $n$ nodes and $m$ edges. For each node we want to make path that will start from this node, possibly traverse some other nodes and finish in the same node, in other words we want to make a cycle through each node. It is allowed to add edges that start and finish in the same node....
I'm analyzing a piece of code that has a recursive call inside a for loop such as: def fun(n): for i in range(0, 256): if ( n > 0): fun(n-8) (I only included a general piece of code not the actual version) It is my understanding that a recursive call gets assigned T(n) = T(n-8) but what happe...
Let MULT$=\{a\#b\#c| a,b,c \text{ binary natural numbers and } a\times b=c\}$ Prove that MULT $\in L$ How do I show that this language, MULT, is computable in Logarithmic space? Let us assume a#b#c is on the input tape, we now need away of multiplying a with b and checking if the product is c, while using only $log(n)$...
input: n-bit integer X output: list of prime factors and their multiplicity acc = X for i = 2 ... sqrt( X ) --count = 0 --while acc % i == 0 ------acc = acc / i ------count = count + 1 --if count > 0 ------print i (count) I know that for the worst case, a n-bit integer is 2^n maximum. So the time complexity for for i =...
I'm having trouble proving Hoare logic questions as I'm not sure of the process that is taken to prove them. I understand that they're rules such as assignment axiom, pre-condition strengthening, post-condition weakening etc... but how you actually apply these rules to the question is a little out of my understanding. ...
I was given the following homework assignment: Consider a set of $p$ points and $t$ triangles in the plane. The triangles are pairwise disjoint, that is, their edges do not intersect, no triangle lies in the interior of another, and no edge/vertex is part of more than one triangle. The points are in general position wi...
If I am implementing binary search using a recursive algorithm on an array it will be bounded by $O(\log(n))$. However, what will occur if the array is NOT passed by referenced and rather by value. This means that the recursive call will have to first copy the elements of the array (half the original items). Does th...
How many data addresses are specified in an ADD instruction in accumulator based architecture, stack based architecture, and in the most common register-based architecture? I'm not sure what I should look at - diagrams? Assembly code? Thank you for any help in advance!
I have written an algorithm for find all the pairs in a BST which have a given sum. def getPairsForSum(rootNode : Node, expectedSum : Int) : List[(Node,Node)] = { def check(node1 : Node, node2 : Node) : List[(Node,Node)] = { if (node1 == null || node2 == null) Nil else { val actualSum = node1.va...
Given a graph $G=(V,E)$, metric spaces $\delta:E\rightarrow \mathbb{Z}^{+}$ and $w:E\rightarrow \mathbb{Z}^{+}$, terminal vertices $s,t\in V$, do there exists $s\rightarrow t$ path $P=(V_{p},E_{p})$ such that $\sum_{e\in E_{p}} w(e) \leq W$ and $\sum_{e\in E_{p}} \delta(e) \leq K$, where $W,K\in Z^{+}$. This is Weight ...
In the paper "An introduction to algebraic effects and handlers" (Pretnar, Matija. Electronic Notes in Theoretical Computer Science 319 (2015): 19-35), handlers get a handler type that looks like a function type: $\underline{C} \Rightarrow \underline{D}$. These can be "applied" with the with h handle c syntax. What I'v...
In "Call-by-push-value: A subsuming paradigm." (Levy, Paul Blain. Springer, Dordrecht, 2003. 27-47) terms of the lambda calculus get split in to values and computations, with the slogan "A value is, a computation does". What I don't understand is: why are abstractions computations and not values? Intuitively a function...
Good evening everyone, I have a question that I am having a bit of trouble formulating properly and thus it is making it complicated to look up literature on the subject. What I am looking for is a name for a more general problem of the same nature, and I think it will have something to do with the title of this questi...
Let's say we are given this table of the relation Person(name, hobby) name hobby bob hockey alice basketball mary cricket mark basketball rick snowboarding andy hockey How would I use relational algebra to find the hobby that had only one person had. It should give me hobby cricket snowboarding My ATTE...
I am look for a tool with any or all of the following features: Regular Expresstion to NFA converter that represents transitions as Binary Decision Diagrams NFA to DFA converter NFA minimization NFA union/complement/intersection Can you recommend one?
I realize that we must do a minimum of $n - 1$ comparisons to find the median in a list of numbers, therefore the time complexity would be $\Omega(n)$. However, given a hypothetical scenario in a world where the median can be found in $\mathcal O(log(n))$ time, what would be the implications on the fastest sorting time...
I have a struct like this: struct UInt128 { UInt64 s1; UInt64 s2; } In this struct, s1 represents the highest 64-bits of my 128 bit integer, and s2 represents the lowest 64-bits of my 128 bit integer. I'm attempting to implement a method that produces the product of two UInt128's. My current thought process is...
Suppose all the spaces between the words(only small letter alphabets and no punctuation) in a file has been deleted and we need to reconstruct the file. There is a dictionary available which answers whether a word is valid or not in O(1). Brute force approach is to use backtracking i.e try out all the possibilities. Ta...
Is it more efficient to simulate Quantum Computer using a non-deterministic Turing machine? Would it be more efficient than simulation using a deterministic Turing machine or probabilistic Turing machine? I am not sure what are the relations between Turing Machine, Probabilistic TM, Non-deterministic TM and Quantum TM ...
In probability theory, the mixing time of a Markov chain is the time until the Markov chain is "close" to its steady state distribution. Lets fix some $\varepsilon\in (0,1]$ as our closeness parameter. Now suppose that we have a Markov Chain M with mixing time T, and suppose that we want to draw 10 independent sample...
When I search for Dijkstra's algorithm and hypergraphs, I don't get any results discussing it. The Wikipedia page regarding Dijkstra's algorithm doesn't mention hypergraphs and the one regarding hypergraphs doesn't mention Dijkstra's algorithm. When I search for shortest path algorithms for hypergraphs, I only get resu...
I know that it is as hard to find a solution to a SAT formula, as it is to decide it has a solution at all. See the answer to: Is finding a solution of a satisfiability problem harder than deciding satisfiability? Are there also families of formulas for which it is guaranteed that there is a solution, but it is hard to...
I see many algorithmic problems that always reduce to something a long the lines of: You have an integer array $h[1..n]\geq 0$, you need to find $i,j$ such that maximizes $(h[j]-h[i])(j-i)$ in $O(n)$ time. Obviously the $O(n^2)$ time solution is to consider all pairs, however, is there any way we can maximize the expr...
In Hoare logic, there's a thing called a Hoare triple, e.g.$$ \begin{array}{ccccc} \{x = 2\} & & x := x+1 & & \{x = 3\} \end{array}. $$ What does '$x :=$' mean?
Although I am new to the computer vision domain, I am tasked with automating handwritten text recognition from bank cheques. I first did some preprocessing(blurring and binarization) and then dilated it so that I could segment the words. But since the words are handwritten (cursive and unconstrained), the segmentation ...
Given a decidable problem, how would I go about proofing that the problem and the complement of the problem have to be semi-decidable?
Which one has a higher order time complexity: $n ^ 3$ $3 ^ {\log n}$ I know that an exponential time order is higher than polynomials. However, it uses a logarithmic power which is low for a large n, while n^3 or more could remain still high, not?
Consider the following formula: $T(n) = n + \sum_{k=1}^{n-1} [T(n-k) + T(k)], T(1) = 1$ What is the order of T?
I know that the time complexity of quick sort in the worst case is $\Theta(n^2)$ and in the average case is $\Theta(n \log n)$. Can it be $\Theta(n\sqrt n)$ for certain inputs?
type checking I was preparing examples of type checking in simply typed $\lambda$-calculus. I wanted to explain it to my audience in the way of implementation. And I found a bit tricky point in the typing rule of application, which is as follows. $$ \frac {\Gamma \vdash t_1:T_{11}\rightarrow T_{12} \quad \Gamma \vd...
I am wondering what the time complexity of finding the most appropriate exception handler for dispatching zero-cost exceptions is. For zero-cost (this refers to execution under the assumption that no exceptoins occur) exception dispatching, the compiler stores a big table of all possible exceptions. An entry consists o...
How to find a recurrence relation for $F(n)$ the number of ways to make n cents change using only pennies (4 cents), nickels(5cents), and dimes(10cents) and ordering matters. There are three exclusive case here Start with pennies then new subproblem is $F(n-4)$ Start with nickels then new subproblem is $F(n-5)$ Star...
I am aware that $MA \subseteq ZPP^{NP} \subseteq \Sigma_2^{P}\cap \Pi_{2}^{P}$ and also $NP^{BPP} \subseteq MA \subseteq AM \subseteq \Pi_{2}^{P}$. My question is: In this whole thing, where does $P^{NP}$ lie? (Obviously, $P^{NP} \subseteq ZPP^{NP}$) But, what about the relationship between $MA$ and $P^{NP}$? Which is ...
I am trying to determine which functions are not learnable without a bias when building a perceptron. The set of functions I need to evaluate is {NOT, OR, AND}. Could someone help interpret these results? AND FUNCTION https://i.stack.imgur.com/5sbuj.jpg OR FUNCTION I get a divide by 0 error in my script. NOT FUNCTION...
Working on an optimization problem formulated using the well known assignment problem. My decision variable is defined as follows : $$\alpha _{x}^{r,u} = 1\begin{cases} & \text{ 1 if } \mathbf{VM}\: \mathbf{u}\; of\; request \: \boldsymbol{r}\; is\; assigned\; to\; server\; \mathbf{x}\\ & \text{ 0 } otherwise \end{...
I'm struggling to analyze the runtime of this algorithm mainly because it depends on two parameters - the length of the input n, and also the bit size of individual n (bitnum). Most documentation I can find solve recursion based on n solely. The algorithm is: def sortB(seq,bitnum): # length of seq n = len(seq) ...
In the exercise I have a 32 bit processor with a 2-way set associative cache. I have 32 bit addresses: 31-14 tag, 13-5 index, 4-0 offset. Calculate: 1) Cache line size in number of words (1 word = 4 bytes) 2) Total cache size in bits In the presence of the following sequence of accesses in memory, considering the initi...
The cost of computing a trivial hash function is effectively zero, so the time complexity is $\mathcal{O}(1)$; however, if I assign $n$ variables using the hash function, is the complexity $\mathcal{O}(n)$. For example, the pseudo code would look like this: for i=1 to n var[i] = hash[data[i]]; end The only operati...
I've been given the following task and have tried a few things, but none seem to result in what is required. $L = \{ww \mid w \in \{a,b\}^*\}$ What Chomsky-Type is $L$? Provide a grammar fulfilling that Type. It can't be context-free, since that wouldn't allow us to force that we write each symbol twice at the right pl...
Given a connected graph G, what is the complexity of the problem to determine if a spanning tree with a number of leaves less or equal to k exists inside G? I don't really know how to determine it and how to reach a proper solution to this.
Do unconditional branches, such as jump/goto instructions cause control hazards? If so, why? I am wondering because if unconditional branches did cause control hazards, that is like saying if A were the jump foo instruction and another instruction B was the first one under foo:, B would have a control dependency on A. ...
Let $S \subset \mathbf{R}^3$ be a set of points in 3D and let $O=(x_0,y_0,z_0)$ be the origin/point of reference. We consider a convex polytope $P$ good / interior if: $P$ is wholly contained within the interior of the convex hull of $S$: $P \subsetneq \text{convexhull}(S)$. $O$ is contained within the interior of $...
I am trying to think of how to optimize the following problem: Let $S = \{1,2,...,N\}$. How many ways can $S$ be partitioned into non-empty subsets $P_1$ and $P_2$ such that $sum(P_1) = sum(P_2)$? I have implemented an algorithm that checks all partitions of $S$ into 2 subsets $P_1$ and $P_2$, but I am wondering if th...
Give a decimal number, such as 123. Need to figure out all smaller numbers lesser than 123 made up by 1 and 0 composed of decimal numbers such as 111, 110, 101, 100, 11, 10, 1, 0. I am thinking of below recursive solution: a. If the first number is 1 then we can append 0 or 1 to it. Vice versa is true for 0 if it is th...
$FOLL$ or $FO (\log \log n)$ is a complexity class of all problems solvable by uniform poly-size circuit families of unbounded fan-in and depth $O(\log \log n)$. $AC^2$ is a complexity class of all problems recognized by boolean circuits with depth $O(\log ^{2}n)$ and polynomial number of unlimited fan in AND and OR ga...
Some background on my question: I have done some research into March Tests that are essentially access patterns for DRAM. One example of these march tests in the MATS+ algorithm shown below with (I think) O(n) complexity: MATS+: {⇕ (w0); ⇑(r0, w1); ⇓(r1)} Steps for algorithm: 1) Write a 0 in either up or down addressin...
I have heard that the quickhull algorithm can be modified if the size of the convex hull (the number of points it consists of) is known beforehand, in which case it will run in linear time. What modifications are required in order to decrease the time complexity of the convex hull algorithm?
I am studying Nested Monte Carlo Algorithm addressing the problem of guiding the search toward better states when there is no available heuristic. It uses nested levels of random games in order to guide the search. It consists in two functions : nested(position, level) and sample(position) The basic sample func...
Looking at some Generating functions of a series, I have conjectured - If $G(x) \ =\ \frac{1}{1-x^{t_1}-x^{t_2}-...-x^{t_n}}$, then the recurrence equation of the the series is - $a_n = a_{n-t_1}+a_{n-t_2}+...+a_{n-t_n}$ How can I prove or disprove this?
Suppose that $k < \sqrt n$, what is the time complexity to find the $k_{th}$ smallest number in a min-heap? I thought that we can remove the root element for k times and each time we apply heapify? So it should be $O(k \log n)$ but the answer is $O (k \log k)$. What did I do wrong?
There is a powerful simulation of Turing machine. At the input it takes problems of class P. At the output it gives solution for the problem. So, is it easier (in complexity theory) to test the correctness solution of the given problem than to solve this problem? If checking the solution is really easier than solving t...
I know that monotone 3SAT is NPComplete. Also, 1 in 3SAT is NPComplete. I think both conditions together also leave the problem NP Complete (need confirmation). If possible can someone please help with the smallest non trivial problem of this form that is unsatisfiable. Would be grateful.
I read everywhere that $N$ qubits correspond to $2^N$ bits. Let's start with 1 qubit, which is commonly represented by $\alpha |0\rangle + \beta |1\rangle$ where alpha and beta are complex numbers. This looks to me like infinite bits. How do they choose alpha and beta so that it becomes 2 bits? Edit: Why is it commonly...
Given a 2d array of pixel values, is it possible to iterate over just the pixels in a circle in a way that is less costly than simply iterating over a square and checking if a value is within the circle? I need to get the values of pixels within a circle given center coordinates and the radius. Ideally I would ONLY ite...
I want to determine the complexity of these two problems (with a given k): 1) Determine if the graph G has a cycle of length less or equal than k; 2) Determine if the graph G has a cycle of length equal or more than k. For the first problem, I think it is NP-complete because it is NP (but why?) and because we can reduc...
I have a question regarding DFA: Design a DFA M with alphabet $\sum = \ {\{0,1,2,R}\}$ where the states remember actual sums of the number, except that the sum is reset to 0 whenever the symbol $R$ appears. Show diagrammatically how this DFA can be constructed. What is the problem with this DFA? One thing I do understa...
I work part time at UPS. Part of my job consists of taking boxes from in front of me, determining if the correct cage (1 of 6 moving cages) is behind me (true about 50% of the time), and then putting the box down either in the cage or back in front of me. There can be 6-20 boxes in front of me at any given time dependi...
The title puzzle has a setup of. Www_bbb where there are always 3 w's And 3 b's and 1_ . The rules of the puzzle are to get all w's on the right side of all b's where location of _ does not matter, to do the puzzle you have 6 possible moves. The move are 1, take the closest w or b to the left and move it to the rig...
There is a great divide in Haskell between pure and monadic algorithms. While the latter are indistinguishable from their usual imperative counterparts, the former can get much more magical. What this means is that some pure higher order functions do not admit translation from pure to monadic arguments, or from monadic...
I want to create a program that makes problems that people can solve but computers would struggle with. I've read that human language is very difficult and CAPTCHA looks pretty promising. Basically I want to make puzzles, riddles, and codes that a person could figure out with some effort but that cannot be automated. A...
Show a counter-example to disprove the following statement: If $R1$ and $R2$ are two regular expressions, then $L((R1 \cup R2)^*) = L(R1^* \cup R2^*)$.
I have just been reading through a SO post which proves that the Halting Problem is NP-Hard. Whilst this is an easily followed proof, one slight slight aspect of it has left me scratching my head: it says that "This pairing can be done in polynomial time, because the Turing machine has only constant size." So their j...
Question : What is the definition of $\mathcal{Mod} P$ counting complexity class? I am not getting anything relevant about this complexity class on Google search. If it is available on Wikipedia, please share a link. $\mathcal{Mod} P$: A set $L$ is in the class $\mathcal{Mod} P$ if there exist functions $f \in \#\math...
In the bin packing problem, we are given a set of items I={a1,...,an}, each item with weight w_a1,...,w_an, and a set of n bins with B={b1,..., bn} all bins with capacity C. I want to restrict the weights of the items to be polynomial in n. Is the problem still being NP-hard (restricting the weight of the items)? Any i...
Consider the highlighted columns in the following table: Starting with 100,000 newborns, $l_{x+2}$ denotes the number of individuals in the sample still alive at age $x+2$. If we consider Makeham's law of mortality, defined by the function $$ S_0(x) = \exp \left( -Ax - \frac{Bc^x - 1}{\log (c)} \right) $$ we find that...