instruction stringlengths 35 29.1k |
|---|
First question: It is known that Kolmogorov Complexity (KC) is not computable (systematically). I would like to know if there are any "real-world" examples-applications where the KC has been computed exactly and not approximately through practical compression algorithms.
Second question and I quote from the "Elements o... |
This is a question posted for extra practice (i.e., not for credit):
Can an algorithm with $\Theta(n^2)$ run time be faster than an algorithm with $\Theta(n\log n)$ run time? Explain.
I'm not sure how to approach it. I see lots of near-answers online using $O(\cdot)$, but $\Theta(\cdot)$ is a little different because... |
I would like to find the best, average, worst-case complexities of below code.
Its a variant of selection sort. In each pass both min and max is calculated and placed at proper position
def double_selection_sort(arr):
n = len(arr)
for i in range(int(n/2)):
_min, _max = i, n-i-1
for j in range(i+... |
I am trying to deduct how i can, using closure properties, deduct that since the following language is not context free $$L=\left\{abc^{i_1}bc^{i_2}...bc^{i_{2m}}def^{j_1}ef^{j_2}..ef^{j_{2n}}ghq^{k_1}hq^{k_2}...hq^{k_o}\right\}$$
Such that:
$m,n,o \geq 1;$
$m>n>o>0;$
$i_1,i_2,...,i_{2m} \geq 0;$
$j_1,j_2,...,j_{2n} ... |
I'm doing some research on the CRCs, but i can't find informations about the use of two (or more) short CRCs compared to the use of a longer CRC:
Suppose that i have a dataword A of some length and 3 different generator polynomials, 2 of degree 8 and one of degree 16. These polynomials are used respectively by CRC1, CR... |
In textbook by Mitzenmacher and Upfal here, they write in page 62, the following:
By repeating Algorithm 3.1 until it succeeds in finding the median, we can obtain an iterative algorithm that never fails but has a random running time.
Note that that the algorithm has linear running time. Now, if we repeat this algori... |
I have a few different trees, which resemble what the AST that compilers often deal with.
For example:
tree 1
( (a, b), (c, d) )
Imagine that each tree split represents the function "add", then tree 1 simply says: add a and b, then add c and d, in the end, add the sum of these 2 sums as the final result.
tree 2
( ( (... |
I understand the difference in the parsing tables of the above 4 parsers.
I understand that CLR>LALR>SLR>LR(0) in terms of power.
Are shift and goto moves for all LR parsers ( LR(0), SLR(1),CLR(1),LALR(1) ) same?. I think goto should vary as reduce moves vary?
Also, if a grammar is accepted by CLR(1) parser, for whic... |
I've had problems with this one and was unable to solve it on my Algorithms 1 exam:
Input:
-n words
-k letters
Problem:
For each letter print out the one word which starts with that letter and has the least number of appearances. If there are more than one, write the lexicographically smallest one.
The printing of a wo... |
Given is a positive integer integer $n$, and integers $a_1,b_1,\dots,a_n,b_n$ with $ a_i\leq b_i$ for each $i$. What is the complexity of deciding whether there exist integers $c_1,\dots,c_n$ such that $a_i\leq c_i\leq b_i$ for all $i$ and $|c_i-c_j|\geq 2$ for all $i,j$?
What can be observed is that a greedy algorithm... |
i=12
while( i < n )
{
i=i^5
i=i/3
i=i∗7
}
What is the complexity of the given program?
|
I read about LL(1), LR(0), SLR(1) and LALR(1) in many online sources and even in dragon book. However I found that no one talks about LL(0), SLR(0) and LALR(0). So I googled and come up against these two links which talk about LL(0): 1 and 2. These answers are quite satisfiable in explaining LL(0) grammars. However I s... |
I am currently stuck on the following problem:
Given a WHILE-program P and the knowledge that all input variales are set to 0, is it decidable if a specific instruction is reached 1000 times?
My intuition is that it is not decidable. Rice's theorem says that a non-trivial property of a program is always undicidable. Bu... |
Let $G = \{\langle M_1\rangle, \langle M_2\rangle, \langle M_3\rangle,\cdots\}$ be an infinite turing recognizable language, whose members are descriptions of turing machines.
How can one prove that the union of all the languages recognized by the turing machines in $G$, $L(M_1) \cup L(M_2) \cup L(M_3)\cup\cdots $ is t... |
my question is if my regular expression R is 1* that means the language accepted is {^,1,11,111,1111...}
in that case i don't understand the meaning what (R*)* means
|
It is clear to me that it should be impossible to prove :
exclMidl = isProp A → ((A) ⊎ (¬ A))
Because it would give deciding oracle for every Proposition.
My question is about the following Types:
exclMidl' = isProp A → ∥ ((A) ⊎ (¬ A)) ∥
or
exclMidl'' = isProp A → ∥ ((A ≡ Unit) ⊎ (A ≡ Empty)) ∥
Are they provable in... |
I know that:
Point 1: Set of languages accepted by $LR(0)$ parsers $\subset$ Set of languages accepted by $SLR(1)$ parsers
Does this logic hold for higher $k$'s? That is, does following fact hold?
Point 2: Set of languages accepted by $LR(k)$ parsers $\subset$ Set of languages accepted by $SLR(k+1)$ parsers, for $k... |
Given n pairs of parentheses, a function which returns the total number of all combinations well-formed parentheses could be:
def count_parenthesis(n, opened, closed):
if closed == n:
return 1
num_pairs = 0
if opened < n:
num_pairs += _count_parenthesis(n, opened + 1, closed)
if opened > closed:
... |
I want to come up with a language that satisfies the pumping lemma while not being a regular expression.
I thought of $\{0^i1^j: i > j > 0\} $. The pumping seems to work just fine, and this is not a regular expression, as it would not be possible to create an automata that recognizes it. This last part is where I'm ha... |
Consider the following problem, which can be called "2-SET-PARTITION":
Given two sets of positive numbers, $a_1,\ldots,a_n$ and $b_1,\ldots,b_n$, where $\sum_{i\in[n]}a_i = \sum_{i\in[n]}b_i = 2 S$, decide whether there exists a subset of indices $I\subseteq [n]$ such that:
$\sum_{i\in I} b_i \geq S \geq \sum_{i\in ... |
I'm looking for an algorithm that gives a smallest value of 'travel cost' within the following constraints:
a complete, connected, weighted graph,
vertices are defined in 3d euclidean space,
relatively low number of vertices (less than 500)
no limits on how many times a node may be visited
a fixed starting vertex
no r... |
How one does prove that if algorithm W failed for a given program $e$ and context $\Gamma$, then there is no substitution $S$ and type $\tau$ such that $S\Gamma \vdash e : \tau$ ?
The original paper states that from the completeness proof one can derive that "it is decidable whether $e$ has any type at all under the as... |
For a given classifier h, How is the true error over a distribution D defined?
\begin{align*}
L_D(h) &= \sideset{\mathbb{E}}{}{}_{x,y \sim D} \Pr[h(x) \neq y] \\ &=
\sideset{\mathbb{E}}{}{}_{x,y \sim D}
\begin{cases}
\Pr[y \neq 0|x] & \text{if } h(x) = 0, \\
\Pr[y \neq 1|x] & \text{if } h(x) = 1.
\end{cases}
\end{align... |
Wikipedia states that three different graph implementations are used in practice:
Adjacency Lists
Adjacency Matrix
Incidence Matrix
While I was learning about these structures, another option occurred to me that seems to have better asymptotic properties than Wikipedia's. My idea is to create a hash map where the key... |
Say language $L$ is recursively enumerable, but not recursive.
Say $a$ and $b$ are symbols of the alphabet and $w$ a word.
Say we have the following language:
$L' = \{ aw | w \in L \} \cup \{ bw | w \notin L \}$
That is, $L'$ consists of the words that are in $L$ with an $a$ added at the beginning and the words that ar... |
Given a number n, what is the most assymptotically fast algorithm to express it in terms of base^exponent + rem such that rem is the smallest possible and base is limited from 2 to some relatively small number (e.g. the maximum number that can be represented by a unsigned int)?
I'm currently using gmp bignum library in... |
Given a PRF - F, is $G_s(x)=F_{F_s(x)}(x)$ necessarily a PRF?
First I thought how to tackle this problem. First I tried using a hybrid argument:
$|\mathbb P[F_{F_s(x)}(x)] -\mathbb P[f(x)]|\leq |\mathbb P[F_{F_s(x)}(x)] -\mathbb P[F_{f(x)}(x)]| + |\mathbb P[F_{f(x)}(x)] -\mathbb P[f(x)]|$ so I can contradict the possi... |
Let $G=(V,E)$ be a DAG and let $v_0\in V$.
Alice and Bob are playing a game in which every player has his own turn and Bob is starting. In every turn $i$, the player is picking an edge $e=(v_i,x)$, then $x$ become $v_{i+1}$ and then it becomes the other player's turn. The player which doesn't have an edge to choose (th... |
A beginner's question about "fine-grained" computational power.
Let $M_k$ be a $k$-tapes turing machine, and let $M$ be a single tape turing machine. We know that $M_k$ and $M$ both have the same "computable power". In addition, one can simulate $M_k$ on $M$ in a way that every computation which takes $O(t(n))$ on $M_k... |
I came across the following question
The error in the expression " if x>y x=2; " is detected by
a. Syntax analyzer
b. Lexical analyzer
c. semantic analyzer
I know that the parentheses of x>y are missing, but it is not syntax error right? as all the syntaxes are correct, but we are missing a pair of parenthesis.. so i... |
Suppose we have designed an Algorithm and we want to find out its complexity. I am looking for a book which mainly focuses on finding out complexity of algorithms rather than introducing me to different search, sort, and ... algorithms.
|
Since they are discrete models, do they have some kind of information boundary? Can all Cellular Automata models be related to the Bekenstein Bound?
https://en.wikipedia.org/wiki/Bekenstein_bound
|
I'm just learning about the travelling salesman problem, and I've been playing around with it. I'm not sure if what I've found is just a special case or not. My professor says the search space size is $n!$, where $n$ is the number of cities.
Suppose we have a table with cities $A,B,C,D$ on each axis, and the elements r... |
I am trying to find an algorithm to sort an array of strings by length in O(n) time complexity, and O(1) space complexity.
The max length of the strings is known.
Because of that, I tried using counting sort, but I failed to do in O(1) space complexity. Because multiple strings might have the same length, I need to sto... |
Given that a language D has a polynomial verifier,
and given that for every word $w \in D$, the length of the certificate $c$ is $O(\log|w|)$ space.
How can I prove that $D\in P$ ?
My idea was to create a TM that takes a word w and runs the verifier on all the strings that are potentially a certificate but I don't kno... |
Given matrix of size N x M (N- rows, M - columns), given integer value K(K < N and K < M). Select arbitrary K columns and create new matrix of size N x K after that select max element from each row and calculate sum - S. Task is to find such K columns, so that this sum S will be maximum for given matrix N x M and value... |
I have seen a remark saying "we usually say that a turing machine accepts/rejects a string, while it decides a language" Is this correct?
As I have also seen places where we mention a Turing machine "accepting a language"
See comment on OP's answer here, then the answer by Jan Hudec : What is the difference between a T... |
What does it mean, if possible, for a Turing machine to be defined over many languages?
|
Today I read that
The scanner is a subroutine which is frequently called by an
application program like a compiler. The primary function of a scanner
is to combine characters from the input stream into recognizable units
called tokens.
But isn't it the job of lexical analyzer? Are they both the same?
|
A decision problem A corresponds to the language L1 if L1 contains all of the solutions to A.
A language L2 is defined as the set of all inputs to which a TM halts and accepts.
What is the link between these two languages?
|
What is the link between the language defined by the Turing Machine and the algorithm that the Turing machine implements?
I.e. What is the link between the language and the algorithm
|
I have proved the decision version of my problem to be $\mathcal{NP}$-complete. And I know that if I can solve the optimization version in poly-time, then I can just compare the obtained minimum (or maximum) with target value in decision version. Thus, the decision version can be solved in poly-time as well. Since, the... |
This post is based loosely on a previous post, but the presentation is somewhat different and hopefully much more succinct.
Basically, I'm wondering if it is plausible for there to be a formal proof of P!=NP if ZF is consistent (obviously the converse is true). The idea is this: since proofs to sentences in ZF can be v... |
When we say a TM solves a problem, what does this mean?
|
It's written here Word Sense Disambiguation: A Structured Learning Perspective:
2.1 Basics of Word Sense Disambiguation
...the POS is usually provided before WSD. POS tagging is closely related to WSD, and POS tagging is a well-studied problem with accuracy over 95%, thus the separation of POS tagging from WSD can ful... |
In this book introduction to algorithms , i have been reading about a method named substitution method to solve the recurrence, the recurrence equation is
\begin{equation}
T(n)=2 T(\lfloor n / 2\rfloor)+n
\end{equation}
the author guessed the solution was $O(n \log n)$ and proved it below, my question is how to make t... |
Does anyone know of any instances where we've been able to show that some complexity class is strictly harder than SZK relative to some oracle?
In general, it seems that SZK is really hard (for example, this paper https://arxiv.org/pdf/1609.02888.pdf shows that SZK is harder than PP relative to some oracle) and so I'v... |
The algorithm should analyze measured time series data in realtime and should check if all values of the specified last period lay inside a specified range. The range is calculated with max-min over the specified time period.
Input data
t | 10:00 | 10:01 | 10:02 | 10:03 | ... | 19:00 |
Temp [°C]| 40 | 41.3 |... |
I was looking at this reading of MIT on computational complexity and on minute 15:00 Erik Demaine embarks on a demonstration to show what is stated in the title of this question. However I cannot follow his reasoning, in practice what he says is this:
we can state a decision problem as string of $0$ and $1$ which in pr... |
This is a question from a quantum computation textbook.
Consider a classical algorithm for counting the number of solutions to a problem. The algorithm samples uniformly and independently $k$ times from the Search Space of size $N$ for solutions using an Oracle that outputs 1 or 0, and let $X_1,X_2,X_3,...X_k$ be the... |
There is a directed social network with large number of nodes and arcs and there are many instances of the network (nodes are same but arcs change in each instance). You can think of it as a stochastic network with probabilities on the arcs, so that in each scenario you end up a different instance of the network (in te... |
I am just starting out learning code.
The output of the following code is OOOXOXOO, but I don't see how X can be printed twice. How does a=2 more than once?
a = 1
while a < 3:
b = 1
while b < 3:
if a == 2:
print ("X"),
print ("O"),
b = b + 1
print ("O"),
a = a + 1
|
I'm working through a proof of correctness for merge sort.
I'm given a loop invariant for a for loop, which makes reference to a subarray $A[p..k-1]$. During the initialization step of the correctness proof, my textbook says "Prior to the first iteration of the loop, we have $k=p$, so that the subarray $A[p..k-1]$ is em... |
I'm trying to prove that a simple computer language is Turing Complete. For that, I did some researches about Turing Machine and I found (if I understand correctly), that we can prove that by simuling a Turing Machine with this language. Like Turing Machine has completeness, the fact to simulate it shows the language h... |
Arden's Theorem says that in the equation $R=Q+RP$, the $P$ cannot have NULL string. In this respect,the theorem will not be valid for the expression $R=Q+R(NULL+01)$. Am I correct? If so, then what will be the justification?
|
I'm trying find an optimization for an equation related to theorem 3.5.7 from "Finite Markov Chains" by Kemeny and Snell (1976). The theorem is:
$$H=(N-I)N_{dg}^{-1}$$
Where $N_{dg}$ is a diagonal matrix with all 0 except for the diagonal portion of N and
$$N=(I-Q)^{-1}$$
And $Q$ is a $n \times n$ square sparse pairwis... |
Today I ran into a this relatively simple (At least from my perspective ) problem. Basically the task is to be able to express any number using only a single number an any combination of arithmetic operations, square roots, exponentiation or factorials. To further elaborate I will make an example.
The input of the prog... |
I have been studying for my algorithms exam and whilst doing previous exams found this question for which I am not sure how to handle.
Given a graph $G=(V,E)$ with integer capacities $C:E \rightarrow \mathbb{N}$, find an efficient algorithm to determine whether the graph has a min cut of at most $k$ edges (assume $k=10... |
Suppose $coNP \neq NP$
language B would be called "complete" in $coNP-NP$ if:
$B\in coNP - NP$
$A\in coNP-NP \implies A\leq_pB$
Are there any "complete" languages in $coNP - NP$?
|
I've been reading Garey-Johnson book Computers and Intractability and I am focusin on Section 3.2, Techniques for proving NP-completeness. In these definitions and explanations nothing is formally defined. I was wondering, how would someone define those techniques formally?
The techniques mentioned are restriction, loc... |
If have a cellular automaton, can I see the state of the board after something like $10^{{10}^{10}}$ time steps? For trivial cases, this is possible - for example, a cellular automaton where the state of the board is known to repeat after some finite period.
But are there any cellular automata (or perhaps even similar ... |
In context of "Computability", I have went over some proofs for Recursion
Theorem using Turing Machine description. A TM $M$ stands for a single tape
Turing machine and $\langle M \rangle$ is the description of TM $M$. Even some semi-decidable machines such as $A_{\mathrm{TM}} = \{ \langle M, w \rangle \mid \text{TM $M... |
Given a directed graph with $n$ vertices, and $k=\log n$, we are given a coloring of the vertices with $k$ colors.
Describe an algorithm determining if there exists a simple cycle in $G$ of length $k$ visiting exactly one vertex of each color.
Time complexity should be $O(n^3)$.
I couldn't think of any efficient solu... |
What are some good algorithms to have a SAT (CNF) solver determine if a given graph is fully-connected or disjoint?
The best one I can think of is this:
Number the nodes 1..N, where N is the number of nodes in the graph.
define N^2 variables with the ordered pair (P, Q), where P = 1..N and
Q = 0..N-1.
Set (1,0) to tru... |
A set $\mathcal{A}$ is the relaxation of another set $\mathcal{B}$, if $\mathcal{B} \subseteq \mathcal{A}$.
I have a set of points defined as the knapsack constraint
$$
\mathcal{X} = \{x \in \mathcal{Z}^n: w^{\top}x \leq b \}
$$
where $\mathcal{Z}^n$ is the n-dimensional 0-1 vectors and $w \in \Re^n_+$ and $b \in \Re_+... |
I know that during compilation we need to undergo several stages like lexical analysis, syntax analysis and so on. Which of them takes the most time?
|
I'm confused between 2 XOR gate symbols, they have a minor difference but I'd still like to know if they truly are identical.
One looks like -
The other, like
Notice, how for one of them the input lines are connected all the way and for the other, it's not. Are they both identical, as I suspect or is there something ... |
I am reading this book and am at a point when the Interval Partitioning Problem is discussed. The pseudocode they provide for it is the following:
Sort the intervals by their start times, breaking ties arbitrarily
Let I_1, I_2, ..., I_n denote the intervals in this order
For j = 1, 2, 3, ..., n
For each interval I_... |
Let's say I have 2 different types of machines responsible for 2 different duties.
I have the PRODUCTION_MACHINES that EACH are able to produce a single unit of goods within 2 hours.
Then I have TRANSPORTER_MACHINES which are EACH able to collect and package away a single unit of goods from the production line at 95 se... |
I am learning the programming langauge Haskell, and I'm trying to wrap my head around what the difference between a type and a kind is.
As I understand it, a kind is a type of type. For instance, a ford is a type of car and a car is a kind of vehicle.
Is this a good way to think about this?
Because, the way my brain ... |
I have heard the quote "L is a trivial language" What does this mean and how do we relate this to Turing machines and complexity theory?
|
I believe I have heard that you can never have more space than the algorithms running time. I could be wrong, maybe other way around. What is the intuition behind this?
|
If we were to assume that primality testing was in NP.
What would the certificate be, so that a polynomial time verifier can check the number X is indeed prime?
|
What is the intuition behind EXPTIME being inside EXPSPACE?
When space complexity is usually smaller than time complexity or in the worse case, they are equal
|
So one of Aaronson's lecture note (https://www.scottaaronson.com/democritus/lec10.html) pointed out that, if we'd like to simulate a BQP-oracle, technically speaking, the oracle of address-target form.
$$
\forall x\in\{0,1\}^n, b\in\{0,1\}: |x,b\rangle\mapsto|x,f(x)\oplus b\rangle
$$
Because such oracle should linearly... |
I had a discussion with a friend developer and teacher. He told me about the Structured program theorem arguing that this theorem is one of the most important to know about. However, I have never heard about it and I don't understand how it may have deeply contributed to the computer theory. It seems quite cited in aca... |
I have an algorithm than can recognize the 2d pixel locations of certain 3d points within a 2d image. Ultimately we are interested in computing a real-world horizontal distance between these points. See the below example.
We have some known a-priori information about the world and the camera.
First of all, we kno... |
Suppose that L(M)=L where M is a one tape TM that can move right or stay.
I need to Show that L is decidable.
I thought of reducing a PDA to this TM, since moving to the right is equivalent to popping and pushing some new symbol to the stack. and staying is the same as not touching the automata at all. but im not sure ... |
I know that synchronous interrupts are interrupts that occur with a clock tick (after finishing an instruction) and I think that periodic if they happen in every n ticks of the clock. To get a better grasp of understanding periodic interrupts I tried without success to find a synchronous but non periodic interrupt.
wou... |
I can't find anywhere the meaning of $L^*$, given that $L$ is a language. I know $^* $ means repetition, for example $0^*$ = $\{ \epsilon, 0, 00, 000, \dots \}$. Or if $A$ is an alphabet $A^*$ are all the possible words.
Does $L^*$ mean the language whose words are the concatenation of the words of $L$?
For example if ... |
Consider a classical discrete memoryless channel (DMC). Let $p$ be an input probability distribution and $Q$ be the channel's transition matrix. $q = Qp$ is a valid output probability distribution. The components of $p$ and $q$ are given as $p_i$ and $q_i$ respectively.
The capacity of this channel is given by maximiz... |
I would like to generate discrete samples $0 = B(0), B(1), \ldots, B(T)$ of a Brownian motion $B : [0,T] \to \mathbb{R}^d$. It is possible to get $O(\log T)$ time random access into a consistent sequence of samples $B(k)$ by constructing the path in tree fashion. We choose $B(T) = \sqrt{T} Z_0$ where $Z_0$ is a stan... |
I have recently been investigating CPU pipelining and branch prediction and have a question about how exactly these fit together.
If, for example, instructions are meant to be fetched in one stage of the pipeline and decoded in the next while the next instruction is fetched simultaneously, how is it possible for the pi... |
I'm reading CLRS and there is the following:
When x→0, the approximation of $e^x$ by $1+x$ is
quite good:
$$e^x=1++Θ(^2)$$
I suppose I understand what means this equation from math perspective and, also, there is an answer in another cs question. But I don't understand some things, so have a few questions.
Why ... |
I'm asking myself if the problem of decide whether a push down automaton will accept a word is decidable.
I would say that you can simulate a push down automaton with a Turing Machine and, if it doesn't loop forever, accept the word when the automaton accepts, or reject when it does. In this case, the problem of decid... |
i am asking myself the following question:
Assuming: A and B are context-free languages, then A - B (difference) must also be context-free language, right?
but I do not know how to prove it.
|
I will divide my question in two parts. The first part I am sure that there is a objective answer, but I am not sure about the second part.
First part:
Is it all (decisions) problems trivial to prove decidable after assuming the Law of Excluded Middle (LEM)? e.g. There is no problem hard to prove decidable after assumi... |
Is the Halting problem in the class of undecidable problems, or it is just in the set of unrecognizable problems?
I understand that if it is undecidable, then it is also unrecognizable. I have seen the two being used interchangeably, however I believe it is possible for a language to be recognizable but not decidable, ... |
Is there a standard name or a reference for the network flow problem that looks very similar to the minimum cost maximum flow problem, only the flow cost that I wish to minimize isn't sum of edge.flow * edge.weight over edges, but rather sum of [edge.flow > 0] * edge.weight over edges, where [edge.flow > 0] equals one... |
The type theory that I have seen is all developed over lambda calculus, which is an inherently functional language.
Nevertheless, in practice imperative languages have type systems. Are there differences in the type theory for imperative vs functional languages?
|
I have been wondering over the following problem:
Given a set $S$ of intervals on the number line. We can do two operations on them:
Add a new interval $[l_i,r_i]$ to $S$
Given an interval $[l_j, r_j]$, which is possibly not in $S$, find the longest interval from $S$ which is contained entirely in $[l_j, r_j]$
If I d... |
I can't find a concise algorithm for the following coding problem:
Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded. For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka', and 'ak'.You can assume that the messages are decodabl... |
Let $M$ be a maximum cardinality matching in a bipartite graph $G(X+Y,E)$. Let $X_0$ be the subset of $X$ unmatched by $M$. Define the following sequence:
$Y_1 = $ the neighbors of $X_0$ using edges in $E\setminus M$.
$X_1 = $ the neighbors of $Y_1$ using edges in $M$.
$Y_2 = $ the new neighbors of $X_1$ ("new" = not ... |
The proof with contradiction that $MIN_{\mathrm{TM}}$ is not Turing-recognizable from Michael Sipser's textbook "Introduction to the Theory of Computation" (Theorem 6.7) is as follows:
$C=$ "On input $w$:
Obtain, via the recursion theorem, own description $\langle C \rangle$.
Run the enumerator $E$ until a machine $... |
I'm looking for a good / efficient algorithm to compare classes of driver licences (or any type of similar objects) and their dates, so that they do not overlap and come in certain order.
eg. We have G1, G2, G, M, etc.
I need to make sure all instances of G1 do not overlap, G1 comes before G2 and does not overlap, and ... |
For the second largest element, I know that the formula is $n+ \lceil\log n \rceil -2 $
Is there any formula for the third largest element? and if so, what is the derivation?
|
The following is Ex 5.2-5 from Introduction to Algorithms (CLRS), 2nd Edition.
Let $A[1...n]$ be an array of n distinct numbers. If $i<j$ and $A[i]>A[j]$, then the pair $(i, j)$ is called an inversion of $A$. Suppose that the elements of $A$ form a uniform random permutation of $<1,...,n>$. Use indicator random variab... |
In order to select questions for an online contest, we get contributors to submit potential questions that they write themselves. Then, out of, say 100 submitted questions, we have to rate them and select the best ones, say about 30. Suppose we have 4-5 people willing to help on the final selection task. No one has tim... |
This question arises from a problem on a problem solving site (https://practice.geeksforgeeks.org/problems/-rearrange-array-alternately/0).
Given a sorted (ascending order) array $A$ of $N$ numbers, re-arrange the elements of A to be this order: [A[n-1], A[0], A[n-2], A[1], A[n-3], A[2], ...]. While the problem doe... |
Based on CLRS question 2.2:
Consider linear search again. How many elements of the input
sequence need to be checked on the average, assuming that the element being
searched for is equally likely to be any element in the array? How about in the worst case? What are the average-case and worst-case running times of linea... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.