instruction
stringlengths
35
29.1k
For k inputs, the complexity of naive algorithm is O(2^k). I understood this one. What is meant by "the size of the instance to be solved should be polynomial in k". Is it equivalent to the statement "The number of clauses in CNF of the boolean expression is polynomial in k"? What should be complexity of a hypothetical...
I have collection $U$ of sets, where each set is of size at most 95 (corresponding to each printable ASCII character). For example, $\{h,r,l,a\}$ is one set, and $U = \{\{h,r,l,a\}, \{l,e,d\}, \ldots\}$. The number of sets in $U$ is nearly a million. Also a set in $U$ will mostly contains 8-20 elements. I am looking fo...
How to prove if $B$, $\overline{B}\neq \varnothing$ , then for every recursive set $A$, $A \leq_m B$ ? it means every recursive set is mapping reducible to set $B\neq \aleph$. I really have no idea to prove this. UPDATE $A,B$ are sets, $A \leq_m B$ if there is a computable function $f$ such that $A = \{ x \in N | f(x) ...
I can't prove the correctness of the following algorithm by R. E. Tarjan amd U. Vishkin, as described on wikipedia: Given an undirected tree presented as a set of edges, the Euler tour representation (ETR) can be constructed in parallel as follows: We construct a symmetric list of directed edges: For each undirecte...
The integer feasibility problem is NP-complete: $Ax=b, x \geq 0, x \mbox{ integer}$ $A$ contains elements in $\mathbb{R}$ If we restrict this: $A$ contains only elements in: $\{1,0\}$ $\{1,0,-1\}$ $\mathbb{N}$ $\mathbb{Z}$ Does this change anything in term of hardness? Can all these problems be reduced to each other?...
I have a question related to representing numbers in base 2 with floating point. For example, if I have such a number $$0.000011 \cdot 2^3$$ then is its normalized form this? $$1.1\cdot 2^{-2}$$ Generally speaking about normalizing, normalizing with hidden bit, does it imply that the first number of mantissa should a...
How can I prove that a stable algorithm cannot solve an ill-conditioned problem with a precision greater than that of input values ? It seems obvious to me, since an ill-conditioned problem is that in which exact input values(D) are totally different from error valuesI(D') (judging by something), thus the exact soluti...
One sentence question Is there any algorithm able to prove (solve) a logic problem (first-order, propositional, pddl) by finite induction? Background I am researching Hierarchical planning solvers and I found the following problem. Let a problem climb a stairway. An agent is able to move up or down. For example, suppos...
I need to write a program that does the following: Take an input list of objects whose properties include latitude and longitude to, say, 5 decimal places Store them in a data structure once Provide a "nearby" lookup function that can efficiently return the N closest objects for a given lat/long Currently, I'm doing ...
I was asked this question in an interview. I was not able to find a better solution than $O(n)$ which is just going over the array and finding the sum. Can it be done any better? I am not really interested in the actual sum, I just want to know whether it's even or odd. Or how do I prove that it cannot be done better t...
[redirected from math.stackexchange.com] Let $U = \{u_{1}, u_{2}, \ldots, u_{n}\} \subset \mathbb{R}^{3}$ be the finite set of points on the unit sphere in $\mathbb{R}^{3}$: $||u_{i}||_{2} = 1$ Definition: Quadruple of points $(u_{i}, u_{j}, u_{k}, u_{l})$ is said to be positive if $$ \exists \alpha_{i j} > 0, \alpha_{...
how many BST exist with same postorder and inorder traversal? I know that in binary tree (Not BST), it is one. but i have a book from that said for BST it is CATALAN number. i become confused.
I think my problem can easier be explained via an example: Assume we have a dataset containing the images of 10 different mammals, let's say lion, elephant, cat, ... and horse. We have a 20-class image classification task where we want to detect whether an image belongs to lion-male or lion-female or cat-male or cat-fe...
Given n different numbers, I would like to find out whether there exists an algebraic expression using all the n numbers, with n−1 binary operators and unlimited number of parentheses, that evaluates to a certain number T. My idea is to make use of binary expression trees, construct all possible trees and then find the...
I've found the following algorithm for selection sort on the internet. program SelectionSort(input,output); var A : Array[1..80] of Integer; n, i, j, k, m, loc, temp : Integer; begin writeln('size of the array?'); read(n); for i := 1 to n do read(A[i]); for k := 1 to n - 1 do begin m := A[k]; ...
Introduction to Algorithms said that quicksort "works well even in virtual-memory environments," but didn't explain why. I've tried looking an Wikipedia and Stack Exchange, but found no reason why. Is it just because quicksort sorts in place?
I know that the equivalence of two context-free grammars is undecidable, but what about the equivalence of a regular grammar and a context-free grammar?
I'm literally so confused on how to even start this problem of proving that the given language is not Context Free. L = {a^i b^j c^k d^l | i = k and j = l} I know that we have to find cases where it contradicts the three conditions of the pumping lemma in all cases, but I'm not good in doing so. Thanks for the help!
I am currently working on the asymptotic analysis of Karatsuba algorithm and I have this line "return (X * B^ (2 * m)) + ((Z) * B ^ (m)) + (Y)" where X,Z,Y are some numbers, m is in fact floor(n/2), where n is the length of the input, and B is a base(could be 10, then we would have decimal numbers). I was wondering wh...
Physically based rendering form theory to implementation - http://www.amazon.ca/Physically-Based-Rendering-Theory-Implementation/dp/0123750792/ref=sr_1_1?s=books&ie=UTF8&qid=1425451050&sr=1-1&keywords=physically+based+rendering has all the information which is in Real time rendering - http://www.amazon.ca/Real-Time-Ren...
Assuming $P\neq NP$, is there a computational model in which OWFs cannot exist? What more should we include beyond non-determinism, randomness, quantum model to preclude existence of OWFs?
I've come across a programming question. I can't solve it but I can write the question in mathematical form as follow: Receive k equations,and for each equation receive 3 variables a, b, and c in the following form: ax + by + cz >= 0 This is an example input of k = 4: 1) 2x + 1y + 0z >= 0 2) 1x - 2y + 0z >= 0 3) 3x + ...
I was given a target function to design a neural network and train: $y = (x_1 \wedge x_2) \vee (x_3 \wedge x_4)$ The number of inputs and outputs seems obvious (4 and 1). And the training data can use a truth table. However, in order to train it as a multilayer artificial neural network, I need to choose the number of ...
I'm reading Lamport's "Time, Clocks, and the Ordering of Events in a Distributed System" and there's a detail that's bugging me. Lamport defines the "happened before" partial order, which I understand. Then he says that "Another way of viewing the definition is to say that a -> b means that it is possible for event a t...
PR is defined as "the complexity class of all primitive recursive functions" and also equivalently as "the set of all formal languages that can be decided by such a function". (wiki:http://en.wikipedia.org/wiki/PR_(complexity)) Unfortunately I fail to understand, why these two are equivalent?
This is a follow-up of another question here, and I hope it is not too philosophical. As Raphael pointed out in a comment on my previous question, I don't really get the definition of "computable", but according to some papers I read, the definition is also not really clear when it comes to models of computation weaker...
I've been trying to understand time complexity and space complexity by writing my own snippets of code and solving them. Can you see if I'm correct? for(int i=1; i<=n; i*=2) c = i+8; for(int j=n; j>0 ; j/=2) a[j] = 8; I think the time complexity is $O(log_2n)$ and the space complexity is $O(n)$. for(int i = 1; i<=n;i*...
I am interested in whether a graph (say, a complete graph) with one capacity negative (or many, but one should suffice) can be reconstructed as a graph with all non-negative capacities where the max flow between vertices of the original graph can be identified with max flows between vertices of the new graph. It is ok ...
So I've been interested in learning more about formal verification, and I've seen a lot of interesting things like ACSL and JML which are based on the concept of Hoare triples. My question is, that these seem to be a way to describe the behaviour of imperative programs via specification languages that are mostly functi...
We want to store a set S of distinct positive integers and support the following operations on S: Insert(a): insert integer a !∈ S into S. Delete(a): delete integer a ∈ S from S. FindNext(a, k), where a ∈ S and k is an integer: if S consists of some elements a1 < a2 < · · · < an, and a = ai (for some i, 1 ≤ i ≤ n), th...
Each time the camera generates a ray, the first task of the renderer is to determine which object, if any, that ray intersects first and where the intersection occurs. This intersection point is the visible point along the ray, and we will want to simulate the interaction of light with the object at this point. To find...
Say I have two simple graphs, $A$ and $B$ In $A$, I know: one node has 3 nodes at distance of 1, 4 nodes at distance 2, etc. one node has 4 nodes at distance of 1, 1 nodes at distance 2, etc. etc. In $B$, I know: one node has 3 nodes at distance of 1, 4 nodes at distance 2, etc. one node has 4 nodes at distance of ...
I thought I understood dependent typing (DT) properly, but the answer to this question: https://cstheory.stackexchange.com/questions/30651/why-was-there-a-need-for-martin-l%C3%B6f-to-create-intuitionistic-type-theory has had me thinking otherwise. After reading up on DT and trying to understand what they are, I'm tryin...
I'm having trouble determining the correct way (if there is one) to find the witnesses in any given big O problem. The example I'm struggling with: $2^x + 17$ is $O(3^x)$. I am expected to find two witnesses such that $2^x + 17 \leq C(3^x)$ whenever $x > k$. Unfortunately, my textbook isn't very clear on how to actual...
I was wondering what would be a time complexity of shifting a binary or a decimal number? For example: 0011, when I shift it left I get 0001. I was thinking that the time complexity is $\Theta(n)$, because we have to shift every number. I need it to calculate $m*{b^\frac{n}{2}}$, where $m$ is some number and $b$ might...
Can you pipeline a pure Von Neumann architecture based CPU or do you need seperate data and instruction caches for this? If you include seperate instruction and data caches (then it isn't a von neumann CPU anymore, it's a modified Harvard), how do you unify the data of these caches so that they get stored in a single m...
I am trying to understand how PCA works, and think I got most of it except... By calculating eigenvalues/vectors of the covariance matrix of the original dataset allows to find those dimensions where data is least correlated (lowest covariance). Sorting them based on eigenvalues is the method which allows the sorting o...
Edit: answerers keep finding (valid!) problems with my example. I'll try again. The older version is below the horizontal line. Thanks to Klaus below for pointing out the last problem. My question is how to unify skolemizations that have differing numbers of arguments. As he points out, there is rarely any need ...
This is a homework question, I'm wondering if anyone could help. Recall $RP$ is the set of languages recognized by randomized algorithms in polynomial time. The question is given an algorithm in $RP$ allowed to consult an oracle in $RP$, prove the "lowest complexity bound" for a set recognized by this algorithm. I do...
In The Algebra of Programming page 5, the authors defined structural recursion foldn (c, h) over natural numbers: f 0 = c f (n+1) = h (f n) They then went on to defin factorial as follows: fact = outr . foldn ((0, 1), f) outr (m, n) = n f (m, n) = (m + 1, (m + 1) * n) This doesn't seem right, first of all, foldn ...
The following is my own set-up code: Search_and_Sum(key, A,n) A[1..n] int sum = 0; for(int i=0; i<=n+n+1000; i++){ for(int j=A.length; j>=1; j/=2){ if(key==A[j]) break; else sum+=j; } } return sum; Well, I think the first loop has time complexity $O(n...
Consider the recursion tree: $T(p) = 3T(\frac{2p}{8}) + 2T(\frac{p}{8}) + O(p)$. I determined that there are at most $1 + log_{4}\ p$ levels, because the longest simple path from root to leaf is $p \rightarrow \frac{2p}{8} \rightarrow \frac{4p}{16} \rightarrow \frac{8p}{32} \rightarrow\ ...$. This means that the time c...
Studying for my qualifying exam, have a past exam here, which has the following question, verbatim: Give a proof of the Folklore statement: "sequential space is parallel time." In other words, the space used by a sequential algorithm for a problem $X$ can be equated (within Big Oh) to the time taken by a parallel alg...
I'm reading Neil Gunther's Practical Performance Analyst, and he provides that when there's one queue and one server, the residence time (total time spent per request) is: R = S + QS S is service time Q is number of customers ahead R is residence time Then he describes a case with a single queue and two servers and ...
Assume $f$ decides a language $A$ in $O(g(n))$ time, where $n$ is the length of the input string. How to write a recursive algorithm to decide $A^*$ (recursive)? Moreover, can an $O(n^2g(n))$ time algorithm be written to decide $A^*$ (dynamic programming)? Yes, the dynamic programming portion is a hw assignment. CLRS...
I am a little confused which of the two laws above i should use: Suppose I have a computer program that can be parallelized by 70%. 30% cannot be parallelized. Every single data (100% of data) will pass the parallelizable part and also pass the non-parallelizable part. I want to calculate how much more data i can proce...
In ray tracing if we are tracing a ray from camera to the object, then why there is need for light source as in this image and also rays are going towards the light source instead of outgoing from the light source? Recursive ray tracing associates an entire tree of rays with each image location. Image from: Physically...
I'm working on the following problem: Suppose that we're given a connected, undirected graph $G = (V, E)$ with edge weights $w_e$ and a subset of vertices $U \subset V$. We want to find the lightest spanning tree in which the nodes of $U$ are leaves (there may be other leaves as well). We want to do so in $O(|E|\log(|...
Here's the statement: Take a set of finite inputs from some alphabet. If for any two turing machines: All inputs in the set produce the same output for both machines In both machines, the following is true: every state transition (i.e. every row in the state table) occurs at least once for at least one of the inputs ...
I have studied the following recurrence. The ratio between f(n) and n^log_b(a) is log n so there is non polynomial difference but I have studied from book that it can be solved by master method. $T (n) = 2T (n/2) + n log n$ On the other hand ratio in $T (n) = 2T (n/2) + n /log n$ is $1/log n$ so this also has non...
Please let me know, if this goes here, if not, please point out where I should post this. Thanks in advance. So I require huge number of training data, mostly images. This is a pet project, only for learning. So how and where do I collect them, free of cost? Will it be suitable if I use a crawler and pull out images, t...
I have a set S (so no duplicates) of d-dimensional vectors of non-negative real numbers (or if you would prefer, floats). I say a vector u "covers" a vector v if, in every dimension 1..d, u[i] >= v[i]. So for d=3, (3,3,2) covers (2, 3, 1), but (3, 3, 1) doesn't cover (2, 2, 2). I am interested in finding a subset T of ...
So I'm reading "Search Through Systematic Set Enumeration" by Ron Rymon (currently available online for free. I'm having a problem with the notation in the following definition presented bellow: The Set-Enumeration (SE)-tree is a vehicle for representing and/or enumerating sets in a best-first fashion. The complete S...
Can anyone think of a way to use Huffman Encoding to improve the compression rate of Lempel-Ziv Encoding? My initial idea was to encode with higher probabilities given to shorter strings (i.e. the string "e" would have a higher probability than the string "ef"). Does anyone know of a good way?
I edited my question trying to make it as short and precise. I am developing a prototype of a facial recognition system for my Graduation Project. I use Eigenface and my main source is the document Turk and Pentland. It is available here: http://www.face-rec.org/algorithms/PCA/jcn.pdf. My doubts focus on step 4 and 5. ...
I am trying to solve the following problem: A set $S$ is self-reducible if the following holds: $x \in S$ iff $x = 1$(Base case) or (recursively) $l(x) \in S$ and $r(x) \in S$ where $\left|l(x)\right| < \left|x\right|$, $\left|r(x)\right| < |x|$, and $l$ and $r$ are both deterministic polynomial time computable functi...
How to solve this using the recursive tree method? I'm stuck with the $\max$. $$T(n) = T\left(\left\lceil \frac{n}{\max\,\{\sqrt{n},2\}}\right\rceil\right) + n\,.$$
I have the following problem: $x$ is the number of operations I have to perform. $O=\{o_1,o_2,\ldots o_n\}$ is the set of possible operations. I know beforehand the cost in terms of time and memory of every operation $o_i \in O$. I have a limited amount of memory and computation time, $M$ and $T$ respectively. What is ...
Given a directed graph $G = (V, E)$ and an edge $e \in E$, I'm trying to come up with an algorithm to construct the minimum induced subgraph $H$ of $G$ with the property that every circuit in $G$ that traverses $e$ is in also in $H$. As an example, suppose graph $G$ has vertices $V = \{1,2,3,4\}$ and edges $\{(1,2), (2...
Consider a boolean function $f:\{0,1\}^n\rightarrow\{0,1\}$. If $f$ satisfies $f(\bar{0})=0$ where $\bar{0}$ is vector of $0$, $f(x)=1$ with every $0/1$ vector of hamming weight $1$, then communication complexity of function is $\Omega(n)$. This is claim $4.23$ in Jukna's book. If $f$ satisfies $f(\bar{0})=0$ where $\b...
From page 29 of The algebra of programming : For any category C the opposite category $C^{op}$ is defined to have the same objects and arrows as C, but the source and target operators are interchanged and composition is defined by swapping arguments: $$ f \cdot g \text{ in } C^{op} = g \cdot f \text{ in } C. $$...
From page 31 of The algebra of programming : Next, consider the squaring functor $()^2: Fun \leftarrow Fun$ defined by $$ A^2 = \{(a, b) | a \in A, b \in B\} \\ f^2(a, b) = (f a, f b) $$ Functors are required to preserve identities and composition: $$ F(id_A) = id_{FA} \\ F(f \circ g) = Ff \circ Fg $$ The second ...
I'd like to begin the question by saying I'm a programmer, and I don't have a lot of background in complexity theory. One thing that I've noticed is that while many problems are NP-complete, when extended to optimization problems, some are far more difficult to approximate than others. A good example is TSP. Although a...
Suppose that there are a set of $n$ points $P = \{(x_1,y_1), \dots, (x_n,y_n)\}$ in 2D. Given two coordinates $(a,b)$ and a number $r \in \mathbb{R}$, is there an algorithm with $O(|Q| + \log n)$ running time that can find the point set $Q \subseteq P$ containing those points of $P$ that are inside the circle with cent...
Actually my question has two parts: 1) I wanted to know that whether Iterative Lengthening Search is used in combination with DFS or Uniform Cost Search? Actually, in Russell and Norvig book (on page 90), it is described as follow: It would seem worthwhile to develop an iterative analog to uniform-cost search, inherit...
I'm trying to create an algorithm in polynomial time, that detects wether or not a graph is in a language. The language specifies that a graph is only part of this language if it has a cycle on 40 vertices. (The cycle doesn't need to be induced.) Now, I'm considering the fact that there could be a huge number of vertic...
I am learning about neural networks and have a couple of things I don't understand. Firstly, in competitive learning I understand that only the neuron with the strongest output is reinforced. That is done in a manners imilar to: Δwi*j = I(j)*h(i) Where w* indicates the 'winning' neuron, j indicates the input we are co...
Consider the following problem: Suppose you have $k$ nephews and $d$ dollars in your pocket all of which you need to spend. Given a set of $n$ toys with different prices, find whether there exists $k$ gifts with total cost exactly $d$. If $k=2$, is it possible to have an algorithm that runs in $o(n^2)$? If not, how t...
I have been examining the NP = P problem and I am wondering, why is proving or disproving NP = P hard? For example, why wouldn't a proof such as the following be adequate? Suppose a million doors were in front of me and I had to discover which door had a red ball behind it. In order to verify the solution, one would ha...
$$ f_1(n) = n^2 $$ $$ f_2(n) = n^2 + 1000n $$ Are the following statements true or false? $$ f_1(n) = O (f_2(n)), $$ $$ f_2(n) = O (f_1(n)), $$ Based on what I know about big O notation, I think the first statement is true and the second false, however my answer sheet says they're both true. Is that correct?
I've read the Wikipedia article explaining the complexity analysis of the Karatsuba algorithm, but I'm not fully grasping it. I seem to have gotten about 75% of the way to the solution on my own, but lack the last 25% to fully understand why the complexity is $O(N^{\log3})$ where the log function is base $2$. I worked...
Given an unsorted array of size n, it's obvious that finding whether an element exists in the array takes O(n) time. If we let h = log n then it takes O(2^h) time. Notice that if the array is sorted, a binary search actually takes O(h) time (which is polynomial) but the binary search cannot apply to an unsorted array. ...
I've been studying constructive type theory (CTT) and one of the things that I'm not clear on is the proof part: Proving the correctness of a program in a form of a proof that's nothing but the program itself (Curry-Howard Correspondence) Most examples that I've seen in books (e.g., Type Theory and Functional Programm...
Now my knowledge of this comes through watching The Imitation Game, a glance of a wiki article, and a couple of computerphile videos, so forgive me if it's obvious. While watching the Imitation Game, I couldn't help but think that the Bombe that was being developed was just doing a naive search through all possible com...
The following grammar is given: \begin{align*} M &\rightarrow d M d \\ M &\rightarrow e M e \\ M &\rightarrow f M f \\ M &\rightarrow \varepsilon \end{align*} I've checked it with the LL(1) table and there are ambiguous cell entries. Now, I've tried to convert it to LL(1), but without success. Is this not possible for ...
I have a language, for example $\{a^m b^n c^n \mid m, n \in \mathbb{N}, m = 2n\}$ $\{a^l b^m \mid l, m \in \mathbb{N}, l=4^m\}$ How can I see at a glance whether the language is deterministic context-free, context-free or not context-free? I'm not willing to try to prove the language to be context-free. I just wa...
What does the language {a, b, c}* exactly mean?
Is the wall-follower algorithm a poly-time algorithm (for Perfect Mazes)? In particular, are there poly time algorithms for solving the Perfect Maze problems? A perfect maze has the following properties: no inaccessible areas and is simply connected. no closed loops one and only one path from any point to any other p...
Given pseudocode: X is an array function FUN(X) l = length(X) if l <= 1 then PRINT("Hello") return end if p = l / 3 FUN(X[1...p]) FUN(X[(l-p+1)...l]) end function I now want to get the reccurence of this pseudocode. At the moment I have $$T(n) = 2 \cdot T(\frac{n}{b})\cdot O(1)...
I have a language $\{a^m b a^n | m+n \equiv 1 mod 3\}$ $m+n$ can be 1, 4, 7, 10, 13, 16, 19, 22, ... $m+n$ is the number of all $a$'s in the word How can I build a DFA for this language?
A few days ago this appeared on HN http://www.patrickcraig.co.uk/other/compression.htm. This refers to a challenge from 2001 - where someone was offering a prize of \$5000 for any kind of reduction to the size of randomly generated data (the entrance cost would be \$100 and the contestant could choose the file-size). I...
I have a series of about 50 images, each separated by a small rotation and taken from the same camera. The images are feature-dense, and I can calculate a homography from image-to-image easily. My question is, is there any way to determine the rotation matrix and/or intrinsic camera calibration parameters given just t...
What I have is the following: A mapping $f : key \rightarrow set$ that works in constant time An inefficient mapping $g : \{key\} \rightarrow \cup_{k \in \{key\}} f(k)$ where this union is slow Is there a data structure that would make things faster? I could precalculate for every possible set of keys the wanted outp...
I know that the definition of RE class is: $\ RE = \left \{ L \subseteq \Sigma ^{*} | \text{Exists M which accepts L} \right \}$ Can someone explain in the same notation the definition of co-RE.
Is there a regular expression of star-height 1 (i.e. without two nested Kleene stars) for the following language : $a^*(bb^*aa^*ba^*)^*$ ?
I'm having a really tough time trying to comprehend proofs via closure and pumping lemma. None of the examples I can find are similar to the one's im looking to prove. Can anyone explain if I'm totally missing the mark here or is this valid? Question: Prove that $$ L = \{0^x 1^y 2^{x+y} \mid x \ge 0 \text{ and } y \g...
How can we prove a program in repeat until using Hoare Logic? I've found a rule like this: {P} S {R}, {R ^ ~B -> P}, {R ^ B -> Q} for {P} repeat S until B {Q} But I still can't find any explanatiom how I can use this rule For example in this question: {x > 0 ^ y > 0} z:=0; u:=x; REPEAT z:=z+y...
Let's say I have a space with obstacles and I'm trying to control a robot's movement while avoiding obstacles. I also have a start state and a goal state. I use a search algorithm to find the shortest path from the start state to the goal state (actually I really don't care if the path is optimal or not at this stage, ...
Given an un-rooted tree with N nodes, numbered from 1 to N. Each edge of the tree has a positive integer, associated with it. We need to calculate the number of unordered pairs (S, T) of tree's nodes such that the greatest common divisor of all the integers associated with the edges of the path between S and T is equal...
Just like the title says. I need to use a SAT solver on a series of CNF formulas but not only do I need an answer of the type satisfiable/unsatisfiable but also some subset of clauses whose conjunction is still unsatisfiable (the unsatisfiability core). I have read somewhere that it is possible to hack the code of som...
Yesterday I was reading about Computability and they mention the Halting Problem. It got stuck in mind all day until I remember that some weeks ago, when learning Java, the IDE (Netbeans) show me a warning saying that my code was going to result in an infinite loop. My question is, why can't this problem, be solved ...
Suppose that $f, g$ are functions from the positive integers to the positive reals. Under what circumstances will $\log f(n)=O(\log g(n))$ imply $f(n)=O(g(n))$? It's easy to see that this isn't always true: If $f(n)=3^n$ and $g(n)=2^n$ then we know that $3^n\notin O(2^n)$, but taking logs gives $\log3^n = n\log 3$ and...
Suppose the usual dynamic programming algorithm for the knapsack problem. If we swap the max with an addition, does the modified algorithm compute all the solutions with benefit $\leq W$? I described the problem very briefly but I think anyone familiar with these notion wouldn't find any difficulty understanding wha...
Suppose there is an array of nonzero integer values A[n], which has a Fenwick tree representation F[n]. The most simplistic way to delete A[index] and update the values accordingly in F[] would be to perform update(index, -A[index]), then set A[index]=0. However, I could imagine that after a few deletes, the tree would...
If I have the following pieces to a train set: (12) Curve (4) Straight Such as this train set. I'm looking for an algorithm (to which I can write a program) that creates/lists all permutations. It's not as simple as just creating a list , such as the following, where s=straight and c=curve, and creating all permutati...
I've got following definition: Function $f$ is a valid mapping of word $w$ to regular expression $R$, if any of following conditions is true: $R = w$ and $f$ is the identity or $R = \epsilon$ and $w = \epsilon$; $R = R_1 + R_2$ and $f$ is a valid mapping of $w$ to $R_1$ or $f$ is valid mapping of $w$ to $R_2$; $R = R_...
I know that device drivers are attached to device controllers, which have their own registers and some local buffer storage. I'm wondering if I can think of device drivers as little state machines -- i.e. do they read and write to memory, or not?
Lets assume that we have access to a oracle (machine that determines without details) for $L^*$, can we calculate $L$ from this machine? The cost of operation is measured by number of queries from oracle. Can any property of $L$ like being prefix free or regular help? What if the language be finite and instead of $L^*$...
In RAID 6, there is a parity scheme that allows 2 concurrent disk failures. This requires 2 ‘syndromes’, one of which is simply XOR, as used for RAID 5's only parity. In trying to find out whether RAID 6 can support 3 or more parities, it has been disputed that there even exist any other parity syndromes.     I don't u...
With the initial condition being $a_0$ = 3, and the relation being $a_n = 2a_{n - 1}$, what would the solution be? Any help would be greatly appreciated.