instruction stringlengths 35 29.1k |
|---|
I want to find a reference for the following problem or a similar problem for my paper. I found a greedy algorithm for this problem, but writing such an algorithm in a paper is not common in my area, and finding a reference is the best solution.
We have a connected hypergraph. We want to choose a list of hyperedges sat... |
I checked my Mac, it shows the memory is 16 GB 2400 Mhz, does it mean that the bandwidth is $ \dfrac{16\times1024}{8} \times 2400$, is there any thing wrong with that calculation, because the value seems a little incredible, I am new to this kind of computer science, hope someone can help me.
Thank You
|
The Bellman-Ford algorithm checks all edges in each step, and if for each edge the following:
$d(v)>d(u)+w(u,v)$
holds, then $d(v)$ will be updated. $w(u,v)$ is the weight of edge $(u, v)$ and $d(u)$ is the length of best path was found for vertex $u$.
If in any step there is no update for all vertexes, the algorithms ... |
And how do I solve this?
I know this is a decimal and we have to convert it to an exponent. I want to know how I would solve this and the steps as well so I will be able to solve questions similar to this in the future. Thank you
|
I am reading basics of Exponential Time Hypothesis (ETH). There are two statements for it:
Statement 1
There exists no $2^{o(n)}$ algorithm for $3$-SAT, where $n$ is the number of variables.
Statement 2
If $\delta_q$ ($q \ge 3$) is the infimum of set of constants $c$ for which there exists an algorithm for solving $q$-... |
I'm not sure if this is off-topic but I was thinking about the following: many modern (object-oriented) programming languages are very similar at their core, i.e. they share language features like iterative functions, classes, objects, inheritance, polymorphism etc. Has anyone ever attempted to create a "unifying" (may... |
I have read that; if a polygon contains a hole in it, then the dual graph of a triangulation of the polygon not have to be a tree. But could not get it exactly. How is it possible, what is the relation with the hole in it?
If anyone could explain it with a polygon contains hole. I would be very happy and thanks in adva... |
I have an NP-hard problem and an optimization to deal with the problem.
I want to know that is it possible to distinguish between easy and difficult instances of the problem by the parameters of the optimization, like the number of iteration to solve them?
I am not sure that there exists any relation or not. But, I tho... |
Find if a given integer is in the series $1, 5, 2, 13, 10, \dots$ in the most efficient way, where the sequence is given by
$$
f(n) =
\begin{cases}
1 & n=1, \\
2f(\tfrac{n}{2})+3 & n \text{ even}, \\
2f(\tfrac{n-1}{2}) & n>1 \text{ odd}.
\end{cases}
$$
The series is infinite of course, and $x$ can be a number with at m... |
I am trying to prove that $\text{NEXP} = \text{MA} \Rightarrow \text{NEXP} \subseteq P/\text{Poly}$. I tried to approach the result via trying out the contrapositive, that $\text{NEXP} \nsubseteq P/\text{Poly} \Rightarrow \text{NEXP} \ne \text{MA}$ but I couldn't get anywhere. Can anyone give me a hint to proceed?
|
Show that if $SAT \in P/klog(n)$ then $SAT \in P$
Assuming that there is a a constant $k \in \mathbb{N}$ such that $SAT \in P/klog(n)$, I need to prove that $SAT \in P$.
Since $SAT \in P/klog(n)$, then there is a sequence of advices $\{a_n\}_{n \in \mathbb{N}}$ of length $|a_n \le klog(n)$ and a turing machine $M$ that... |
Hi I am currently learning about orthogonal range search and found two data structures with two different runtimes and wanted to proof that one always dominates the other.
So I found out about k-d-trees with a query time of
$$\mathcal{O}(n^{1-\frac{1}{d}})$$
and range trees with a query time of
$$\mathcal{O}(\log^{d-1}... |
Suppose $L_1$ is a regular language and $L_2$ a non-regular one, then:
is $L_1\setminus L_2$ REGULAR/NON REGULAR/BOTH OF THEM?
is $L_2\setminus L_1$ REGULAR/NON REGULAR/BOTH OF THEM?
|
Let's say we have a forest of imperfect binary merkle trees of different heights (this is an invariant). Only the numbered nodes store data, the rest store hashes. Here is an example with 4 trees, with heights 3, 2, 1, 0. Laid out with the leaves at the bottom, non-leaf roots labeled with letters:
A
|---------------\
*... |
I am trying to find a fast algorithm that can compute the number of hamiltonian paths in an undirected graph. I saw this on the web, but it sounds like this finds all hamiltonian paths starting from one specific vertex. (for example vertex '0' in this code)
One idea is to run the above algorithm for all of the vertices... |
I'm trying to give a general comparison of the time complexities of various thresholding algorithms. I have not taken an algorithms course yet, so please forgive any misunderstandings.
Otsu's method is performed on $N$ pixels with $L$ number of pixel intensities (e.g. an 8 bit greyscale image would have $L=256$). The a... |
I was reading a paper and I came across the term $L\notin i.o.Dtime(2^{n^c}/n^c)$. What is the meaning of this?
|
Let $f: \mathbb{R}^n \to \mathbb{R}$ be a convex function. Let $V \subseteq \mathbb{R}$ be some closed convex set. Consider the following convex minimization problem:
\begin{align}
\min_{\mathbf{x} \in V} f(\mathbf{x}) \label{minconv}\tag{1}
\end{align}
Let $\mathbf{x}^*$ be the minimizer of $f$, i.e., $\mathbf{x}^* = ... |
I'm pretty sure that the Turing machine state diagram I drew accepts all strings in the language $\{a^{n}b^{2n}c^{3n}|\ n\ge0\}$, but how do you verify this? Likewise, how do you verify that this machine rejects any string not in the given language?
|
I am trying to learn more about the CPU in embedded systems. As I am studying I learned that the IR (Instruction Register) is kind of a special register.
What I would like to know is how to know the width / size of the IR. So, what I mean is for e.g. if I have a 16-bits CPU with 18 address lines (that means max. 256 Kb... |
It's quite easy to show that there are only three recursive sets up to m-equivalence, namely $\emptyset,\{1\},\mathbb N.$ Can we state something "similarly short" for recursively enumerable sets, like there are only 4 recursively enumerable sets up to m-equivalence – $\emptyset,\{1\},K,\mathbb N$ (where $K=\{i\mid\varp... |
I wonder how can I construct 4 (distinct) codewords given the fact that code distance is 5. As far as I know that the code distance is the number of distinct bits between any 2 codewords. How to achieve this code distance for the 6 possible pairs from the 4 codewords available(of any bit length). I named, for example, ... |
Because of the covid-19 pandemic, our firm works semi-remote working. We want to that:
Every day 2/5 of staff should be in the office.
Everyone should go to the office 2 times a week.
Teams want to go to the office together. But teams are not very strict. Some people are in 2 teams. So there may be no best solution fo... |
Let there be a bipartite directed graph $G=(V,E)$.
Let's say we have a path cover of the graph. In some texts it is said that this path cover "induces" a flow on $G$. What does this mean?
How can we extract a flow from a path cover (and similarly, extract a path cover from a flow)?
|
I want to know whether there is a decision problem, written EasyProblem, satisfying the follow property:
For every valid instance $x$, $x$ is a Yes-instance for EasyProblem (if we construct EasyProblem as a nature problem). Formally speaking, maybe we can define EasyProblem as a language $L \in \mathrm{DTIME}(n)$ or e... |
Are the algorithms for picking between 2 numbers randomly a lot less computer intensive than the algorithms for picking almost any number randomly? The definition of random for our purpose is anything that's random enough to be thought as being random by the general population. I am thinking it is true, but I wouldn't ... |
I don't understand why I am getting the following execution times for the quicksort with a random pivot.
Times are in microseconds they are the average of five executions.
Random array: 9097
Sorted array: 4250
sorted backwards array: 4396
This doesn't make sense to me. It is obvious that th... |
We are given a Graph G where, s ∈ V and t ∈ V. w:E such that w represents the time from u to v. We have to calculate shortest path between s to t with a twist. The twist is the turbocharger which can be activated at any node u, such that time between u to v becomes (u,v)/3. The turbocharger has to be used just once. F... |
We want to calculate $A_1 \times A_2 \times \cdots \times A_n$, where $A_i$ has dimensions $d_{i-1} \times d_i$.
In the classical matrix chain multiplication problem, we wish to minimize the total number of scalar multiplications. In this problem, we consider the all intermediate matrices arising in the computation (in... |
I'm creating app that allows user to authorize by drawing dynamic gesture in front of camera (actually Leap Motion sensor, but that's not the point). Every person can save their own gesture as their password, so for every user I have a time series representing the gestures where single frame is an array of values that ... |
It is well established that palindrome language is non-regular. The one way to prove it is by means of pumping lemma. The other way is violating the closure properties of regular language. The strategy seems that pick a regular language and intersect with language L under consideration. If the result is a non-regular l... |
I'm studying The Algorithm Design Manual and I was having some difficulty in the proof exercises,
so I asked a question here.
Based on the answer I got in that question(which was not the a complete proof),I came up with a proof.
Prove the correctness of the following sorting algorithm.
Bubblesort (A)
for i ... |
I am learning about model of computation and I found this wikipedia entry that categorises and outlines various model of computation.
Now I want to know the programming languages that builds on these models.
I am aware that functional programming languages are built upon lambda calculus, and that imperative programming... |
I have $$T(n)=T(n-1)+n^{2}$$
And I know, by drawing the recursion tree that this is $\Theta (n^{3})$
However, if I try claiming that it's $O(n^{2})$ through induction:
$$T(n)\le c(n-1)^{2}+n^{2}\le cn^{2}$$
which evaluates to
$$c\ge \frac{n^2}{2n-1}$$
Which makes $c>0$ for all $n>1$ and concludes that the recurrence is... |
Given a sequence $a_1,\ldots,a_n$, find the shortest subsequence $a_i,\ldots,a_j$ such that $\{a_1,\ldots,a_n\} = \{a_i,\ldots,a_j\}$.
I came up with three solutions:
The most straightforward brute-force solution is $O(n^3)$.
We can optimizing brute-force solution, performing a binary search on subsequence length in ... |
I keep encountering citations of the following article:
Takahashi and A. Matsuyama, “An approximate solution for the Steiner problem in graphs,” Math. Japonica, vol. 24, no. 6, pp. 573–577, 1980
For example, Yahui Sun refers to it here as "a widely-used Steiner tree approximation algorithm".
But... w... |
I'm trying to optimize a system with a better algorithm for allocating storage. The system has 'N' writer processes and 'M' disks. (N < 30, M < 10. N can change, M is constant).
Any process can write to any disk and each process regularly writes a file every, say, 5 minutes, but the size of the file can be quite diffe... |
How to prove that language $L = \{G \; | \; \omega(G) \geq \frac{9}{10}\cdot n\}$, where $n$ - number of vertices in the graph, NP-hard?
$\omega$ - is a clique number.
|
I've got this question from a course:
Show how to efficiently find a certificate for each of the following problems assuming that the decision problem is efficiently solvable.
And it seems like this has been poorly explained and I am getting conflicting answers on how to answer. For explanation purposes I will consid... |
I have a sorted multiset (size < 100, real valued) and want to determine the $n^{\mathrm{th}}$ largest of all possible subset sums (including multiplicity in the sums).
Attempt at solving :
I have been looking at ordering the sums starting with the unbounded knapsack problem (UKP) with equal weights to find the sets of... |
Consider the language of all strings whose length is divisible by either $x$ or $y$, where $x,y \geq 1$.
After trying various values of $x$ and $y$, I noticed made the following observation:
If one of $x,y$ is a multiple of the other, then the minimal DFA contains $\min(x,y)$ states, and otherwise it contains $\operat... |
This is given vertabim in my lecture slides and it seems like I'm having difficulty proving this statement mathematically. I know that P is a subset of NP and NP-Complete is also a subset of NP. But what else do we have to prove for this statement?
|
Is it in in a deadlocked state?
In this graph, there is a deadlock initially I think. Since P1 is holding R1 and waiting for R2; P2 is holding R2 and waiting for R1 and R3; P3 is holding R3 and waiting for R1.
Or P1 and P2 are also in a cycle. So it is in a deadlocked state. Am I correct to claim that?
If one more ... |
Why do we create Universal Turing Machine explicilty to simulate the run of a word (say, $w$) on a Turing Machine $M$, given the description on it? Can't we just run $w$ on $M$ itself? I don't see the point of it.
|
Let $M(x,w)$ be a polynomial Turing machine with $|w| = poly(|x|)$, and $L = \{x | \exists_w M(x,w)=1 \}$.
Assuming that $P=NP$ I want to show that there is a polynomial algorithm $N(x)$ that finds a witness for $x$ according to $L$. Namely:
$\forall_{x \in L}M(x, N(x)) = 1 $
My idea was to decide the bits of a witness... |
On the page 1073 of CLRS(Introduction to Algorithms),
Given a circuit C, we might attempt to determine whether it is satisfiable by simply checking all possible assignments to the inputs. Unfortunately, if the circuit has k inputs, then we would have to check up to 2^k possible assignments. When the size of C is polyn... |
I have a machine learning problem where I need to find the most dissimilar subset of rows/columns of an $m$-by-$m$ symmetric similarity matrix $M$ which minimizes the sum of the elements in an $n$-by-$n$ submatrix $N$, where $n < m$. In other words, by minimizing this sum, we find the most dissimilar rows/columns in $M... |
I have a feeling that it's related to how different output layers are stacked up against one another? However, there's a missing link in that argument that I can't completely get to.
|
ReLU units are said to be necessary in CNNs to introduce non-linearity which convolution does not involve. This is needed, because many real-world forms of data are non-linear.
What does non-linearity refer to?
|
The famous 4-sum problem is to find 4 elements at unique indices in an array which sum to a given X. I was looking at one solution I found:
findFourElements(A[1], ..., A[n], X)
create hashtable mp
for each 1 ≤ i < j ≤ n:
mp[A[i] + A[j]] ← (i,j) // (i,j) is an ordered pair
end for
for each 1 ≤ k < l ≤ n:
if m... |
Point-free style is generally taken to mean a style of programming without explicit variables.
I have some intuitions on point-free style but I want to know what the formal mathematical definition is.
I feel like the informal definition should not be taken too literally. Universal quantification, labels/continuations a... |
As I know $L=\{w\in\{a,b\}^*\mid n_a(w)=n_b(w)\}$ is a deterministic context free language. I have drawn a push dawn automata for this language in the format of Sipser as the following
However, as you may know, in Sipser's format, the transition
$$\varepsilon,$;\varepsilon$$
means that "don't read any thing from the i... |
I've read various descriptions of the TGP, most of which seem vague or conflicting on the precise constraints of the problem. Specifically:
is it always or sometimes impossible to reach consensus
finite/infinite messages required
given unreliable communication, is actual message loss important or not.
As another poin... |
I just wanted to make sure I'm on the right track regarding this.
Here's the function that I'm dealing with:
import math
def Mystery2(A, f, l):
if f == l:
return A[f]
m = math.floor((f+l)/2)
x = Mystery2(A, f, m)
c = 0
i = f
while i <= l:
if A[i] == x:
c = c + 1
... |
I am looking answer for the question: Is every total, convergent function f: N → N is WHILE-computable?
In Wikipedia stand, "Every convergent function is computable." But I have no idea how to implement that to this question. How can I show or disprove this statement?
Thanks!
|
What's the meaning of $\log^{O(1)}(a+b)$ ? Is it simply $(\log_2(a+b))^k$ where k is calculated in constant time ? That is the base 2 logarithm usually in computer science when no other base is set, and the $O(1)$ at the log word means that the whole expression should be raised to the power of that number (which I name... |
It can be read on Wikipedia that MIS is NP-hard. However, is it also NP-complete?
This article says:
"Thus, the Maximum Clique Problem(MCP) and the Maximum Independent
Set(MIS) Problem are equivalent. In addition, both problems are
NP—complete".
However, a professor told me that MIS cannot be NP-complete because only... |
• How CPU identifies which device is sending the request?
• How CPU decide which action should be taken for each request?
|
I've already solved the recurrence exactly and found that $T(n) = n - 1$. Therefore, I know that $T(n) = O(n)$.
However, I'm having trouble showing that $T(n) = O(n)$ without solving the recurrence exactly.
My strategy so far has been to prove that $T(n) \leq cn$ ($c$ is a constant) $\forall n \geq 2$ via induction on ... |
I want to find the bit complexity of finding the $n$-th Fibonacci number using the matrix multiplication method. I know that it has complexity $O(\log n)$ if we assume that the standard operations have complexity $O(1)$, but if we now consider their true complexity, for example $O(n)$ for addition, I don't know how to ... |
So I'm thinking of a simple election prediction program to keep track of the minimum ballots the candidates must gain from the uncounted votes in order to win the election.
Assuming we are considering n states each with some different electoral votes. The candidate who has a majority receive all these votes from that s... |
I was reading about type unification and it moves through of substitution of variables. To me it looks like a search for an alpha equivalence... I mean, two types are unifiable if they are alpha equivalent, at last if they are in polymorphic form, is this right?
If I have forall a.a -> a and forall b.b -> b I can apply... |
I want to prove that the subset sum problem is polynomially reducible to the Knapsack problem. Overall I want to show that Knapsack is NP-complete.
There are two parts to showing knapsack is NP-complete
knapsack is in NP
If I show that the subset sum problem is polynomially reducible to the knapsack.
Then since subse... |
I have the following array that contains a day and the scheduled hours, i wanna know how to check if the given time falls in a period of that array, for example let's say the current time is 20:50 how to know if it's in that scheduled array?
{
"monday":[
"00:00", // Period number 1
"00:15",
"00:30"... |
I am trying to find an Algorithm to find the amount of elements in a BST which are greater than a certain number K.
I found it problematic as there are elements which might be greater then K but wont be found by traveling constantly to the right child, as there might be elements that are greater then K in the left sub-... |
Here is the problem, i have a graphical component that displays a tree. It takes as input an array of nodes and array of edges(eg:an edge has a source and target).
I will be performing complex tasks, such as building the tree dynamically from user input, removing nodes adding nodes, hiding a node's children, i would ne... |
I have to formalize the following sentence:
If any house is green then there exists a horse that is white.
I have formalized it the following way:
$$\forall(x)(\mathit{house}(x)\rightarrow \mathit{green}(x))\rightarrow \exists(y)(\mathit{horse}(y) \rightarrow \mathit{white}(y))$$
A friend formalized it in a slightly ... |
Hello I have a problem and would like a help to prove if it is P or not.
Given an array $\mathcal{A}$ of integers. Is there a permutation of the elements of $\mathcal{A}$ such that, $\forall i \in \{1, ..., |\mathcal{A}|-1\} : \mathcal{A}[i] \neq \mathcal{A}[i + 1]$?
Could anyone give me some direction on how to show... |
We know that $A ≤ B$, $B ≤ \overline{A}$ and $B$ is recursively enumerable. Is $A$ recursive or not?
I tried negating whats given, but didn't achieve much. I know that from the very first inequality that $A$ is also recursively enumerable. I assumed whether $B$ is also recursive or not to maybe get to a contradiction o... |
Problem statement
Let $K$ be a set of keys with $|K| = n$ and define the index set $I = \{0, \ldots, m-1\}$. Now let $H = \{h \mid h : K \to I\}$, i.e. $H$ contains all hash functions which map the keys from $K$ to the set $\{0, \ldots, m-1\}$.
Prove or disprove that $H$ is universal.
Attempt
Reiterating the definition... |
I'm doing the CLRS Problems and there's a part I'm having trouble following.
The question is:
Part a) Given 2n numbers, compute the number of possible ways to divide them into two sorted lists, each with n numbers.
Part b) Using a decision tree and your answer to part (a), show that any algorithm that correctly merges ... |
Let $b:\{0,1\}^*\mapsto \{0,1\}$, be a hardcore bit of a one way function $f$. I want to show that $\vert Pr_{x\in U_n}[b(x)=1]-Pr_{x\in U_n}[b(x)=0]\vert=n^{-\omega(1)}$. Intuitively, it looks correct as if it is not the case then the bit is not hardcore, but I do not have any ideas how to proceed with the proof. Can ... |
we know max tsp (maximal Hamilton cycle) is NP-Hard. is there any decision version for this problem to conclude this is NP-Complete?
|
HAMCYCLE = {<"G"> : G is a simple undirected
graph that has a Hamiltonian cycle}
CUBIC CYCLE = {<"G"> :G is a simple undirected graph that contains
a simple cycle of length at least |V (G)|^1/3}
The reduction i figured out is :
G has a ham-cycle <==> G has a cubic cycle of a given length(V^1/3).
Prooving ==> part is s... |
I've seen two answers to this:
Wikipedia says no:
These restrictions mean that total functional programming is not Turing-complete.
And the Wikipedia article cites D.A. Turner as the coiner of "total functional programming," and Turner says on page 755 of Total Functional Programming:
There are two obvious disadvant... |
prove that in binary heap buildheap function does at most 2N-2 comparison
I don't know how should I prove it I need some hint thanks.
buildheap procedure: we have n element and we build a heap at first and then we start from the first node which is not leaf(floor of n/2) and for each step we have 2 comparison(each node... |
I'm trying to understand how the shap algorithm calculates in polynomial time an estimation to the feature attribution function that satisfies the shapely value attributes (specifically for tree based models!).
A simplified version of the feature attribution function for the feature $i$ of the model $f$ prediction for... |
Give a randomized algorithm that takes input two $n \times n$ matrices $A$ and $B$ with integer
entries and does the following: If $A$ and $B$ are similar, then with high probability the algorithm outputs
an $n \times n$ invertible matrix $C$ with rational entries such that $CAC^{−1} = B$; otherwise it outputs $A$ not
... |
I was asked to be able to find minimum, maximum and mean of a large array in constant time. I used 3 variables to track these statistics and updated them on every insert operation. I don't feel like it is the correct answer or maybe there is more nuance. Given that nothing was said about extra space, is this the simple... |
I am trying to find the minimum cut of this flow network, but I feel like I have the cut wrong. Based off this post, I should try to find all reachable vertices in the residual network once there are no augmenting paths, and set that to partition "A", but then I get this weird cut. Is this the right cut?
|
this is the recursion formula for problem :
C(i,S) = min { d(i,j) + C(j,S-{j}) }
In fact, when I tried to implement it as a code, the following code came to my mind:
int TSP(i, S){
if(S.size == 0)
return dist(start_vertex,i)
min = inf
cost = inf
for(int j=0;j<S.size;j++)
{
cost = dist(i,S[j])+TSP(... |
I'm learning data structure and trying to solve problem related to Computer Game like Chess/Go. There is a line in my book on the section of DFS algorithm, which is implemented by two stacks: one for storing the open-list the other for current path. It says there is no good (I think it means efficient) algorithm to ma... |
My approach is to prove that the complement is turing recognizable and undecidable, so that we can prove L not recognizable. But what is the complement of such L?
|
Prove that $\mathsf{P} \neq \bigcup_{k=1}^{\infty}\mathsf{DSPACE}(\log^k n)$.
Hint: Assume that there is an equality, show that this implies $\mathsf{DTIME}(n^{\log n})\subseteq \mathsf{P}$ via a padding argument.
I proved that $L'=\{x\#1^{|x|^{\log|x|}}\mid x\in L\}$ is in $\mathsf{P}$ but I'm not sure how to concl... |
I am currently reviewing the GBFS algorithm and when looking at its completeness I am confused between the difference of it being
not optimal in Tree Search for Finite and Infinite Spaces
that it is optimal for finite Graph State spaces but not when infinite?
Anyone able to help pick this apart and explain it?
|
A linear code is termed as an $\epsilon -$balanced code if all the codewords are having fractional hamming weight $\in (1/2-\epsilon,1/2+\epsilon)$. I want to show that for every $\epsilon\in (0,1/2)$, $\exists$ a linear $\epsilon -$balanced code $E:\{0,1\}^n\mapsto \{0,1\}^{poly(n/\epsilon)}$, with efficient encoding ... |
I am new to Algorithms and Competitive Coding. I have a problem as follow:
For this problem, the time limit is 1 second so brute force is not a good way to solve. The only way I think must be Dynamic Programming or any other way which can run in less than O(nlogn) or even O(n) and the limit memory is 256 Mb.
Initially... |
So I just started learning about computability, undecidability and Turing machines. And I wonder if:
Given a computable and injective function $f$, is $f^{-1}$ also computable and injective?
I don't really know where to start to prove this, any hint or explanation would be appreciated.
|
We covered compression/encoding/decoding of data streams very briefly last lecture and I had an odd idea:
Let's say I have a stream of random 8-Bit numbers. Now the probabilty to encounter each number is 1/256.
If I prime factorize each number though I get a stream of prime numbers where I can calculate the probabilty ... |
From http://web.mit.edu/6.031/www/fa19/classes/12-interfaces-enums/#implementing_generic_interfaces
"That means B is only a subtype of A if B’s specification is at least as strong as A’s specification. When we declare a class that implements an interface, the Java compiler enforces part of this requirement automaticall... |
Problem
Given a set of intervals with possibly non-distinct start and end points, find all maximal gaps. A gap is defined as an interval that does not overlap with any given interval. All endpoints are integers and inclusive.
For example, given the following set of intervals:
$\{[2,6], [1,9], [12,19]\}$
The set of all ... |
I am struggling to analyze the runtime complexity of the following algorithm formally:
Given a string s and a dictionary of words dict(wordDict), add spaces in s to
construct a sentence where each word is a valid dictionary word.
Return all such possible sentences.
For example, given s = "catsanddog", dict = ["cat", "... |
I argue that right quotient of $a^*b^*/b^*$ is $a^*$,is that true?any help or argument to accept or reject my argument will be appreciated:)
|
I was chatting with a friend about my love/hate relationship with XML. He made the comment that, "xml is broken primarily because parsers for recursive self-defined document are basically impossible to get right."
I've heard the critique that XML is very difficult to parse before, but my understanding is limited to di... |
Given a DAG $G=(V, E)$ and a function $f(v)$ which maps every vertex to a unique number from 1 to $|V|$, I need to write a pseudo code for an algorithm that finds for every $v\in V$ the minimal value of $f(u)$, among all vertices $u$ that are reachable from $v$, and save it a an attribute of v. The time complexity of t... |
I just found there is an old program of mine where I implemented the following prime sieving algorithm:
#define MAX=1000001
#define SQRT=1000
// ...
not_prime[1] = 1;
for (int a = 2; a <= SQRT; a++)
if (!not_prime[a])
for (int c = MAX / a, b = a * c; c >= a; c--, b -= a)
if (!not_prime[c])
not... |
I am currently self learning Category Theory and Simply typed lambda calculus (STLC). For learning purposes, I have implemented an STLC interpreter as given in Types and Programming Languages book of Benjamin Pierce. Now i am wondering if I can extend this interpreter with category of sets (category Set ). i.e. inter... |
I am trying to analyze the running time of the following function:
def algo(array: List[int]):
x = 1
y = 0
sigma = 0
for ix in range(1, len(array)): #len(array) always >= 1
summation = 0
for jx in range(ix, 0, -1):
summation = summation + array[jx]
if summation ... |
Let's consider a graph $G(n)$ of $n$ vertices such as no two vertices in $G$ have the same exact neighbors (different open neighbourhoods to be more specific; I wonder if this kind of graphs have already a name). Which is the maximum number of maximal cliques of such graphs? Is that amount polynomically bounded?
Additi... |
Show that there is no comparison sort whose running time is linear for at least half of the $n!$ inputs of length $n$. What about a fraction of $1/n$ of the inputs of length $n$? What about a fraction of $1/2^n$?
The running time of a specific input is linear if the corresponding leaf node is within a linear distance... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.