Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I need to prove that for every k, there's a DFA M with k+2 states, so in every automat M' who accepts the language reverse(L(M)) there are at least 2^k states.
Help would be really appreciated.
Thanks :)
Assuming that the alphabet set contains at least two elements, let it be {0,1}.
Next, let M be the automata accepting the language L defined as:
All the strings which k-th position is 1
defined as:
M = {Q,{0,1},q0,{qk+1},δ}, where
Q={q0,q1,...,qk,qF}
δ(qi,a) = qi+1, for a in {0,1} and i=0,1,...,k-2
δ(qk-1,0) = qF,
δ(qk-1,1) = qk,
δ(qF,a) = qF, for a in {0,1}
Note that M has exactly k+2 states, and that it accepts the language L.
Now, note that the language reverse(L(M)) can be translated as:
All the strings which k-th position from the end is 1
To recognize that language, note that we need to remember the last k symbols, because we don't know when the string will end. We know that there are at least 2k possible strings of length k (since the alphabet size is at least 2).
So using a DFA, we need at least 2k states, each to represent one possible string of length k. ▢
Author's note:
The idea of this proof is to find a language which is "easy" to be recognized in normal way, but "difficult" when is read backward. Through experience, I remember that fixing the k-th position from the beginning is "easy", while k-th position from the end is "difficult", hence my answer.
Related
Let L be any regular language and a ∈ Σ. How to show that the language L'={uav | uv ∈ L} is regular too?
Wikipedia says a way to proove it is to lead it back to a regular language but I don't understand how to do that in this case. Hope somebody can help.
There are lots of ways to show this. I think an argument whereby we construct a DFA is particularly easy to visualize.
Imagine a DFA for your language L. Let's call it M. Imagine it sprawled out in diagram form on a table. Now, imagine making a copy of M and spreading it out next to M on the table. Call it M'.
Now - from M, add a new transition from state q of M to the corresponding state q' of M'. The transition is on the symbol a.
Now, consider the aggregate machine whose start state is the start state of M and whose accepting states are the accepting states of M'. This machine starts out accepting strings in L, then accepts an a somewhere in the middle, and then continues accepting strings in L from where it left off. This is the language we were going for and we have defined a perfectly reasonable NFA for it. Since any language accepted by an NFA is regular, our language is regular.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
An electric current, I, in amps, is given by
I=cos(wt)+√(8)sin(wt),
where w≠0 is a constant. What are the maximum and minimum values of I?
I have tried finding the derivative, but after that, I do not know how to solve for 0 because of the constant w.
Well David,you can convert this function into one trigonometric function by multiplying and dividing it by
√(1^2 + 8) i.e, 3. So your function becomes like this
I = 3*(1/3 cos(wt) + √8/3 sin(wt))
= 3* sin(wt + atan(1/√8))
Now, you can easily say its maximum value is
I = 3 amp
and minimum value is
I = 0 amp.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
Can anyone help me to understand that Is 2^(n^2 )=Θ(2^(n^3 )) ? it will be great if also provide the proof for this. As per my view this does not need to be equal.
The given assumption is not true:
First of all, 2^(n^2) is a function and Theta(2^(n^3)) is a set of functions, so it would be correct to say that 2^(n^2) ∈ Theta(2^(n^3)). The = is just a common abuse of notation, but it actually means ∈. To find out whether that statement is true, solve the following limit:
lim (n->infinity) of (2^(n^2)) / (2^(n^3))
If the result is 0 or infinite then the function does not belong to that particular Theta class. If it is some other value, it does belong to that class.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have got a too large binary value.
value1 : 2 ^ 300,000.
value2 : 2 ^ 300,000.
I'd like to do 'and calculation' of value1 and value2.
First of all, how to store a value1 and value2? (int, float, double... ???)
int value1 = 2 ^ 300000;
Is this correct?
Does this way completly store a value?
context for using)
I have two arrays which has 300,000 elements.
eg) array1 # [# "apple", # "banana", # "iphone", # "TV", # "clock" .... <= it has 300, 000.
array2 # [# "fruit", # "fruit", # "electric", # "electric", # "electric" ....] <= also has 300,000.
display prefered thing to binary : 1,1,0,0,1 ...
display prefered kind to binary : 1,1,0,0,0 ...
result of calculating 'and' of array1 & array2 : 1,1,0,0,0 ...
I like "apple" and "banana" of fruit.
Reason of using binary calculating are expected to be faster than other way.
The first thing is that you are not using Objective-C classes, but Plain Old Datatype, a.k.a. POD.
That large value far exceeds the limit of integers, even 64-bit unsigned ints. I am not a math wiz, so I'm not sure if that will fit in a double but that doesn't matter because with floating-point, you loses precision. (Link to WolframAlpha for the exact value that definitely won't fit.)
What you want is probably NSDecimalNumber which provide up to 38 digit precision, that's what's built into the library, if you need further precision, you can write your own class, or check out libraries like GMP.
There's a good question and answer about NSDecimalNumber here.
UPDATE: As Craig mentioned in the comment, you may want to roll your own class to speed up the calculation. Libraries like GMP are general purpose, and will do the calculation in a way that's so safe that it sometimes are wasting your time as the calculation you want to do can be simplified.
First of all the ^ operator is not a power operator, but a bitwise XOR.
So 2 ^ 300000 actually produces 300002.
Secondly you can use NSDecimalNumber, a subclass of NSNumber, which according to the documentation
provides an object-oriented wrapper for doing base-10 arithmetic. An instance can represent any number that can be expressed as mantissa x 10^exponent where mantissa is a decimal integer up to 38 digits long, and exponent is an integer from –128 through 127
If you have 300 000 objects, have you considered to use a database, e.g. Core Data? Instead of a very large bit mask, maybe it would be easier to do the same by a single database (Core Data) request.
To answer your specific question, a C-array of integers would be probably the best solution:
const NUM_OBJECTS = 300000;
//8 * sizeof(int) bits per an int
int* mask = malloc((size_t) ceilf(NUM_OBJECTS / (sizeof(int) * 8.0f));
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How to describe this in description logic?
"every human is either male or female"
Thanks
The answers provided here so far do not use Description Logic syntax (which is variable-free).
Assuming you want the actual Description Logic syntax that is used in scientific papers about Description Logics, check out this:
human \sqsubseteq (male \sqcup female) \sqcap \neg (male \sqcap female)
Its written in LaTeX, you can use an online LaTeX equation editor, e.g. this to render this expression.
With propositional calculus, this would be described as:
∀x.H(x) ⊃ (M(x) ∨ F(x)) ∧ (¬(M(x) ∧ F(x)))
where:
H(x) = x is human
M(x) = x is male
F(x) = x is female
In description logic, it's a little bit different:
human ⊆ (male ∪ female) ∩ ¬(male ∩ female)
don't have the ability to comment yet as a newbie but i believe you would want to use an "exclusive or"... then again, i guess it depends on your universe of discourse ;)