instruction
stringlengths
0
29.8k
⌀
null
I'm going to assume you are not given negative weighted edges, because this may not work if there are negative weights. Algorithm --------- For each of your edges, label them $1$ to $n$ Let $a_i$ weight A of edge number $i$ Let $b_i$ weight B of edge number $i$ Draw up this table |a_1 a_2 a_3 ...
null
I'm going to assume you are not given negative weighted edges, because this may not work if there are negative weights. Algorithm --------- For each of your edges, label them $1$ to $n$ Let $a_i$ weight A of edge number $i$ Let $b_i$ weight B of edge number $i$ Draw up this table |a_1 a_2 a_3 ...
Is { a^nb^m | n,m >=0, n!=m} is regular? i think it is but cant prove it ?
Is a^nb^m | n,m>=0 and not equal to each other is regular or not?
|regular-languages|
Is $L=\{ a^nb^m \mid n,m \ge 0, n\ne m\}$ a regular language? i think it is but can't prove it.
Is $\{a^nb^m | n,m\ge 0, n\ne m\}$ regular or not?
|formal-languages|regular-languages|closure-properties|
Suppose a **build** max-heap operation that runs bubble down over a heap tree, how does it's amortized cost equal to $O(n)$.
|data-structures|runtime-analysis|amortized-analysis|
null
First you should know that a language $L$ is regular if and only if its complement is regular. This is fairly simple to prove, given a deterministic finite automaton $M$, let $M^{-1}$ be the automaton where a state is accepting if and only if it is not accepting in $M$. Given this theorem you should be able to prov...
Using Ran G.'s comment which links to a very similar question: Suppose $L$ is regular. $M=a^*b^*$ is regular, too, so since regularity is closed by set difference, $M\backslash L=\{a^nb^n\}$ would be, too, which is the usual counterexample.
null
I assume that the operation **build** just turns an array into a heap by repairing the heap-property for every subtree bottom-up (let the operation for a single repair step called **heapify**). It is not so hard to see, that **heapify** takes $O(h)$ steps, where $h$ is the height of the subtree to repair. We set $k...
Using the formula from wikipedia for [Bloom filter false positives](http://en.wikipedia.org/wiki/Bloom_filter#Probability_of_false_positives), your proposal would have a false positive probability of about 14.8%. This assumes, among other things, that good hash functions are used. The formula is: (1 - [1 - (1/m)]*...
the maximum sucesss probability would be the minimum failed probability, and each machine should be at least 1, so we can reduce the original package B into B'= B-sum(c_i), and each machine's dp[i][0] should be initialized as fail probability (1 - r_i). so, we can find the dp state transition based on the modified k...
I have just started to learn Dynamic Programming, and so far I have studied the few basic concepts; longest common subsequent problem, edit distance problem and the knapsack problem. I have attempted to solve the following exercise that is related with this topic, and so far I think I have a way how to approach it , bu...
Dynamic programming: Knapsack with repetition, Find the number of redundant machines
|dynamic-programming|
I'm trying to find the most probable path (i.e. sequence of states) on an HMM using the Viterbi algorithm. However, I don't know the transition and emission matrices, which I need to estimate from the observations (data). To estimate these matrices, which algorithm should I use: the Baum-Welch algorithm or the Viter...
viterbi training vs baum-welch algorithm
|hidden-markov-models|
I take course on Computational Complexity. My problem is I don't understand **Relativization method**. I tried to find a bit of intuition in many textbooks, unfortunately, so far with no success. I will appreciate if someone could shed the light on this topic so that I will be able to continue by myself. Few following...
Intuition behind Relativization
|complexity-theory|np-complete|complexity-classes|relativization|np|
I'm trying to find the most probable path (i.e., sequence of states) on an hidden Markov model (HMM) using the Viterbi algorithm. However, I don't know the transition and emission matrices, which I need to estimate from the observations (data). To estimate these matrices, which algorithm should I use: the Baum-Welch...
Viterbi training vs. Baum-Welch algorithm
|algorithms|hidden-markov-models|
Is $L=\{ a^nb^m \mid n,m \ge 0, n\ne m\}$ a regular language? I think it is but can't prove it.
Is $\{a^nb^m \mid n,m\ge 0, n\ne m\}$ regular or not?
Suppose a **build** max-heap operation runs bubble down over a heap. How does its amortized cost equal $O(n)$?
How can I prove that a build max heap's amortized cost is $O(n)$?
I take course on Computational Complexity. My problem is I don't understand **Relativization method**. I tried to find a bit of intuition in many textbooks, unfortunately, so far with no success. I will appreciate if someone could shed the light on this topic so that I will be able to continue by myself. Few following...
Using the formula from wikipedia for [Bloom filter false positives](http://en.wikipedia.org/wiki/Bloom_filter#Probability_of_false_positives), your proposal would have a false positive probability of about 0.00726%. This assumes, among other things, that good hash functions are used. The formula is: (1 - [1 - (1/m...
You haven't really asked any question, but it seems like you don't know what $\rm{P}^A$ means and what $\rm{NP}^A$ means for a language $A$. The class $\rm{NP}^A$ is simply all languages that are decidable in "NP time", given a turing machine with $A$ as an oracle. This means a non-deterministic turing machine with a...
null
I take course on Computational Complexity. My problem is I don't understand **Relativization method**. I tried to find a bit of intuition in many textbooks, unfortunately, so far with no success. I will appreciate if someone could shed the light on this topic so that I will be able to continue by myself. Few following...
null
We can consider a <a href="http://en.wikipedia.org/wiki/Residue_number_system">Residue Number System (R.N.S.)</a> that has efficient operations for add, multiply, and compare between two numbers. **A more rigorous definition** We can suppose that we can perform the operations above between two non-negative intege...
What are the potential uses of a good R.N.S. system?
|algorithms|data-structures|
I'd like to know if there is a function $f$ from n-bit numbers to n-bit numbers that has the following characteristics: * $f$ should be bijective * Both $f$ and $f^{-1}$ should be calculateable pretty fast * $f$ should return a number that has no significant correlation to its input. The rationale is this: I...
Function that spreads input
|binary-trees|hash|binary-arithmetic|
The comment of Patrick87 correctly points out the flaw in my "proof" below, but I let it be as it were as it might be a good starting point. Together with his comment, it should be simple to prove that the language is not regular. First you should know that a language $L$ is regular if and only if its complement is...
null
I need to build a graph with number of vertexes N such that each vertex has degree at least k and the graph has the smallest diameter.
Constructing a graph of min-degree k with the smallest diameter possible
|graphs|
There is some evidence: [This paper][1] was presented at the ACM SIGPLAN History of Programming Languages Conference (HOPL II, April, 1993), co-authored by myself, Chuck, and Don Colburn, an erstwhile colleague now unfortunately deceased. It references, in turn, a very early work that Chuck wrote when Forth was in what...
http://arxiv.org/pdf/1111.6745.pdf This link contains what you want! good luck!
null
There is some evidence: [This paper][1] was presented at the ACM SIGPLAN History of Programming Languages Conference (HOPL II, April, 1993), co-authored by myself, Chuck, and Don Colburn, an erstwhile colleague now unfortunately deceased. It references, in turn, a very early work that Chuck wrote when Forth was in what...
How can you prove that multiple-cell-move instructions, for example (X, Y, 5R) and (X, Y, 17L), do not increase the power of a Turing Machine? Thanks
Prove multiple cell move instructions don't increase power of Turing Machines
|turing-machines|
null
I am designing a poker agent with different heuristics to decide whether to raise, fold or pass (in Texas holdem poker). I am planning to have 4 heuristics with the agent biased to one of them. The poker game will consist of 10 agents playing against each other. I have two heuristics now: 1. bluff - Agent wou...
'Texas Hold Em Poker' Agent Heuristics to help decide whether to fold or bet?
|artificial-intelligence|heuristics|
A quick answer: the control of every TM is finite, so given a TM $M$, the jumps in its transition table are finite. Suppose that it has the following jump transition: on state_x: if read symbol a -> write b, jump 3R, goto state_y then you can simulate it using 3 *single step* transitions : on state_x:...
This paper, [Fast Balanced Partitioning is Hard Even on Grids and Trees][1], by Andreas Emil Feldmann contains what you want! Good luck! > We will set up a general framework for a reduction from 3-PARTITION to > different graph classes. This will be achieved by identifying some > structural properties that a gra...
null
I take course on Computational Complexity. My problem is I don't understand **Relativization method**. I tried to find a bit of intuition in many textbooks, unfortunately, so far with no success. I will appreciate if someone could shed the light on this topic so that I will be able to continue by myself. Few following...
null
It seems that you are moving the blocks to get all the permutations. Then, checking each permutation to be present in DB; if yes then updating the number of moves if necessary. It would generate a tree. You are generating it in DFS style (by recursive calls). If you do it in BFS style, then you will always get the s...
On page 16 of this [algorithms book][1], it states: > For example, suppose we are choosing between two algorithms for a particular computational task. One takes $f_1(n) = n^2$ steps, while the other takes $f_2(n) = 2n + 20$ steps (Figure 0.2). He then goes on to say: > This superiority ... (of $f_2$ over $f_1$...
Confusion about big-O notation comparison of two functions
|complexity-theory|
The big-O denotes an **upper bound**. Since $O(n)\subset O(n^2) $, we have for any function $h$ $$h=O(n)\; \Rightarrow \; h= O(n^2).$$ In other words if $g_1(n)=n$ is an asymptotic upper bound for $f_2(n)$ then $g_2(n)=n^2$ is of course also an asymptotic upper bound for $f_2(n)$. The statement does not contradict ...
I thought associative array (i.e. map, or dictionary) and hashing table were the same concept, until I saw in Wikipedia that > For dictionaries with very small numbers of bindings, it may make > sense to implement the dictionary using an association list, a linked > list of bindings. ... > > The most frequent...
Relation and difference between associative array and hashing table?
|data-structures|
|asymptotics|landau-notation|
i would like to ask you some clarification on the following question: know that NP is a subset of IP and also coNP it is a subset of IP. So IP is a biggest class, but how much it is big? may i say that PSPACE is a subset of IP? or that they may intersect? Can you give me a easy clarification about it?
relation between interactive proof systems (IP), NP, coNP, PSPACE
|complexity-theory|np-complete|np-hard|interactive-proof-systems|
null
I thought associative array (i.e. map, or dictionary) and hashing table were the same concept, until I saw in [Wikipedia][1] that > For dictionaries with very small numbers of bindings, it may make > sense to implement the dictionary using an association list, a linked > list of bindings. ... > > The most fre...
From [Wikipedia][1] > A hash function is any algorithm or subroutine that maps **large data > sets of variable length**, called keys, to **smaller data sets of a > fixed length**. For example, a person's name, having a variable > length, could be hashed to a single **integer**. The values returned > by a hash fu...
Is the codomain/range of a hash function always $\mathbb{Z}$ or $\mathbb{N}$?
|hash|
No, hash function's range can be strings too. For example, MD5, SHA1, SHA2 and SHA3 are all widely known hash functions that give strings as output.
Abstract data type describes _what_ operations are available and what laws they obey. E.g. a dictionary allows you to store a value under a given key and to retrieve a value for a key, and promises that if you first store a value and then retrieve it with the same key, you will get the value you stored back. A stack ha...
It's quite commonly smaller than $\mathbb{N}$ or $\mathbb{Z}$, e.g. $\{-2^{31},...,2^{31}-1\}$ so as to fit in common number types.
Range of any hash function is a sub-set of natural numbers (this is how we think of it, exactly for access to the arrays, that could lie behind). The actual output of common hash-functions (MD5, SHAX...) is $n$ bits, where $n$ is $128$ for MD5 and $512$ for SHA2 with 80 rounds. These bits can then be interpreted as...
[IP = PSPACE][1] is a famous result (and indeed paper) by Adi Shamir in 1992. Furthermore, we clearly have NP $\subseteq$ PSPACE and coNP $\subseteq$ PSPACE, but we don't know how NP relates to coNP. There are several reasons to believe that determining the relationship between NP and coNP is difficult, some of...
If $N > k$ then the complete graph $K_N$ is regular with degree $N-1 \geq k$, and has the smallest possible diameter $1$. If $N \leq k$ then there the degrees are bounded by $N-1 < k$, and so no such graph exists.
null
While hash function's outputs (especially cryptographic hash function outputs) are frequently used as strings in software engineering, this is because there exists a bijection between the set of possible strings and subset of N or Z. Thus, MD5, SHA1, SHA2 and SHA3 are all widely known hash functions whose outputs are f...
null
The abstract data type (ADT) is essentially an API, and a concrete data structure provides an implementation of that API. For a given ADT, there are often several different choices of concrete data structures which support the query and update operations described by the ADT. Every concrete data structure for a given A...
There are N number of people and X amount of objects with different values. Each person will choose an object and will obtain that objects value. If multiple people choose the same object then the value of the object is shared among the people. For example, If there are 2 objects and 3 people, one of the objects will b...
Guessing the best choice to maximize returns