instruction stringlengths 35 29.1k |
|---|
I have a question regarding the cardinality of sets and strings.
If $ \Sigma^* $ is empty, the cardinality is 1, because the empty word $ \varepsilon $ is counted.
If $ \Sigma^+ $ is empty, the cardinality is 0, because the empty word is excluded from the set.
If $ \Sigma $ includes at least one symbol, the cardinality... |
I don't understand what these function are like and why they satisfy that f(n) is not O(g(n)) and g(n) is not O(f(n)).
Where is x?
\begin{eqnarray}
f(x)=
\begin{cases}
k^{2k}, &x\in(2,2+1)& \\
k^{2k+1}, &x\in(2+1,2+2)&
\end{cases}
\end{eqnarray}
\begin{eqnarray}
g(x)=
\begin{cases}
k^{2k-2}, &x\in(2,2+1)& \... |
$\text{Consider the following ANSI C code:}$
int main(){
Integer x;
return 0;
}
$\text{What will be the type of error?}$
$\text{a) Lexical}$,
$\text{b) Syntax}$,
$\text{c) Semantic}$,
$\text{d) None}$ $\tag {GATE-CS 2021}$
According to me, Syntax Analysis phase should detect the error as there is no grammar in C whi... |
In Arthur C. Clarke's short story, "The 9 Billion Names of God", two software/hardware engineers are contracted by a monastery to generate 9 billion string permutations from a 13-character alphabet. The only rules are that no character can occur 4 times in a row and each string must be 9 characters long. They estimate ... |
While learning about computers I will read about RAM and Storage and the CPU, and while these explain the architecture of a computer and how parts of a computer work together, I still don't understand the fundamental workings of a computer program.
Let me take an example.
I'm on the web on a mac right now. When I push ... |
I have 50 polynomials $f_i$ over binary variables $(x_1,\ldots,x_{100})$. Also $f_i(0,0,\ldots,0)=0$
for any $i \in [1,50]$. I want to assign few variables so that all $f_i$ will be
identically zero. I want to assign number of variables as small as possible.
Here assign means we will fix some variable either 0 or 1. O... |
For many discrete problems, it's natural to consider their continuous relaxations. A common case is when instead of $x_i \in \{0, 1\}$ we allow $x_i \in [0, 1]$. In certain cases, the original problem is an integer linear programming (ILP) problem, and its relaxed version becomes a linear programming (LP) problem, whic... |
Assuming that the time complexity of the two algorithms $A_1$ and $A_2$ to solve the same problem are $O(n^3)$ and $O(n)$ respectively. If you write programs for these two algorithms and run them in the same environment, does the program of algorithm $A_2$ run faster than algorithm $A_1$ for sure? why?
|
This is the desired result which I want:
|
I am facing the task of designing an algorithm to rank some hundred of images (around 300). The ranking is to be based on pairwise comparison judged by human (done through Amazon mechanical Turk). I have read many papers on ranking inference based on a subset of all possible pairwise comparisons (e.g. Jamieson and Nowa... |
I have found a problem on my Computer Architecture textbook which I have some issues with:
We have a process which spends its time in the following way:
50% of the time, it executes common arithmetic (non-floating point) instructions
10% of the time, it executes floating point instructions
40% of the time, it execute... |
Suppose I have an ode that involves infinitely many variables, with the property that at any given time, only finitely many of them are large enough to be of interest (say $>10^{-10}$). However, at different times, different variables may become large.
It is also the case that given such a set of interesting variables,... |
I think, Preemption can easily be done in kernel mode, where it just have to call the Context-Switch procedure. Also, based on algorithm we can select the new process from the ready queue as well...
I'm unable to think and find Why and where the role of timers come and what exactly are significance of Hardware in preem... |
Imagine a N by M 2D array of random positive integers and two coordinates (i1,j1), (i2,j2), which represent the upper-left bound and bottom-right bound of a subarray, respectively. Is there a efficient algorithm to calculate all the minimum values of each subarray?
[[4, 10, 9, 7],
[9, 8, 1, 2],
[1, 21, 3, 1]]
In t... |
I'm working on creating a rather difficult CFG and I am getting stuck on finishing it. The CFG in question is meant to contain all valid regular expressions using the alphabet {0, 1, (, ), *, +, e} (e for epsilon).
Some examples I know that should be accepted are things like:
e
0
01
1010
0*1*0*1*
0*11+(10)*+(e+1*0*)
(... |
I've implemented longest common substring in python. I know the usual way to reconstruct the path. But, I am reading my algorithm many times, I don't understand why it doesn't work for some test-cases. I am trying to construct the solution while the longest path is being made through dynamic programming.
def lcs(s1, s2... |
Given a function $f$ of $n$ variables, is there a reasonable way to generate all integer points on the hypersurface given by $f(x)=0$?
To be more specific, let us assume that $f$ is a polynomial with integer coefficients and $S=\{x\in\mathbb{R}^n\mid f(x)=0\}$ is bounded. If one knows a bound for the elements of $S$,... |
For any context free grammar, there is a parser that takes atmost n^3 time to parse a string of length n.
Doubt: I marked it false in a national level exam.I think it should be any null-free context free grammar and not any cfg because we first have to convert cfg to cnf but only null free cfg can be converted to cnf.
... |
Given the below ambiguous grammar how can I make it inambiguous and how can I prove the new modified unambiguous grammar is unambiguous? S -> S + S | S − S | S ∗ S | S / S | (S) | x | y
My attempt: The ambiguity can be corrected by
S -> S + T | T , T ->T - M| M, M * N|N , N / Q | Q , Q-> (I) | x| y|
But I'm unsure how ... |
I am trying to understand SVMs in depth watching lectures from MIT.
The professor to reduces the classification problem into an optimization problem. To do that, he first defines the decision and margin boundaries as following:
Note that $\frac1{||\theta||}$ is the distance between the margin boundaries and the decisi... |
For a Finite State Automaton / Finite State Machine (FSM) $F$, that has an input alphabet, a set of possible states, an initial state, a set of possible final states and a state transition function, let a finite input sequence $S$ is given, such that at the end of this sequence the FSM enters a final state and stays in... |
Consider the following program fragment:
var x, y: integer;
x := 1;
y := 0;
while y < x do
begin
x := 2*x;
y := y+1
end;
For the above fragment, which of the following is a loop invariant?
(A)x=y+1
(B)x=(y+1)^2
(C)x=(y+1)2^y
(D)x=2^y
(E)None of the above, since the loop does not terminate
As per my solution, ... |
Is there a polynomial algorithm that can compute the diameter (the distance between the furthest points) of a convex set?
It is possible to do it efficiently for a set of points, but imagine that the set is described by the intersection of linear equations in high dimensional space, so the number of vertices of the set... |
I'm interested in a variant of minimum set cover where some sets are ``incompatible'' (they can't be chosen simultaneously).
To state it more formally:
We have a finite base set $X$ and a family $\mathcal{R}$ of subsets of $X$. We also have an undirected graph $G$ with vertex set $\mathcal{R}$ and edges representing in... |
I am working through the book "Parameterized Algorithms" https://www.mimuw.edu.pl/~malcin/book/parameterized-algorithms.pdf and at the chapter about tree decomposition I am trying to understand the choice of using 2/3 separations instead of 1/2 separators.
It has also been stated in the exercise 7.33 that there would b... |
I was recently working on an old qualifying exam problem asking us to generalize Karger's randomized global min cut algorithm to that of a global min $k$-cut. I recalled the strategy of running a recursive version of the randomized edge contraction algorithm to help with the shrinking the error probability and ultimate... |
I have an NFA, and the question I am asked is :
Let < < . Now in simple English, express the language of the NFA to explain what type of strings are accepted by it.
In simple English, my answer is
The NFA accepts strings over alphabet {a, b, c} such that the last symbol appears twice.
Which I know is correct, however... |
I'm looking for a textbook or reference material to learn about the theory of abstract data types, the ways in which they are specified (axiomatic specification vs abstract model), imperative vs functional definitions, etc.
I'm looking for a theoretical book that gives a good introduction to how they are discussed and ... |
For a CFG with the production rules that can represent a regular expression. How can one calculate all the set of strings that regular expression would produce.
For T = {a, b,*,(,)}
and an arbitrary production rule I created to represent a simple regular expression
S->SS | S* | (S) | a | b | ∅
What would be an attribut... |
I'm trying to solve the following problem :
A tile results of a number and a color.
a tile can be black, red, orange or blue.
a tile number is >= 1 and <= 15.
Given a random set a tiles (a same tile cannot be present more than twice in the set, so we have 15 * 4 * 2 = 120 tiles maximum), find if all the tiles can be ... |
What I tried first was to find the equation of the line and then compare its y-intercepts with the y-intercepts of each point. I just need the proper approach to this algorithm.
|
Suppose for a given optimization problem, $A$, the size of the search space $S$ is |$S$|.
If the fitness landscape defined by $A$ is unimodal, then there is clearly only one global optimum. Given that $G$ is the event "reach the global optimum", can we then infer that $P(G) = \frac{1}{|S|}$, where $P(G)$ denotes the pr... |
From this answer, and the comments that follow:
To clarify, this machine T′ with the fixed output for all inputs is a Turing machine? – Shashank V M
@ShashankVM, Yes, T′ is a Turing machine. – D.W.♦ (When can a deterministic finite-state-automata (DFSA) along with its input sequence be said to be a part of another D... |
I have been looking at the question as to which grows faster asymptotically; $\log \sqrt n$ or $4 \log n$. I have applied L'Hopitals rule and ended up with 1/8. This would imply that they grow at same rate.
Graphically $4 \log n$ is always above $\log \sqrt n$. Also from a perspective that $4 \log n$ is $\log n^4$ w... |
I'm trying to understand what LDA exactly does when used as a classifier, i've understood how the dimensionality reduction works and i've understood that the classification task is carried out with the application of Bayes' theorem, but i still can't figure out if LDA executes both operation when used as a classificati... |
I want to learn computer science, SO is discrete math enough for computer science ? Or there other Math topics that I should also learn With it ?
I don’t have specific topic that I care more about than others (like cryptography) ,Just CS.
|
I saw people use DAGs to represent the search space of a search problems like the travelling salesman problem. Why is this better than the tree representation? Is the reason to save memory space on the computer or can it reduce the computation time in some way?
I googled but I didn't find an answer, it would be great t... |
I understand deterministic as a function for some input will always give the same output, and these inputs and outputs can be sets of values represent by a predicate.
I understand confluent as convergence of a rewriting system, ie the rewritten terms always converge to some term, which could also represent a predicate.... |
As $-1 <\sin(n) < 1$, So $n^{\sin(n)}$ is bounded, but square root of $n$ tends to infinity. Is my logic correct? But from the other perspective, $1/n \leq n^{\sin(n)} \leq n$. I am confused.
|
I have the language $L = \{ dkd\space \mid d \in \{a,b\}^*, k \in \{a,b\} \}$ and i have to show that it's non-regular using the pumping lemma.
The structure of the language i think can be explained as (based on definition above) $\{a^{n}b^{n}ca^{n}b^{n} \mid c \in \{a,b\}\}$
Based on pumping lemma, it must have this 3... |
What would happen in the variant of the Josephus problem in which people in odd-numbered positions are killed in each round?
For example, with $N=10$ people:
$$
1, 2, 3, 4, 5, 6, 7, 8, 9, 10 \to 2, 4, 6, 8, 10 \to 4 ,8 \to 8.
$$
As you can see in the above example the killing starts from position $1$.
I was just curiou... |
I have an array of N symbols written on a cyclic tape. I read a sequence of M symbols starting from a random place on the tape. What error correcting scheme and even a coding scheme should I use for such "channel"?
Also will this problem be simpler if tape is not cyclic?
|
In the wikipedia page on pure type systems, it gives the following inference rule:
$\frac{\Gamma \vdash A : s \quad x \notin \text{dom}(\Gamma)}{\Gamma, x : A \vdash x : A }\quad \text{(start)}$
What does $\text{dom}(\Gamma)$ mean here? These are string rewriting systems, so $\Gamma$ is supposed to be a string of sym... |
There are well-defined methods for generating random graphs / networks that satisfy certain properties, including small-world graphs, scale-free networks, and totally random non-planar graphs. I am looking for methods to generate random graphs that (1) are planar, and (2) have the quality that they are arranged in a l... |
I am told to find the equivalence classes of the Myhill–Nerode relation of the language $\{0^n1^n \mid n \in \mathbb{N}\}$. For one, I know it has an infinite number of equivalence classes given that it's a non-regular language. Im not sure how to find all the equivalence classes and show how I got those equivalence cl... |
I am trying to understand the multiple variable definition of an asymptotic notation. Particularly the definition in Wikipedia. It's also discussed in Asymptotic Analysis for two variables? but I think the answer is wrong. At least it is just corrected in the comments and and referenced to a lengthy answer. What I look... |
What is the asymptotic complexity of
$$f(n) = -\log(c^{1/n} - 1)$$
for some constant $c > 1$? I conjectured $O(\log n)$ and checking WolframAlpha does give $$\lim_{n\to\infty}\frac{f(n)}{\log(n)} = 1,$$ but I haven't found a proof yet.
|
I am not able to understand how to write a recurrence relation for this n queen problem algorithm down below. Recurrence relation is for n*n board and the time complexity
Algorithm : nQueen(B) for the n queens problem
Input : 2-dimensional array B[]
Output: All solutions B[] satisfying the condition for the eight q... |
I just had a data-structures exam. One of the questions asked us to create a data structure which allowed insert operations in O(logn) amortized and delete-max (or min, doesn't matter) in O(1) amortized.
The official answer was to use a regular fibonacci heap, and then to change the potential s.t. for every insert we i... |
Let $G$ be a weighted graph with a weight function $w \longrightarrow \mathbb{R}^{+}$. Let $G'$ denotes the weighted matrix with adjacency matrix
$$A_{G'} = \sum_{i=0}^{k} (xA)^{i}$$
where $k$ is integer and $x$ is a variable.
I am not getting what is $A_{G'}$ matrix? Is it contains all walks of length $k$ or is it som... |
Prove that the language $A$ on $\{0,1\}$ containing all words for which the number of $0$s is equal to the number of $1$s is not regular.
I know one way to do it would be to show that the cardinality of $A / \mathbin \equiv$ is infinite. But how would I find the different equivalence classes and then show it has an inf... |
Consider a simple Bernoulli variable X
X = 1 with probability p
X = 0 with probability (1-p)
The variance is simply p(1-p). The entropy is -p*ln(p)-(1-p)*ln(1-p) Both are measures of uncertainty. What is the advantage of entropy then?
Thanks!
|
This is taken from a practice quiz by my university.
I ruled out that aabbbaab is not part of the grammar:
S → aSb → aaSbb... This shows that I can't make this word because it would have to have atleast two b's at the end in order for me to add more letters
Then I tried to see if abbaabb can be derived from the gramma... |
Suppose I have a polynomial $p(x)$, and a "modulus" polynomial $q(x)$ of degree $d$. I want to find two polynomials $r_1(x),r_2(x)$ of degree $\le d_1,d_2$ such that
$$p(x) \equiv r_1(x) x^t + r_2(x) \pmod{q(x)}$$
Assume $d_1+d_2= d$, and that we are working over some finite field.
Given $p(x),q(x),d,d_1,d_2,t$, is th... |
I got confused about minimal and minimum in context of graph theory.
Although, I have understanding that minimal means more than one minimum i.e. none qualifies as actual minimum so we say them minimal.
What exactly does minimal spanning tree mean? Also, what exactly does 'minimal edge' mean?
How do they differ from mi... |
I'm afraid this may be opinion-based and not apt here, but...
Mathematicians often talk about "mathematical beauty", i.e. Gauss' proof of the Fundamental Theorem of Algebra, Euler's Formula, etc.
What's beautiful in Computer Science?
Things like the Church-Turing thesis or Curry-Howard correspondence are cool, but I'm ... |
As the title says, I have been asked to generate a grammar that defines the language of regular expressions. The symbols are: + . * | ? char
I tried and came up with this but it doesn't work when trying to create a parse tree so it's wrong but I'm so lost on how to even begin to define the different rules. So any help ... |
Let $G$ be a graph which is a tree with $\ell$ added edges. I wish to show that VWVC ((Vertex-)Weighted Vertex cover) is FPT with respect to $\ell$. In particular, I'd like an algorithm running in $O(2^\ell n^c)$ time, where $n$ is the number of vertices and $c$ is a constant.
I tried to approach this by finding a tree... |
First, let's start with the description of the problem in dimension 1:
Let $T_0$ be a space with $n$ nodes organized in a tree structure, with $m$ of those nodes defined as target nodes. In this space, we define a function $f(node)$ that associates each node to the first target node in the path to the root.
So, as an e... |
I was wondering for if a single core processor can be MIMD? or MISD? or SIMD?
I thought MIMD's requirement is multicore, but I am not sure about this
|
k-disjoint triangle
"We consider the NP-complete problem of deciding whether an input graph on n vertices has k vertex-disjoint copies of a fixed graph H. "
The above definition is the best I could find online. Nowhere could I find an clear formal definition.
What does it mean to be vertex disjoint exactly?
How to pro... |
In most machine learning applications, we use Maximum Likelihood Estimation to derive appropriate cost functions. For example, if we assume that our model $f(x;\theta)$ yields the mean of a multivariate normal distribution (i.e. $p(y|x;\theta) = \mathcal{N}(y;f(x;\theta),I)$), we will obtain the mean squared error (MSE... |
I didn't study computer science as a degree, so whilst having studied computer science, there are still gaps in my knowledge. Everything I read about 'state' sounds like some form of 'data' but kept in memory as opposed to a database. This keeps leading me to the question: is a state machine not just a way of storing d... |
There are 3 definitions of asynchrony that I know of:
In event-based programming, asynchrony refers to the execution of tasks in a non-sequential way, which may involve creating another thread. For example with AJAX, we can perform HTTP requests and handle their response in a new thread so that the program doesn't blo... |
If I have a sorted list $A=[a_1, \dots, a_n]$ such that the integers $a_1\leq a_2\leq\dots\leq a_n$, and an unsorted list $B=[b_1, \dots, b_k]$, which includes at least one integer also in $A$, can I then find the maximum integer in $A$ which also is in $B$ in $O(k\log n)$ time? If so, how?
|
I am interested in the asymptotic bounds of the following recurrence:
$$T(n)= T(n - 1) + \frac{1}{n\log n}$$
with base case $T(1) = 1$. I'm having trouble while solving this recurrence. It seems much more tricky than I initially thought.
I've tried out by iterative method and since $\log(n!) = n\log n$,
I've got $\frac... |
Show that $$ 1 + \frac{1}{2} + \cdots + \frac{1}{n} = \Theta(\ln n) $$
How do I solve this problem?
I tried to to integrate it but I got a weird answer.
|
The question is as above.
I want to prove that there exists a $K_5$ as a subgraph, so this graph is not a planar graph. But I failed.
If you can help me, I will be very appreciative.
|
From time to time I stumble across a problem of matching hashmap keys to a regular expression. In such situations I am forced to loop through all of map's elements and try to match every single key to the regex. With regex compiled to DST it should have complexity class of O(n * m) where n is number of elements in map ... |
I wonder how or why Avalanche Effect got its name.
Avalanche Effect is a desirable property of cryptographic algorithms, wherein if an input is changed slightly (for example, flipping a single bit), the output changes significantly (e.g., half the output bits flip).
(source: Wikipedia)
But I feel like this definition... |
I'm trying to design an algorithm that finds a number in a given range. The only signal we get for a given guess is: "Is our guess less than the magic number?" I'm trying to:
Optimize the number of steps it takes to reach the magic number
Minimize how much we overshoot the magic number by
Example: Our range is [1, 10... |
I am a pure math person doing some ML self-study and I am pretty lost.
I am trying to solve the following exercises on decision trees:
Exercise 1. Consider the following training set where
$X_1,X_2,X_3,X_4$ are the attributes and $Y$ is the class variable.
$$ \begin{matrix} Y & X_1 & X_2 & X_3 & X_4 \\ 1 & 0 & 1 &... |
I am still really new to compsci theory and some of the topics are really hard to understand. For this Problem I would think that say we have two sets A and B and they are both non-recursive.
If we take A ∩ B we would get the the matching inputs and since they are both from non-recursive sets wouldn't the intersectio... |
I am looking for an algorithm that can create binary numbers following certain patterns. Let $n$ be the size; and assume that is a power of 2. Let $E$ be the exponent; $n = 2^E; k = \log n$. The $0, 1$ on the "top level" are symbols, and let $0^n, 1^n$ represent $n$ consecutive zeroes and ones respectively.
For size 2... |
Consider the following recurrence relationship.
\begin{eqnarray}
T(n) &=&
\begin{cases}
T\left(\displaystyle\frac{n}{2}\right) + 1, &n \ \mbox{is even number}& \\
2T\left(\displaystyle\frac{n-1}{2}\right), &n \ \mbox{is odd number}&
\end{cases} \nonumber \\
T(1) &=& 1
\end{eqnarray}
How to prove there exists an... |
I understand that the Bellman-Ford Algorithm can solve the single-source shortest-paths problem. However, can it also be used to determine the longest path in an undirected, graph through first negating the weight of all the edges?
|
If I start with 4 threads when I run my code and increase thread number each time I run it, my run time decreases as you would expect. However, my run time for 1 thread is significantly smaller than my run time for 4-16 threads. How can that be? Is it an issue with the time needed to create new threads? Should I change... |
Answering my question Yonatan N said a statement from which follows that there are computable functions of quantum time complexity strictly above polynomial.
Accordingly a Quora answer
Quantum computation is fully deterministic. A given computation applied to a given starting state will always produce the same final s... |
I found this sentence in multiple sources but I didnt understand
in one thesis
With a neutral representation each phenotype could be represented by a
number of different genotype
and in another thesis
it may be possible for neural networks with functionally equivalent
topologies to be represented by a number of diff... |
I am studying a configuration model building $d$-regular graphs and reading the following article:
The expansion of random regular graphs by David Ellis.
I am stuck on the following step:
Each simple labelled $d$-regular graph on $n$ vertices has the same probability of arising. Indeed, it is easy to see that a simple... |
So, I have some data to a time capsule project of mine. But the thing is, I need to know the best media on long-time scale to use as storage unity. The time range is 120 years. Now, I've been thinking about two medias: the average CD-ROM/DVD-ROM and a outdated Vinyl/LP. On the one hand the CD/DVD is a good one, due to ... |
There are several quantum complexity classes in different ways analogous to NP: NQP, QMA, and, as I understand, others.
P=NP BPP=NP in simple words means "any cipher can be deciphered by a classical computer". (Do I understand it correctly?)
So, what is the "formula" for "any cipher can be deciphered by a quantum compu... |
Assume we have a language L={111}. Prove no DFA with four states can accept L.
Can’t a DFA with 4 states accept L?
|
I need to binarily encode/decode small integers (around 10 bits), in such a way that the hamming distance of the encoded number grows monotonically with the (absolute value) arithmetic distance of the numbers.
Edit: the monotonicity doesn't needs to be absolute. There is probably a cost to pay breaking it, but the cost... |
What is a regular expression for the language $C=\{wtw^r \mid w, t \in \{0 \cup 1\}^+\}$?
Here $w^r$ is the reverse of $w$.
|
i need help for a specific problem i have at work.
You have N number of rows in an array, each with some distribution of Numbers that range from 0 to N.Given an array of size 1000:
Row 1 might look like: [1,288,399,784,456,994].
Row 2 might look like: [4,784,123,8]
For each each element in each row, we take the mod 8, ... |
I have a directed graph which has edges between every vertices $i$ and $j$ such
that $i < j$ and the edge is from i->j and every vertex needs to be visited. I need to divide the graph into two parts such that the
travel distance on both the parts i.e. sum of edge weights while traveling from the lowest index to the hi... |
I'm trying to prove that in-order tree traversal prints the keys in sorted order. It's shown here, but what I want is to prove correctness using ordinary induction.
Claim: For any n-node subtree, the in-order-tree-walk subroutine prints the keys of the subtree rooted at node x in sorted order.
in-order-tree-walk(x)
... |
While there's an algorithm for solving the stable roommates problem, I understand that the three-people-per-room version of that problem, sometimes called the "threesome roommates problem", is NP-complete.
I'm wondering if there's an approximation algorithm. This is for a specific use case - grouping people into tables... |
I am a little stuck at attempting to give an NFA for the regular expression $0^+(10^+0)^∗$
, where the alphabet is ${0, 1}$. I have tried to construct multiple NFA's state diagram and the closest I can come up with is
However, I see that this NFA also accepts $0^+(10^+0)^∗0^*$. Is there any way I can alter this state ... |
Recently I encountered an interesting problem while studying discrete mathematics:
Give the pseudo code to judge whether a poset $(S,\preceq)$ is a lattice, and analyze the time complexity of the algorithm.
I am an algorithm beginner, and I am not familiar with various advanced algorithms. I have no idea about this p... |
Consider a string 'ABBAA'
Possible substrings with even number of characters are $4$
'ABBA' : Count of 'A' is even and 'B' is even
'AA' : Count of 'A' is even and 'B' is even - ($0$)
Similarly 'BB' and 'BBAA' substrings.
So a total of $4$ substrings are possible.
If given string is 'AABCCBBCAA'
substrings possible are ... |
Consider two problems as defined here.
Approximate counting: Given a Boolean function $f(x)$, for $x \in \{0, 1\}^{n}$, distinguish between the two cases:
The number of satisfying assignments for $f(x)$ is $\geq 2^{k+1}$.
The number of satisfying assignments for $f(x)$ is $\leq 2^{k}$.
We are promised that one of the... |
Because SD cards use flash memory, they should requires wear leveling to avoid significantly shortening the life of the card. At the same time, my understanding is that they usually use a FAT32 file system.
My understanding of FAT32 is that there is a small "file system description" block at the beginning of the device... |
I found a pseudocode online and I don't know why the complexity of it is $O(2^N)$, according to the site.
Given a fixed curr, the for-loop in lis_ending_here(...) will recursively call curr times itself will new curr range from 0 to curr-1, then I stuck here and don't know what's the next step to get the conclusion $O(... |
In my analysis of algorithms class we were given the following recurrence relation:
\begin{eqnarray}
T(n) &=&
\begin{cases}
T\left(\displaystyle\frac{n}{2}\right) + 1, &n \ \mbox{is even number}& \\
2T\left(\displaystyle\frac{n-1}{2}\right), &n \ \mbox{is odd number}&
\end{cases} \nonumber \\
T(1) &=& 1
\end{eq... |
Assume that we have a set S of sets s.
Every pair (s,s') in SxS can be overlapping or not.
How can we efficiently compute the number of pairs (s,s') that are overlapping, i.e. that share at least one element?
Additional: actually each set s occurs a number of times (S is a multiset). I have tried to create a matrix M o... |
I was asked this in a hiring challenge that I gave today on HackerEarth:
Question/Problem statement:
Given an array, split them into several subarrays(possibly zero) such that you obtain maximum sum of difference between maximum and minimum in each of those subarrays.
Examples:
[1, 2 , 1 , 0, 5]
You can split them int... |
In the paradigm of Turing machines what is considered a program?
Can't find a definition anywhere.
Is it a member of L(M)?
|
Suppose that $D$ is a regular language over an alphabet $A$. How can I prove that the following language is also regular?
$$ \mathrm{LANGUAGE}_2(D) := \{ d \mid d,t \in A^* \text{ and } dt \in D \} $$
(This problem is taken from Introduction to the Theory of Computation by Mike Sipser.)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.