instruction stringlengths 35 29.1k |
|---|
Is the internal structure of a red-black tree (which nodes are red or black, the disposition of the branches, the location of each value...) dependent on the order in which the elements were inserted? Or does it only depend on the set of inserted elements, without taking the order into account? Do different insertion o... |
I have a linear program with $n$ variables, $m$ constraints and $O(nm)$ bit total length (the constraint matrix contains only zeros and ones). I am interested in finding a polynomial time algorithm for exact solving of the linear program, where the dependency on $m$ is as small as possible. More formally:
The time comp... |
$L_{1}=\left\{w \in\{a, b\}^{*} | \#_{a}(w)=0\right\}$
$L_{2}=\left\{w \in\{0,1\}^{*} | w=u v u \text { with } u, v \in\{0,1\}^{*}\right\}$
I have problems to prove regularity with the nerode theorem
The idea behind this is that the nerode classes have to be finite for a regular language
How do I use this?
For L1 I kno... |
How to prove that this crossword puzzle is NP-complete?
We have an instance of crosswords in a square grid $G$ of size $m \times m$.
We have a set of black boxes $N$.
We have a dictionary of words $D \subseteq\Sigma^{\ast}$, where $\Sigma$ is a finite alphabet.
The question is whether there is a way to fill in the... |
Consider this, I have n coins and I have placed them in a random order (1st coin is Head, 2nd is Tails etc.). You do not know the order. You can flip one coin at a time and then I tell you if all the coins face the same side or not. You continue flipping until all coins are facing the same side.
I tried breaking it do... |
Many folks use the terms "trace", "execution", "computation", "run", "walk" ... interchangeably when they speak about state machines with labeled transitions. Does any work distinguish between these concepts? E.g., which work says that XXX is a sequence of states, YYY is a sequence of labels and ZZZ is a sequence of ... |
Browsing the wikipedia I got to this page where it is said:
Finding k shortest paths is possible by extending Dijkstra algorithm or Bellman-Ford algorithm and extend them to find more than one path.
The same statement is somewhat repeated in the hall of fame of algorithms:
To find the shortest path one can use sho... |
I am new to LTL and I am trying to understand how it works. My question is: is there such $\sigma$ that:
$ \sigma \models [\Box (\psi \vee \phi) \Rightarrow (\Box \psi) \vee (\Box \phi)]$
I know that:
$\sigma \models \Box \psi: \forall k \, [(\sigma, k) \models \psi] \\
\sigma \models [\psi \Rightarrow \phi]: (\sigma ... |
This is the problem:
An art gallery hired you to put guards so they can monitor artworks in a hallway. The goal is to minimize the amount of guards needed in this hallway. Each guard has a range of 10 meters (5m on the right, 5m on the left with him being in the middle).
No matter where the artworks are put in the ha... |
I'm having some trouble proving what my title states. Some textbooks refer to almost complete binary trees as complete, so to make myself clear, when I say almost complete binary tree I mean a binary tree whose levels are all full except for the last one in which all the nodes are as far left as possible.
I thought of ... |
I'm having an exciting problem that I could not manage to find an optimized solution. I actually have no idea if the problem is already known or not.
Here is the problem :
Consider a list of M sets that ( M = 10000 )
each set contains integers in range 1... N. (Let's say N=50)
each set has the size of K. ( Let's say... |
Are the ones in modern programming languages equivalent to, say, Context-Free Grammars or is there an intermediate (between finite automata and CFGs) set of languages that it covers?
|
I've been looking through a ton of sources to try and understand the definitions of strongly and weakly polynomial time algorithms. Wikipedia
states an algorithm runs in strongly polynomial time if
the number of operations in the arithmetic model of computation is bounded by a polynomial in the number of integers in ... |
How do top news portals detect similar news? For example https://www.bbc.com/news/world-asia-china-51431087, if you go to this webpage, you can see the "More on this story" section at the bottom of the page. This news was published today, but it has detected similar news from days ago.
Is there any known algorithm or ... |
$$A_1 = \{ x \mid x \in A , x^R \not\in B\}$$
$A$ and $B$ are regular over $\Sigma$.
Is $A_1$ regular?
|
I know that, when x = y, then it's not Context Free. This is because, the first letter of y cannot be matched with first letter of x, which is at the bottom of the stack.
But, a link of Show that { xy ∣ |x| = |y|, x ≠ y } is context-free claims that, when x!=y, then it's Context Free. But, how can the letters of x and... |
I have seen a computer program at https://github.com/pkrumins/busy-beaver/blob/master/busy-beaver.py that computes Busy Beaver numbers (well, pretends to). It has busy beaver numbers up to 4, and I am wondering if it is possible (reasonably) for a programmer to add a second-order, n-state, 2-symbol Turing machine.
|
Is there a data indexing technique that speeds up finding subsets of a given set in a collection, or do I always have to scan all of the data?
For example, let's say that I have a collection of sets:
(a, b)
(b, c)
(a, b, c, d)
(a, b, c)
(b, c, d)
(b, e)
(d, e, f)
(d, f, g)
(d, e, f, g)
I want to find subsets of (a, b, ... |
1- why do have a USB controller but a display adapter ?
2- I have heard the terms network adapter and network controller being used, is there a differance between those ?
|
I'm a bit confused with the exponent bias. The sources I found online claim that it is either $2^{n-1}-1$ or $2^{n-1}$, $n$ is the number of bits used for the exponent. In my book when given examples on the bias of a 32bit system the bias is said to be $2^7$ which means the bias is $2^{n-1}$ while in an example on the ... |
We know that the complexity of $T(n)=2T(n/3 + 1) + n$ is $\Theta(n)$, as has been proved on this exchange before. However, what about proving it inductively? I believe that this method might work.
Guess $T(n) \leq cn-d$. Assume true for $m < n$. Specifically, $m = n/3 < n$
Then, $T(n) \leq cn-d$.
$T(n) \leq 2(cn/3 - ... |
I wanted to know if it would practical and useful to analyse machine learning algorithms in terms of asymptotic computational complexity.
I have noticed this is very uncommon. However, I believe it would help us compare these algorithms and decide which one to use for a given scenario.
I am also aware that the runnin... |
Consider the F-measure $F_{\beta}$. I know that with $\beta < 1$ precision is given more importance, ending with $F_{0} = precision$. With $\beta > 1$ means recall gets the upper hand, with the other extreme at $F_{inf} = recall$.
\begin{equation}
F_{\beta} = (1+ \beta^2) \cdot \frac{Precision \cdot Recall}{(\beta^2 \... |
Encountered this question but I couldn't solve with the complexity they solved it:
Suppose I have an array that the first and last $\sqrt[\leftroot{-2}\uproot{2}]{n} $ elements has $\frac{n}{5}$ inverted pairs, and the middle $n - 2\sqrt[\leftroot{-2}\uproot{2}]{n}$ elemnts are sorted. What is the complexity of sorting... |
A stone is located at the point (0,0) of an infinite grid. The stone has exactly $n$ possible moves, not necessarily unique, each described by a $vector$ of integer coordinates. The stone can make each move at most once , and the moves it makes may be arranged in any order.The goal is to reach a point as far (in the E... |
I'm asked to construct a finite automata for a given task. The Automata should accept the values zero or one. In the starting state its output is 1. The output doubles with every one as input and is split in half with every zero as input. The maximum value for the output is 4. Another one as input will put the automata... |
Hello I have this circuit with this I want to learn about Mealey and Moore.
Is this a Mealy Automata? I would say yes because of the upper LED depends on the variables I got.
Otherwise isn't the line of J the next State? So it is a Moore because it only depends on its states?
Now I want to replace the D Flip Flop with... |
A postfix regular expression acting on a binary alphabet (specification from this post) can be described using the following grammar,
R → 0 or 1 or _ or ! or RR; or RR| or R+
where,
0 and 1 match their selves,
! matches nothing,
_ matches the empty string,
; is concatenation,
| is alternation,
R+ matches 1 or more occu... |
Today I had a couple of formal language lectures. The Instructor wrote a regular expression for the alphabet $\{0,1\}$ which does not include any string which includes "11" as a substring.
She wrote that regular expression: $0^*\cup 0^*1(00^*1)^*0^*$.
I have nothing against that but after the lecture I tried to solve t... |
Say we have the set $X=\{ x_1, x_2, \dots \}$ of variables. Then we consider the following problem: Is the formula
$$\bigwedge_{(a,b,c) \in A}(a \vee b \vee c) \wedge \bigwedge_{(a,b,c) \in B}(\neg a \vee \neg b \vee \neg c)$$
for $A,B \subset X^3$ satisfiable.
This problem has been called Montone-3-Sat before and it... |
Given a set of terminal symbols $\Sigma=\{a,b\}$ and a set of nonterminal symbols $N=\{S,A,B\}$ with start symbol $S$, then the two following sets of production rules are equivalent:
$S\to aA$
$A\to aA$
$A\to bB$
$B\to aA$
$B\to bB$
$B\to \epsilon$
and
$S\to aA$
$A\to aA$
$A\to bA$
$A\to b$
They both match any stri... |
I would like to know how we can demonstrate these two problems :
$A \leqslant_p B$ implies $\overline A \leqslant_p \overline B$
The complement of 3-SAT is co-NP-complete
|
I just started learning about NP-Complete problems and one of the first examples they give is Set Cover:
Given a set $U$ of $n$ elements, a collection $S_1, \ldots, S_m$ of subsets of $U$, and a number $k$, does there exist a collection of at least $k$ of these sets with the property that not two of them intersect?
T... |
I just learned pumping lemma this week and got confused on this question.
B={$a^{fn}$ | $f_n$ is a Fibonacci number} for $a \in Σ$.
Hint: the sequence of Fibonacci numbers get increasingly further apart.
I am trying to prove this is not regular using pumping lemma, but 'Fibonacci numbers get increasingly further apart'... |
My textbook states:
Finally, it must be stressed that the Chomsky normal form says nothing about ambiguity in general—a CFG in Chomsky normal form may or may not be ambiguous, just like we have for arbitrary CFGs. On the other hand, if you start with an unambiguous CFG and perform the conversion described above, the r... |
Let's say that I have an MST, $T$. I pick an edge not in $T$ and change its weight, and add it to $T$ to create a cycle. Will removing the heaviest edge from that cycle result in an MST?
MST means minimum spanning tree of a graph. I came across these two posts:
https://stackoverflow.com/questions/13437702/how-to-get... |
Let's use Traveling Salesman as the example, unless you think there's a simpler, more understable example.
My understanding of P=NP question is that, given the optimal solution of a difficult problem, it's easy to check the answer, but very difficult to find the solution.
With the Traveling Salesman, given the shortest... |
The advantage of a multi-level page table is that we can swap the inner-level page tables to some secondary storage. If however we want quick access to the whole address space, we have to keep all page tables in memory. Then there are no savings.
However, imagine that not the innermost page-table pointed to the final f... |
I am looking for references on implementing unification over multidimensional array terms.
Are there specialized unification algorithms for those cases? I wasn't able to find satisfactory literature on the topic, and I am attempting to write a logic programming library for the J language.
|
I want to create constraints such that I can implement the following condition:
Let A be an integer variable >= 0 with an upper bound of 12
I want to introduce the following variable B also an integer:
if A = 1 then B = 0 else B = A
|
Prove that $L=\{a^{n}b^{m}c^{k}\mid n\leq(m+k)\}$ is not regular.
I used the pumping lemma as follow:
there exists $n\in \mathbb{N}$
$z=uvw$
$|uv|\leq n , |v|\geq1$
$uv^iw$ is a string in L, so I need to find i such that $uv^iw$ $\notin L$
I rewritten L so that condition will appear as follow: $n-m\leq k$
I set $i$ to... |
Let $L_1,L_2\in$ CFL $-$ REG, with $L_1\subset L_2$. Which of the following always holds?
$L_1-L_2\in$ CFL $-$ REG and $L_1-L_2\in$ REG.
$L_1-L_2\in$ REG and $L_2-L_1\in$ CFL $-$ REG.
$L_1-L_2\in$ REG. $L_2-L_1\in$ REG.
$L_1-L_2\in$ REG. As to $L_2-L_1$, it may be in REG or not.
None of the above.
|
I recently found a question asking whether the language given below is context-free or not:
$L_1 = \{wxyx | w, x, y \in (0 + 1)^+\}$
My intuition is that I can design a non-deterministic push-down automaton for the language. I would appreciate if you could correct me if I am wrong, or brief me on how I could prove that... |
Suppose I have the simple hash-probe function and we are using linear probing
(k,i) = (k + i) mod m
Assume that there are 3 keys that need to be inserted(k1,k2,k3).
Is there a formula for the average number of attempts required to insert each of the 3 keys?
I know that the avg. no of attempts to insert k1 = 1, since th... |
I'm interested in asymptotically minimizing the maximum between the height of a tree of degree $k$ with $n$ leaves, and $k$, i.e. minimizing $\max(k, \log_kn)$ asymptotically.
If I set $k = \frac {\log n}{\log \log n}$, then the height of the tree is
$\log_\frac{\log n}{\log \log n}(n) = \frac{\log n}{\log \frac {\log ... |
for a project I need to evaluate a model, that tries to predict wether a certain cyber-attack (i.e. connection to a low level honeypot) is just a random access, a new attack-wave or an already known attack-wave. Therefore I am looking for a ground truth. Is there some database that contains historical attack-waves? Som... |
I'm trying to understand the bakery algorithm and read that the Bakery algorithm uses single-writer safe registers. But I am not able to understand the correctness of bakery algorithm with safe registers. Since safe register may return any value that the register may hold If a read does overlap any writes.
choosing[i]... |
Let's say I have three arrays of positive integers X, Y and Z. You can assume that each of the arrays have atmost $N$ elements. All the arrays contain unique elements.
You're allowed to form a triplet of integers $(x,y,z)$ such that $x$, $y$ and $z$ are elements from arrays X, Y and Z respectively.
I want to count the... |
I was studying the paper Derandomizing the Isolation Lemma and Lower Bounds for Circuit Size by Arvind and Mukhopadhyay and came across the following claim (Observation 1.2 on page 3):
"More precisely, for any
polynomially bounded collection of weight assignments $\{w_i\}$ $i \in [n^c]$ with weight range $[n^{c'}]$, t... |
i don't understand the following:
If there's an algorithm that can decide ACYCLIC in Polynomial time, then there's an algorithm who returns a set of k edges, so that the graph obtained by deleting the k edges is without cycles - in polynomial time.
The algorithm should get a directed graph and a natural k as an input, ... |
$L_{4},L_{2}$ are regular languages.
given an expression which we know is regular: $L_{4}\cap \bar{L_{2}}\cap \bar{L_{1}}$
May I assume that the language $L_1$ is regular? using closure properties
|
Wikipedia states:
The main advantage of the neural predictor is its ability to exploit long histories while requiring only linear resource growth. Classical predictors require exponential resource growth.
What is the reason for this?
|
After teaching my philosophy of cognitive science undegraduates what a Turing machine is, I mentioned that there are functions that can't be computed using a Turing machine. A curious philosophy major asked for an example of such a function. Most of the students in the class are not CS students and need not be mathem... |
I think to prove that $\{a^ib^i | i\geq 0\}$ is not regular, we just have to consider the string $a^nb^n$ (which is in the language) and apply the pumping lemma. But I'm not sure how to proceed using the pumping lemma (even though I know it applies with our choice of string, since the string is at least $n$ long).
|
The collision entropy is defined as the Renyi entropy for the case $\alpha = 2$. It is given by
$$\mathrm{H}_{2}(X)=-\log \sum_{i=1}^{n} p_{i}^{2} \tag{1}$$
Take two random variables $X$ and $X'$ which follow the same probability distribution. The probability of a collision is then simply $P_{\rm coll} = \sum_{i=1}^{n}... |
So here are the prerequisites:
There are items to be consumed. Consider an item is just an object with a bunch of properties (e.g. size, weight), and there are tens or hundreds of properties.
Items have quantities. Example: Item_1 {size: 10, weight: 15} - quantity 3; Item_2 {size: 11, weight: 2} - quantity 15 etc.
The... |
whenever it needs to be determined if langage is regular or not, I use the notion that it is impossible for a machine to "remember" an infinte states.
given 2 languages:$L_1=\{(01)^{n}(10)^{n}|n \in \mathbb{N}\}$
$L_2=\{(01)^{n}0(10)^{n} |n \in \mathbb{N}\}$
The only difference between $L_1$ and $L_2$ is the $0$ in th... |
I've watched multiple videos and read posts regarding modern cpus and how they work.
However, those ones very rarely touch the problem on the very basic level.
Like I've read about transistors and stuff but I would like to spend (a lot I guess) time to actually understand how e.g. programming a math operation like 5^... |
I am looking for an efficient algorithm to find convex holes in a given point set.
The problem is
Given $n$ points in the Euclidan plane, and a constant $c$, determine how many empty convex polygons $P_1, \dots, P_k$ there are, such that for each $i = 1,\dots,k$; $P_i$ has exactly $c$ vertices from the given point se... |
Suppose that I have three correlated coins. The marginal probability of Head of coin $i$ is denoted by $p_i$.
The conditional probability of head for coin $i$ given the outcomes of coin $j$ and $k$ is denoted by $p_i|x_j,x_k$, where $x_j,x_k\in\{H,T\}$. We can similarly construct the conditional probability of $i$ giv... |
Suppose you have two lists, A and B, each with length n. The elements of A cannot be compared with other elements of A--there is no order relation among them--and likewise for B. However, elements of A can be compared with elements of B. So for instance, suppose we have a function compareTo(a,b) where a is an elemen... |
I don't think it is, as you have to loop through each set multiple times at least.
implementation of sieve in JS - in the answer at the bottom. The link shows a 10X improvement using sieve.
In this case it is faster b.c. the function changes the integers to bits and is working with bits instead of integers.
But if you... |
Apologies if this question feels like a solution verification, but this question was asked in my graduate admission test and there's a lot riding on this:
What is the worst case time complexity of inserting $n$ elements into an empty linked list, if the linked list needs to be maintained in sorted order?
In my opinio... |
I have to proofe that there are functions defined by $f:\mathbb{N} \rightarrow \mathbb{N}, f(n)=f(2n), \forall n\in \mathbb{N}$, which are not-computable. However I'm not really sure about the correct method.
I thought about a proof by contradiction. Assume each of those functions are computable. Then, by the Church-tu... |
I have a question about the following problem:
Prove that the language $\{a^nva^n | v \in \Sigma^*, n \ge 1\}$ is regular over
$\Sigma = \{a,b\}.$
I know that in proving a language is regular I can either construct a DFA, give a regular expression or show the Nerode-Relation has finite index.
My main problem is, th... |
I am looking for an algorithm that upon an input of a directed graph G and a natural number k,outputs a set of k edges, that upon removing them, the graph will have no cycles. If there are no such k edges, it outputs "not found"
The algorithm cannot use any algorithms for NP-Complete problems - except for the one decid... |
I have the following problem:
There is rectangle with fixed $W > w_i$ width and $H > h_i$ height.
Given a set of item types, where each type has some $w_i$ width, $h_i$ height and $v_i$ value.
I would like to maximize the value of the items placed in the rectangle.
An item can be placed as many times as needed. Not ev... |
This is a quick question. I've been reading up on Lambda Calculus, and I see Normal Order as "outermost leftmost first", and Applicative Order described as as "innermost leftmost first".
I think this makes sense to me, but the explanation is often accompanied by a diagram of a tree (such as pages 15-17 in this docum... |
My assignment asks
Let $S =
\{
w_1\#w_2\# \dots \#w_k | k ≥ 2; (∀i ≤ k)w_i ∈ \{0, 1\}^\star
; (∃i < k) w_i\neq w_{i + 1}^r$
, i.e., not every string $w_i$ is equal to the reversal of $w_{i+1}$. Note $S ⊆ \{0, 1, \#\}^\star$.
Show that S is a CFL by a PDA, P, that accepts it.
I have been stuck on this question for appro... |
I am trying to write an algorithm which produces a solution to a modified n by n sliding puzzle (assuming that an end state is reachable from the given start state). The change is as follows: tiles can belong to sets with other tiles and can occupy any of their positions as well, and the sets are disjoint. The image be... |
Show that $g: \mathbb{N} \to \mathbb{N}$ such that
$$g(x)=\begin{cases} 1 & \text{if halt}(2833,x) \\ 0 & \text{otherwise} \end{cases}$$
is not computable.
We know that
$$g(x)=\begin{cases} 1 & \text{if }\Phi_x(2833)\downarrow \\ 0 & \text{if }\Phi_x(2833)\uparrow \end{cases}$$
How can I use the parameter theore... |
Let's say I have a year $Y$. I wanna know how can I calculate the number of times the calendar configuration of the year $Y$ repeats itself in the year range $[A, B]$.
Is there any method to it without brute force, in a pretty efficient way?
NOTE: I'm talking about the Gregorian Calendar.
|
This is the pseudocode for using deterministic crowding:
for _ in (0, ..., n/2):
p1, p2 = random_individual(), random_individual()
c1 = mutate(crossover(p1, p2))
c2 = mutate(crossover(p2, p1))
if d(p1, c1) + d(p2, c2) < d(p1, c2) + d(p2, c1):
population.add(winner_of(p1, c1))
populati... |
I have 2 large sets of strings (actually they are product names). "Large" means few millions of strings.
Example:
Set 1:
Some good product
Another product
Some name
Blah
Set 2:
Very long some product name with words blah
Another very long product name
asd asd sad sad asdsa
Blah blah blah
Set 1 contains "good" names. ... |
I have been watching some big (Google, Facebook,..) company interview examples and usually when pair programming, they develop the most straightforward algorithm and then the interviewer asks 'could you make it faster (reduce time complexity)'.
I have worked on optimizations of algorithms too and things that immediate... |
In system F, is every closed term $M$, which is of $\forall \alpha . \left( \alpha \rightarrow \alpha \right)$, $\alpha \beta \eta$-equivalent to $\Lambda \alpha. \lambda x^{\alpha} . x$?
I have believed that this is true and have tried to prove it by using the equation
$\forall \alpha. \forall \beta. \forall f^{\alph... |
I'm working with the CPU Pintos and have a question that is:
In which situations can the kernel accessing the data in virtual memory via a pointer lead to problems? And how do you avoid them?
I know that the kernel can access the virtual memory via pointers to the stack, but don't understand when errors may occur.
|
You are given a List of numbers (length unknown).
Let's say the length is 10.
GetRandom(List) is called once. If implemented correctly, each number has 1/10 probability of being returned.
GetRandom(List) is called 100 times. If implemented correctly, each number will appear 10 times in the result.
Fine?
You now have to... |
How to calculate the maximum allowed number of snakes in the game of "snakes and ladders" from mathematical/algorithmic point of view assuming that there is a nxn board?
UPD: My thoughts are simple, but they might be incorrect:
I suppose once any two fields on the board cannot be involved twice forming a snake it mean... |
I am trying to show that the following interference is unsound in terms of Separation Logic:
$$
(p_0 \implies p_1) \implies ((p_0 * q) \implies (p_1 * q))
$$
I came up with the following values for a counter example: $p_0 = true$, $p_1 = x \mapsto 1$, $q = true$. The heap contains just one mapping of $x \mapsto 1$.
The... |
Arora-Barak says that using the Cook-Levin reduction, one can show that all NP-complete problems are downward self-reducible. I know that SAT is downward self-reducible but I am not able to see how we can use this fact together with the Cook-Levin theorem to prove that all NP-complete languages are downward self-reduci... |
Points are in 2d euclidean space. Given a set of n points, A, and a set of m points, B, what is the minimally sized set of circles such that this set of circles covers all points in A and no point in B is covered by a circle?
circles can have arbitrary radius
any thoughts about the difficulty of this problem? any thoug... |
I read about vertex cover and i can't understand why the following occurs. Tried to look and research on the site and in other places but still can't understand it.
In an undirected graph $G(V,E)$, vertex cover is a set of edges U so that every Edge in E has at least one end at U.
Defining the following function: $f(G,... |
What should I learn if I want to make a decision based on multiple variables? Followings are the example of a problem.
I have a farm. My variables are weather, humidity of air, humidity of soil, size of my fruits, etc.. Every hour, I will capture every data and store it in my database. My possible decisions are "Harves... |
What is a quick and a elegant way to reduce vertex cover to minimal vertex cover?
Is it possible to use vertex cover as verifier in the algorithm that reduces vertex cover to minimal vertex cover? since minimal vertex cover is essentially $min{f(x)|x\in VertexCover(G)}$
Graph is basic if it matters, no weights, and it ... |
$$L'=\{ww|w\in L\}$$
I need to give an example of regular language L for which the concatenation of 2's $w$ gives $L'$ which is not regular.
How can I give such an example if according to closure properties for concatenation $L1L2$. each of them is regular,concatenation gives me a regular output.
|
Probably newbie question here, please point me out to relevant theories/tutorials if needed :
let say I want to evaluate the probabilities of the final rankings for a sport competition
the competition involved 8 teams, but I can simplify the problem to 4 contestants (say A - B - C - D)
the competition is splitted in... |
Given a set of positive integers :
$ \\ D = \{ D_1, D_2, ..., D_n\}$
and a non-negative integer $P$, where $P$ is divisible by every element in $D$, then find a set of non-negative integers:
$C = \{ C_1, C_2,..., C_n\}$
such that
$S > P $
where
$S = \displaystyle \sum_{... |
I have come up with the following problem, and cannot seem to find an effective way of solving it:
Consider $n$ clients arriving at a service point at time moments $\{a_i\}_{i=1}^n$ whose duration of service (by a single employee, let's say) is known
to be $\{d_i\}_{i=1}^n$. Choose the turn of servicing them, such t... |
Given two arrays whose elements lie between $[1,10^5]$ and the size of arrays is $[1,10^5]$, how can we find the total number of pairs of elements from these arrays such that their product is a perfect square? The arrays may have same elements.
For example:
Array 1: {1, 2, 4, 5}
Array 2: {4, 8, 16, 125}
Output : 6
Th... |
Say there're two queues of numbered items of different kinds (e.g. color), now we need to merge them into one queue so that each item maintains its order in the original queue, regardless of its kind.
For example,
queue of blacks balls: b1, b2, b3
queue of red balls: r1, r2
one possible merging result: b1, b2, r1, b3,... |
Please consider the figure below. I have to find the best and worst options for W. From the preference list of W, the best option for W is D but there is no matching of W with D in all the 6 options. Thus option 1 is the best option in the context of W because A is the second preferred element of W.
Now C is the worse ... |
Suppose you have an array nums of integers, unsorted, containing the values from 1 to n. You have a second array, call it firstBigger, initially empty, which you want to populate with integers such that firstBigger[i] contains j if j is the least index such that i < j and nums[j] > nums[i]. A brute force search of num... |
In order to keep my interviewing skills sharp, I solve one algorithm/data-structure problem every day, from sites like Leetcode or HackerRank.
If I am not able to solve it after 45 minutes or so, I usually refer to the solution. I review it, understand it, and move on.
However, I have found that I do not really learn a... |
I'm looking for a customer clustering solution. I have done a lot of research on the machine learning level to find algorithms that could fit my needs but I can't find much information when the data is mainly text.
I searched for clustering with string but found little relevant ( for me). Do you have any ideas for algo... |
I have a problem for the comprehension of how to prove that a function $ \log_2 : \mathbb{N} \rightarrow \mathbb{N}$ defined as:
$$\log_2 (x)= \begin{cases}
y & \text{if $x=2^y$} \newline
\bot & \text{otherwise}
\end{cases}$$
is recursive.
I think that I need to use minimization operator but I don't know how to do tha... |
In an undirected (and unweighted) graph, to find the shortest cycle containing a specific vertex $s$, it is usually said to run a BFS from $s$ and the first time to find a re-visit, then that is the wanted smallest cycle length.
This does not seem to be true, quoting from https://www.cs.princeton.edu/courses/archive/sp... |
Given the Equivalence relation R = { x, y $\in$ $\Bbb{Z}$ : (x+y) mod 2 = 0}, what are equivalence classes of 1 and 2?
I can't really see the equivalence classes of infinite sets. Only by having a drawing of all elements can I distinguish the answers, wich is not the case in the above mentioned example.
What would be ... |
I'm doing a masters in CS that requires me to implement from scratch most of the neural network models and because python libraries aren't applicable to what i want.
The problem is that i don't feel capable of implementing those from scratch. Even the MLP seems very difficult, i always try but get stuck and restart. Me... |
For this question I will refer to$\ NP-hard$ problems as those that are at least as hard as$ \ NP-complete$ problems. That is, a problem$ \ H$ is$\ NP-hard$ if there is an$ \ NP-complete$ problem$\ G$, such that$\ G$ is reducible to$\ H$ in polynomial time.$\ NP-hard$ problems are not restricted to decision problems an... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.