instruction stringlengths 35 29.1k |
|---|
I have a question in complexities that I could not do.
There will be D, E, F, three languages belonging to NPH. Suppose that the reductions exist $D \leq _P E$ and $E \leq _P F$.
Determine which of the following statements is correct:
Inevitably there is a reduction $F \leq _P D$
If there was an $F \leq _P D$ reductio... |
I have a question I was unable to do, from a last test I had.
This is the question:
Suppose that there is a language $A \neq \emptyset ,\sum{_{}}^{*}$ such that $A \in CoNP - CoNPC$.
Determine which of the following statements is correct:
In this case it is possible to find a language $B$ such that $B \in CoNPC\... |
I couldn't help but notice the opening summary in Wikipedia's article on Bottom Types:
In type theory, a theory within mathematical logic, the bottom type is the type that has no values. It is also called the zero or empty type, and is sometimes denoted with the up tack (⊥) symbol.
Is the visual similarity to an act... |
I have a question from a test that I could not pass, I could not answer the question and I am looking for help with this question
This is the question
Will be $A\in \mathbf{NP}$
Suppose that $A\notin \mathbf{coNP}$. determine which of the claims is correct:
$\mathbf{P}=\mathbf{coNP}$
$\mathbf{P}=\mathbf{NP}$
$\mathbf{... |
Considering a dynamic array that grows by a constant factor $k$ (the new array has $k$ more cells than the last one) each time the array is full which initially has $n$ elements in it. Calculating the amortized time for insertion:
Consider a sequence $m$ worst case insert operations, then we have constant time for each... |
I am trying to understand the connection between The W-hierarchy as presented in chapter 13 of this book by Cygan et al. and the notion of the NP problems.
Is the existence of an FPT algorithm for a problem in W[1] suggests that P=NP? Why?
For example, assuming I have an FPT algorithm for the k-Clique problem. Can I pr... |
A few days ago I had a test that I failed to pass, and it had a question that I failed to do.
This is the question
Let's look at the language $L_\mathrm{loop} = ${
$\left \langle M,w \right \rangle$ | When $M$ is activated on the input $w$, the machine $M$ enters an infinite loop }
We will mark our input length: $|\lef... |
I have a question from a test that I failed to pass, I failed to do the question.
The question:
Let's look at the problem of the even-length traveling agent. Given graph $G = (V,E)$ and a weight function on the arcs of the graph $W:E \rightarrow \mathbb{R} ^ {+}$ we would like to find an easier route (of the routes of ... |
I had a test that I failed to pass, and it had a question that I failed to do.
This is the question:
Let us look at the language TAUTOLOGY: Collect all the phrases $\varphi$ so that each placement on the variables $\varphi$ will provide $\varphi$. We will denote the number of variables in n and the number of phrases in... |
Could someone explain me how the CPU address the secondary storage? If the CPU needs data that are stored on a HDD (for example), could the CPU address the HDD directly? And the data are transfered directly to the CPU or are first copied into RAM?
I'm talking about a system without DMA.
Thank you
|
A few days ago I had a test that I failed to pass, and it had a question that I failed to do.
the question:
given:
$A \in NPC$
$A \in CoNP$
Determine which of the following statements is correct:
$P\neq NP$
$P\neq CoNP$
$NP\neq CoNP$
$NP=CoNP$
None of the above claims are true.
My idea to solve this, is to choose a l... |
How can I reduce Subsetsum (or maybe other np-complete problem) problem to the problem below?
input : a weighted graph $G$ and numbers $l$ and $u$.
output : Does $G$ has spanning tree, $S$, such that $l \leq \mathrm{weight}(S) \leq u$?
|
I have a dataset with and ID and a date looking like:
+----+------------+
| ID | date |
+----+------------+
| A | 2021-07-20 |
| B | 2021-07-20 |
| C | 2021-07-20 |
| A | 2021-07-20 |
| A | 2021-07-21 |
| C | 2021-07-21 |
| C | 2021-07-21 |
| B | 2021-07-22 |
| C | 2021-07-22 |
| D | 2021-07-22 |
| . |... |
Suppose you're given a string $s$ that consists of lowercase alphabetic letters only. The length of the string is $n$. You are also given $n$ cards, which have lowercase alphabetic letters on the front and back. You want to arrange (shuffle and/or flip each card) the $n$ cards in an order that produces the string. You ... |
I want the algorithm to be in polynomial time and the correct answer rate is 0.5 or more. (True / false judgment is polynomial time)
All the methods I think of take exponential time(2^n).
Can anyone help me?
|
I have been practicing NP-Hardness reductions and have been particularly interested in the language $L = \{ (S,k) | \exists S' \subset S \text{ s.t } \forall x \neq y \in S' \gcd(x,y)=1 \text{ and } \sum_{s \in S'} s \geq k \}$. I am trying to prove that $L$ is NP-Hard and have come up with the following reduction from... |
I have an Object Pool and I will be using it to create Objects. I want to generate an unique id for each object. id should be an integer starting from 0. Ids should be continuous. When an object is deleted that id should be reusable. So that next object created can reuse that id instead of a new id.
And also if there ... |
I study complexity and computation independently.
I have a problem that I can not solve.
That's the problem:
Edge-Coloring problem, we get as input graph G = (V, E) and natural
number k and ask "Is there a coloration in arcs of G which uses at
most k colors?". While painting vertices to two neighboring vertices
must n... |
Prove: $n^{5}-3n^{4}+\log\left(n^{10}\right)∈\ Ω\left(n^{5}\right)$.
I always get stuck in these types of questions, where there is a $"-(xy^{z})"$ in the expression.
Whenever I see the solutions for these type of questions, I can't identify a single method that works every time and it's frustrating. How do I approac... |
Is it because it uses 3 way handshaking, it is reliable? Or is it due to other reasons? Like due to congestion control, flow control and error control in TCP? Why do we call TCP as reliable?
|
I am trying to prove the following statement.
if $\displaystyle \lim_{n\rightarrow\infty}\frac{f(n)}{g(n)}= \infty$, then $f(n) = \Omega(g(n))$ but $f(n) \neq O(g(n))$
What I've done so far
Using the definition of limit: $\forall M>0 \quad \exists n_0 : \forall n \ge n_0 \quad \displaystyle\frac{f(n)}{g(n)} > M$
So I... |
I have a question that is not clear to me, and I have not been able to answer it from a test I had.
This is the question
Let's look at the language $L_\mathrm{reject} = ${
$\left \langle M,w \right \rangle$ | When $M$ is activated on the input $w$, the machine $M$ reach to reject state }
We will mark our input length: ... |
The language given is $L = \{w_1xw_2\mid w_1,w_2\in \{a,b\}^* \text{ and } x \in \{a,b\}\}$. Is this language regular or not?
Since there is no pattern, so it should be non-regular?
Kindly help!
|
Studying for my finals and stuck on the following question:
Prove or disprove: Given an undirected and connected graph $G=(V,E)$ and three different vertices $u,v,w\in V$ then there exists some number $x$ so in any run of BFS from vertex $w$, the distance from $u$ to $v$ in BFS tree is always $x$.
I think it's not tr... |
I suspect that it is not true but I came across with the following statement:
For any direct graph $G(V,E)$, there is always an iteration of DFS algorithm on $G$ so the result does not have any cross edges.
Is it possible to show an example to disprove it?
|
I have a question that is not clear to me, and I have not been able to answer it from a test I had.
This is the question:
Let's look at the problem $Oclique$ , In it we get a graph $G = (V,E)$ , And an odd natural number $k \in N$ ( You can mark: $k = 2d + 1$ for $d \in N $) And ask: "Is there a $U \subseteq V$ clique... |
In the Erickson Algorithms textbook (file:///C:/Users/G068078/OneDrive%20-%20Kaiser%20Permanente/Algorithms_Technique_and_Theory_CS_388G/Undergraduate_CS331/Algorithms-JeffE.pdf)
it has pseudocode for 'momselect':
This is probably a really basic question but I do not get how it ever gets past the red part. It recurse... |
Why the grammar is not (LL1)? (e is the epsilon)
$$S \to a A \mid b B \mid a C c $$
$$A \to a A \mid a a A \mid e $$
$$B \to c C \mid D \mid e $$
CHOICE 1: The grammar is Left-Recursive (LR)
CHOICE 2: The grammar is Non-Deterministic (ND)
CHOICE 3: The grammar has FIRST-FOLLOW conflict(s)
CHOICE 4: Both 1 and 3
CHOICE ... |
Given an unweighted graph $G$, the problem is to add links to the graph with total minimum cost such that the diameter of the graph becomes at most a constant $k$? The cost of adding a link $(u,v)$ is the shortest path length between $u$ and $v$ in $G$.
Has the above problem been looked at? Is it NP-complete?
|
I study complexity and computation independently.
I have a problem that I can not solve.
That's the problem:
Edge-Coloring problem, we get as input graph G = (V, E) and natural
number k and ask "Is there a coloration in arcs of G which uses at
most k colors?". While painting vertices to two neighboring vertices
must n... |
I am solving an interview practice question:
Partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.
My solution is as below, and was accepted.
def partition(self, s: str) -> List[List[str]]:
ans = []
def bt(w, curr):
if not w:
... |
I study complexity and computation independently.
I have a problem that I can not solve.
That's the problem:
For the SAT problem, there is a version in which we receive as input phrase $\varphi$ in the form of CNF and we have to decide whether there is a placement in each of the closures $\varphi$ provides at least one... |
I have a question I was unable to do, from a last test I had.
This is the question:
Will be $A \in NP$
Let $c \in P$ be a language so that there exists $C \leq _pA$. Determine which of the following statements is correct:
$C \notin CoNP$
$A \in P$ if and only if $C \in P$
There is at least one case in which $A \in P$.... |
This was an algorithm problem but I am having problems in formulating it.
I have a certain approach but I do not know how to fully execute:
Given
26 letters in total
All possible strings of length n
Example
Find all possible strings of length 5 such that given [{a, b, c}, {d, g, h}], no two letters from each set can ... |
The pushdown automaton is given as the below diagram.
What I know are as below.
$$ 1,0 ~\texttt{->}~ \epsilon_{} ~~ \leftarrow~~ \text{As 1 is inputted then 0 will be popped from the stack} $$
$$ 0,1 ~\texttt{->}~ \epsilon_{} ~~ \leftarrow~~ \text{As 0 is inputted then 1 will be popped from the stack} $$
$$ 0, ... |
I'm an experienced Software Engineer but very weak in concurrency because of no prior experience in that. I've been interviewing with several companies in which I was asked similar kinds of questions as given below:
If you are designing a fantasy sports application in which there's a contest that can handle only 100 u... |
$f (n) = Θ(f (n/2))$
The counter example in the solutions was $f(n)=\sqrt{n}$.
But then we get for every $n\ge n_{0}$
$\sqrt{n}\le c_{0}\sqrt{\frac{n}{2}}\ \ ->\ \ n\le c_{0}^{2}\cdot\frac{n}{2}\ \ \ ->\ \ 2n\le c_{0}^{2}\cdot n\ \ ->\ 2\le c_{0}^{2}$
and I don't see a problem with that, as we can choose $c_{0}=2$. S... |
$(3 \cdot d) \mod 8=1$. I know the answer is $d=3$ by common sense. But what is the mathematical approach to solve this problem? How do I solve this mathematically?
How do we get this value of 125^107 mod 187=5?
|
Problem. Given positive integers $a$ and $b$, obtain $\frac{a}{b}$ without using division ($/$) directly, though addition ($+$), subtraction ($-$), multiplication ($\times$) and bit-shifts ($\gg$ and $\ll$) are allowed.
Is there a good algorithm to solve the aforementioned problem? This algorithm does not have to be v... |
The following seems to me to be relevant to this question, but to me is an interesting exercise, especially since I have not formally worked with complexity before, but I want to learn more:
Suppose that A is NP-Complete, but B is in P. I claim that A\B is NP-Complete and B\A is NP-Complete as well. To see this, assume... |
My question has to do with the disagreement coefficient in active learning. I've been trying to solve the following question, where I need an algorithm to derive a confidence interval for $\theta$, the disagreement coefficient of a given distribution $\cal D_\cal X$, defined in these notes by Shai-shalev shwartz:
Let $... |
If the complexity of my problem is $O(f_n(n))$ begins at $n =4$ and increases in this sequence:
At
$n = 4$ the number of operations = $(n - 2)$,
$n = 5$ the number of operations = $((n - 2) (n-2)(n-3)/2)$
$n = 6$ the number of operations = $((n - 2) (n-2)(n-3) (n-3)(n-4)/4))$
$n = 7$ the number of operations = $((n-... |
I've came across the optimization bellow
$\phi=argmin_{\theta} \displaystyle\sum_{i=1}^{N}f(x_i,\theta)$
Can i say that minimizing this summation by minimizing each term $\left(\displaystyle\frac{df(x_i,\theta)}{d\theta}=0\right)$ as a such author did is a example of greedy approach? Since i'm minimizing the "whole thi... |
I have a question from a test that I failed to pass, I failed to do the question.
The question is about the reduction between Clique and Subset Sum. I tried to find an explanation for this on the internet and in the books but could not find anything.
Recall the expression problems:
$Clique(G, k)$ - Is there graph G wi... |
I have a directed acyclic graph. Where each node is a task and each edge denotes a dependency.
I want a method to effectively parallelize these tasks. One way would be to topological sort them based on depth. Node a which has no precedents will have depth 0. For other nodes, depth will be the depth of precedent with t... |
I have a question from a test that I failed to pass, I failed to do the question.
The question:
Let A and B have two languages so that there is a reduction function f: $A\leq _pB$.
Suppose that $A \in NP$. We will mark the verification algorithm for A in $M_A$. We will now provide a verification algorithm showing that ... |
Studying for my finals. So I'm reading the "Introduction to Algorithms (Third Edition)" book. In the DFS section there is the following section:
Depth-first search yields valuable information about the structure of a graph. Perhaps
the most basic property of depth-first search is that the predecessor subgraph
$G_{\pi}... |
Alice has a list of secret numbers. Alice wants to give Bob the opportunity to choose one of her secret numbers, and then Alice has to share that specific secret number, but in such a way that Alice can’t know which secret number Bob got to know. Is this known to be possible?
|
I have been given some problems like:
Determine if each of the following strings belongs to the corresponding regular language.
i. ‘10100010’ and L((0*10)*).
iv. ‘011100101’ and L(01*10*(11*0)*)
I just wanted to know the strategy to answer such questions. Show me the working for two of them. Thanks.
|
The set of all words contained in $\{0,1\}^*$ that have an even number of 0’s and an odd number of 1’s.
I came to discover that it is possible but not sure how. Can anyone express it in a regular expression?
|
Large portions of the possible research areas in Automatic Differentiation have broadly defined known solutions; most of which were derived in the 80s and 90s.
Compute vector jacobian products: use reverse mode.
Compute jacobian vector products: use forwards mode.
(other things are a bit less solved, but still, we have... |
Consider:
Constants and variables
If-then-else-elseif statements
Procedures and loops
The very fact that a program is comprised of two or more files (instead just from one large file)
Each one of these features indicates "modularity" but what really makes a program modular by any rigorous standard of computer science... |
I understand uncountably many such languages exist, and the rationale for it is clear to me.
I just cannot think of one trivial, easy-to-prove example.
For instance, the complement of a^nb^nc^n is CF, and for more complicated examples I'm often not even sure what the complement is.
|
In my book,the $O$-notation is given as:
$$O(g)=\{f:\mathbb N\rightarrow \mathbb R_{\geq 0}:\exists \alpha\in \mathbb R_{>0},\exists n_0 \in \mathbb N : \forall n\geq n_0 f(n)\leq \alpha g(n)\}$$
The algorithm(in pseudocode) for simple primality is given as:
input: $n\in \mathbb N$
output: $result$
main code:
if($n<2$)... |
On Hackerrank I found a test that asks to check what the following algorithm computes:
If $x > y$ then $x = x - y$
If $y > x$ then $y = y - x$
If $x \neq y$ then goto 1
Print $x$
Constraints: $x$ and $y$ are greater than $0$
So I think/guess this algorithm returns the product of common factors, so 1 when they do not ... |
I am a tenth grader. I currently learnt about sorting algorithms in java in school. I started with the book "Algorithmic Mathematics" so as learn about algorithms mathematically. I know very little calculus(just started limits) and thus, I had difficulty following it knowing that I am not mature enough to read it .Thus... |
According to Tanenbaum's Modern operating systems,
The purpose of this field is to detect replay attacks. These sequence numbers may not wrap around. If all $2^{32}$ are exhausted, a new security association must be established to continue communication.
According to Forouzan's Data communications and networking,
In... |
Is it possible to use a quantum computer and or a simulation to perform a cyber attack on classic computers? This is part of a research objective I'm trying to figure out.
|
I've encountered this question recently: Given $\Sigma=\{\sigma_1, \sigma_2, ..., \sigma_n\}$ and $n\ge 2$, determine whether the following language is regular or not:
$$
L_1=\{w\in\Sigma^*|for \ 1 \le i \le n, \ \#_{\sigma_i}(w) \ is \ even \iff i \ is \ even \}
$$
And I need to use the Myhill-Nerode theorem to solve ... |
I got black-box (too big to analyze) boolean formula f(...) with 3 sets of input arguments: $x_1... x_i, y_1... y_j, z_1... z_k$. And I want to find such values for x-arguments that for every y-arguments exist z-arguments witch satisfy formula: $(x_1...x_i): \forall (y_1...y_j) \exists (z_1...z_k) f(x_1...x_i, y_1...y_... |
If I want to find the reversal of a regular expression using an automata, Do I have to transform the automata to DFA if it wasn't ?
|
If we want to design a PDA that accepts all words those the first half equals reverse of the second half and there is a '#' between them, "ab#ba" for example.
We start push each letter we read and when we read the symbol '#' don't push it and start popping from its next letter and check for match between the current le... |
Given a chessboard with 4 rows and 4 columns (4x4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Assign a Boolean variable to each cell of the board as below (1, 2, 3, etc. are variable names)
If a variable is True, then there is a queen on the corresponding cell and vice versa.
Use CNF clauses to describe con... |
Given a graph $G$ with $n$ tip vertices, $n-2$ internal vertices, and a cost on each edge $C(v)$, find a minimum spanning tree subject to degree constraints:
tips have a degree of $1$
internal vertices have a degree of $3$.
There are no edges between pairs of tips in the given graph. These constraints ensure an unroo... |
For example, I am given this and my output is:
11+11* = 11, 1, 11, 111, 1111, ......
Since + means or sign, my logic is:
11 appears once or more
Then I work on solving 11*
Is it perfect?
Thanks.
|
The set of all words with the same number of 0’s and 1’s.
The set of all words contained in {0,1}* that have an even number of 0’s and an odd number of 1’s.
I guess first one is NO.
Second one seems no too as we get {0,1,00,11,000,111,...}. Not all of them contains even number of 0s and odd number of 1s.
Am I on the ... |
Consider this algorithm:
RANDOMIZED-SELECT(A, p, r, i)
1 if p == r
2 return A[p]
3 q = RANDOMIZED-PARTITION(A, p, r)
4 k = q - p + 1
5 if i == k // the pivot value is the answer
6 return A[q]
7 elseif i < k
8 return RANDOMIZED-SELECT(A, p, q - 1, i)
9 else return RANDOMIZED-SELECT(A, q + 1, r, i - k)
The book CLRS... |
I need to iterate through all formulas of 7 variables in 3-CNF which have unique satisfying assignment (1,1,1,1,1,1,1).
I could iterate through all formulas which are true under that assignment -- that is, all formulas with no clauses of sort (not a or not b or not c). But there are 2^(7*(7,3)) = 2^245 such formulas.
A... |
I'm making a program that's supposed to be able to find pieces of wood in a dataset to cover a surface. For now I'm focusing on parallelepipedic shapes to simplify the problem (eventually I'd like it to be able to handle any shape).
The user should be able to approximate (almost) any 2D or 3D surface with a big enough ... |
From my theory of computation lecture I recall:
If $A \le_m B$ and $B$ is decidable then $A$ is decidable (uses a computable function as a reduction).
If $A \le_p B$ and $B$ is in P then $A$ is in P (uses a polynomial function reduction).
I wanted to know if there is an analogous notion of reduction for the class N... |
the question is related to networking frameworks; callback-based approach requires you to call a callback function every time you receive a new data packet; this is not a good approach for high-load and high-throughput network servers; is it faster to have a 'while-true' loop running in a separate process or a thread, ... |
Why are Regular sets not closed under infinite unions and intersections, with my flawled reasoning I came to a conclusion that since infinite unions can have no relationship between strings of a language hence it must be regular but the opposite is infact true, can you please help me understand why so, and under what c... |
I am studying data mining and I stumbled upon types of attributes.
They are
Nominal
Ordinal
Interval
Ratio
Data mining book by Tan,Steinbech,Kumar says
Permissible transformations for-:
nominal-: any one to one mapping, eg a permutation of values.
Ordinal-: new_value=f(old_value). An order preserving change of ... |
The problem of enumerating all lists of integers such that the list sums to a known value $k$ is well known and takes exponential time to compute.
If the problem is restricted so that the integers must be greater than $\sqrt{k}$, I feel like the runtime should now be quadratic. Is there a proof of this? More generally,... |
Studying for my finals. I saw the following question:
Prove or disprove: If in a given text the frequency of the letter A is 0.5, then the number of bits encoding in the Hoffman code for the text is 1.
In the solution they said that this statement is true but didn't explain why. I'm trying to prove this statement for... |
Question in title. Looking for whether there is a term that is, if not widely understood, at least citeable to a source.
This is equivalent to asking for the set of nodes that are comparable to the given node in the preorder induced by the digraph. But that's as much of a mouthful as what I wrote in the title.
Example:... |
Given a B-Tree that contains the keys $k$ and $2k$, we know the height
of the tree will be reduced if we delete the key $k$.
Prove or disprove: The height of the tree will also reduce if we
remove $2k$.
Now the solution is that it's true, but the explanation is lacking.. When the height of a B-Tree is reduced it mean... |
I am working on building ML/DL solution for a problem where that data is considered, naturally similar and I am worried if that would be considered as data redundancy.
My question is, is that so? and if yes what can I do about this then, since this is a feature of the actual real data?
|
While this question already exists and does talk about a heuristic with the Farthest Point First technique, I would like to approach the problem in a more efficient way. I do agree that this is an NP Hard problem, but the Farthest Point First technique might not be the best here, since I am looking for something more c... |
We know that the worst-case time complexity of any comparison sorting algorithm is $\Omega(n\log n)$. Is there a lower bound on the worst-case running time of sorting algorithms of any type? Not just comparison-based? I.e, a lower bound on the sorting problem.
|
Let's say we have a string $s[0..n-1]$ and a pattern $p[0..m-1]$ with $m < n$. I am looking for an $O(nm)$ solution to the following problem: find the number of substrings of $s$ not containing $p$ as a substring. Can you please help?
|
So let's say we have the function $f(n)$ that gives $k$ such that $k$ is the smallest number that gives a busy beaver function $B$ value from input $k$ that is greater than $n$. Or more succinctly the smallest $k$ with $B(k) > n$. Can there be computable functions that are not in time complexity class $O(n^c)$ for some... |
Determine if for given some $L$, $S_L=\{\ L(M) | <M>\in L \}$ then for any
$L$, if $S_L=RE$ then $L\in R$. Correct or Incorrect and explain why.
I think the claim is incorrect, and I'm trying to explain it with cardinals.
I know that for each language we have $\aleph0$ turing machines and $|RE|$ is also $\aleph0$
bu... |
I am looking for an algorithm to a problem that I encountered when working with 3D modeling:
On a 3D triangle surface mesh, I have multiple lines, some of them are open, some are closed. The are on one side of each line is defined as inside, the area on the other side of the line as outside. Inside is shown with small ... |
W-types generalize the type of well-founded trees, i.e., possibly infinetely branching trees. I understand that inductive types may be encoded as such in dependent type theory (CIC, MLTT, etc), this answer being particularly helpful in that, but is it possible to derive the usual induction principles from those? E.g., ... |
Referring to the Wikipedia proof :
Wikipedia proves the space hierarchy theorem using the following language:
$$ L = \{ (\langle M \rangle, 10^k) : \text{$M$ does not accept $(\langle M \rangle, 10^k)$ using space $f(|(\langle M \rangle, 10^k)|)$} \}. $$
Why do we need the padding with $10^k$? How does it help us in th... |
I've been scouting the internet for days and after a lot of digging, I decided to resort to my last hope and ask: I'm talking about the "hey Google", "Alexa" and so on voice activations. All results I could find suggested recurrent neutral networks but I have some serious doubts about that for several reasons:
Running ... |
I am trying to understand why the time complexity of the Bit Manipulation solution (https://leetcode.com/problems/add-binary/solution/) to the Binary Addition problem is O(M + N), where M and N are the lengths of the input strings a and b, respectively.
From my understanding, the worst case scenario is that each column... |
I have an algorithmic problem that I am hoping someone can help me out with:
Given: 3D triangle surface mesh, an open polygonal chain (blue).
Wanted: A line that closes the blue line in clockwise direction (green).
The green line provides a correct solution, the red line a wrong solution. Using a shortest path algorith... |
I'm looking for a book on the subject of algorithms and data structures, but I want to specifically learn about the parallel implementations. Books that teach CUDA and OpenCL usually have small sections that briefly touch on this subject, but they are mostly focused on technicalities. I'm looking for something more fun... |
I'm doing an assignment where I need to multiply two 16 bit numbers and store result as an 16 bit integer array.
a is binary with length of n
b is binary with length of m
I have already found out that a * b would have length of n + m if a and b are repdigits consisting of 1 or n + m - 1 if they're not.
Can I also find ... |
I've seen Conway's game of life mentioned in different circles and it seems many people (myself included) have made an implementation of it at one point or another. Other than the fact that it is inherently interesting that complex patterns can arise from such simple rules and the fact that its simple enough to make a ... |
I have an array of numbers, and I need to check if there is a repeating pattern in the array.
Like, for example, if I have an array A=[1,1,6,1,1,6,1,1,6,1,1,6...] this should return "Yes" (pattern present), 3 (for length of the pattern) or "1,1,6" (the pattern).
In contrast, if I have this array A=[1,1,6,1,1,6,1,2,3..]... |
I have been given two True/False questions regarding sorting an array. The questions are as following -
Question A
Given an array A with 3n keys that contains three equal parts
A[1,n], A[n+1,2n] and A[2n+1,3n], each with n keys. Each part is
sorted. Is possible to sort the keys of A into a
new array B in O(n) steps (w... |
We are given an array $A[1..n]$. We don't have direct access to $A$, but we can query what is the sum of $A[i..j]$ for every interval $i..j$. We would like to find the maximum of $A[i..j]$ over all intervals $i..j$. How can we prove that we must make $\Omega(n\log n)$ queries?
My thought is that we can solve the proble... |
My question is about part 15.5 in CLRS (third edition)*, on optimal binary search trees.
I am confused about the following sentences:
Consider any subtree of a binary search tree. It must contain keys in a contiguous range $k_i, …, k_j$ for some $1 \leq i \leq j \leq n$. In addition, a subtree that contains keys $k_i,... |
Assume that the oil company saves for each person that works in the
company a record with its name, its salary, its age and its date of
birth. You can assume that no two fields are identical for any two
employees. a. The accounting department wants to store the records of
all employees such that the following operatio... |
Given an unweighted directed graph $G=(V, E)$, two vertices $s,t \in V$ and a subset of vertices $U \subseteq V$, suggest an algorithm which concludes if there exists a shortest path from $s$ to $t$ which passes through all the vertices in $U$.
The time complexity of the algorithm should be $O(|V|+|E|)$.
I have found... |
I just came across a blockchain concept called "Proof of Space-Time" in which participants compete to verify blocks by generating and storing essentially random data to answer essentially random cryptographic challenges. The more data they can afford to store, the higher their probability of winning a challenge.
The d... |
Consider the following claim.
Let $a_i$'s and $y_i$'s be positive real numbers such that:
\begin{gather*}
y_1 \leq y_2 \leq y_3 \ldots \leq y_n \\
a_1 y_1 + a_2 y_2 + a_3 y_3 + \dots + a_n y_n = v \\
y_1 + y_2 + y_3 + \dots + y_n = 1
\end{gather*}
Show that there exists an $i$ such that:
$$AVG(a_i, a_{i+1}, a_{i+2}, \... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.