instruction stringlengths 35 11.4k |
|---|
Given two strings of the same length, determine if they are permutations of each other.
I can come up with two solutions, one in O(n log n) time with O(1) extra space, and one in O(n) time with O(n) extra space, but I'm wondering if there are more efficient algorithms.
If we sort the strings in-place and compare them, ... |
Is there an efficient algorithm for the following problem?
Input: Set of holes and pegs. Each hole/peg is an interval $[\ell,u]$ with integer endpoints.
Question: Can all the holes be filled using the pegs given, satisfying the following conditions?
Each peg is assigned to at most one hole.
No hole is assigned more... |
$$L_1= \{\langle M \rangle \mid \text{\(M\) takes at least 2016 steps on all inputs} \}$$
Is this language decidable?
I will write my way of understanding it. Please answer it in the way I understand & tell if my understanding is wrong.
It means L1 is a language, which includes all such Turing machines, which takes at... |
I have a bounded sequence of integers, and for each element, I want to know if the sequence next goes some distance above that element, below that element, or neither. This is straightforward in quadratic time; is there a more efficient solution?
More formally, I have $N$ integers $a_i \in [0, R)$, upper and lower off... |
So I have been asked this question during my comprehensive and I have a few answers to it, I just wanted to check with the community whether I'm on track with them.
Is the following statement true?
$\forall A,B \subseteq \Sigma^{*}, \exists\ f : \Sigma^{*} \rightarrow \Sigma^{*}, s.t. \forall x \in A \implies f(x) \in ... |
I'm trying to solve pretty complex problem with combinatorics.
Namely, we have given three numbers N, K, M. Now we want to count how many different arrays of integers are there with length N, sum K and all the elements in the range [1, M]
Constraints:
1 <= N <= 100
1 <= K <= 100
1 <= M <= 100
Example
Let's say N = 2,... |
I have problems with the basics of mapping reductions.
I can understand how to do reductions using a Turing machine, but without it, I get a little bit confused.
For example:
How do I do a mapping reduction from $a$ to $b$, where $a$ is $\{0,1\}$ and $b$ is $\{0\}$ over the alphabet of $\{0,1\}$?
Does every language h... |
Given two integers $a$ and $b$, determine if $a$ and $b$ are equivalent modulo any $k \, (k: 1 \lt k \lt |a - b|)$.
If $\exists$ an integer $ (k: 1 \lt k \lt |a - b|) \text{ and }a \equiv b \mod k$, then the algorithm would return true, otherwise it would return false.
I thought of this problem today.
B... |
I have found a polynomial time solution of an NPC problem. My algorithm give exact result in most cases. For example if I run my algorithm for 20000 problem instances, then it fails 10 times to give correct result. But, I am unable to prove the approximation ratio mathematically. Is it feasible to show it with the expe... |
I often see DFS is used interchangeably with backtracking specially in many permutation, combinations and subset problems. But usually DFS has implicit tree and does backtracking at leaf nodes whereas backtracking is on an implicit tree and does use pruning each branch.
My question is how to systematically think about... |
According to Shannon (in his 1949 paper) the game of chess has too much complexity to be solved by a brute-force search of the game tree:
A machine... would require over $10^{90}$ years to calculate the first move!
But his paper ends with a section entitled "Another Type of Strategy" and provides vague guidance on ot... |
I am looking at the following:
Costruct a composite turing machine, that reverses the words $w_1$ and $w_2$ over the alphabet $\{\_, x_2, \ldots , x_m\}$ as follows:
$$\ldots \_ w_1\_ w_2\underline{\_} \ldots \mapsto \ldots \_ w_2^R\_ w_1\underline{\_} \ldots$$
The first symbol of $w_2^R$ is on the position where th... |
I'm trying to solve this problem (https://open.kattis.com/problems/exponial) by using fast-exponentiation but I'm getting time limit exicted.
How can I compute it efficiently?
|
I've read up on Finite State Automata in a lot of different books on compiler construction (two of which are actually called Compiler Construction) and I'm kind of at a loss. I understand the idea of moving from state to state and having a state that is accepted. What I don't understand is why in the world this theory ... |
I'm looking for an algorithm that will let me plug in a heuristic for scoring a subtree, and as the algorithm does a depth-first search, it stops when the score has:
Already hit a threshold (minimum score)
only changed a very small amount from child to parent
So this algorithm would be doing a fuzzy search for a "pay... |
I have a following problem:
Given $n$ and graph of size $2^n$, and circuit with $2n$ input gates. Directed edge between $k$ and $l$ exists iff only and only we encode $k$ and $l$ as bits and launch circuit on this input and get result $0$.
Problem:
Is there exists path from vertex $k$ to vertex $l$ ?
I can reduce ... |
Let $S = \{ [x_1, y_1], [x_2, y_2], \dots, [x_n, y_n] \}$ be a set of not necessarily disjoint intervals on $\mathbb{R}$. Is there an efficient way to compute the lebesgue measure of the union
$\displaystyle \bigcup_{i = 1}^n [x_i, y_i]$ ?
I present my ideas and approaches as following.
If all intervals of $S$ are disj... |
I think the number of cliques in a graph is generally exponential in the of vertices of that graph. Does anyone know any reference for that?
|
I have
$4$ variables $n_1, n_2, n_3, n_4 \in \mathbb N$ that sum to $N$.
$4$ positive real constants $c_1 < c_2 < c_3 < c_4$.
Given a particular tuple $(k_1,k_2,k_3,k_4)$, how do I find the partial sum of the ordered (w.r.t. the sum $c_1 n_1 + c_2 n_2 + c_3 n_3 + c_4 n_4$ in an increasing manner) sequence
$$\sum_... |
There is a matrix of size (M x N) in which the cells are marked by one of the three letters (either 'a','b' or 'c'). Now given that there is only one cell that is marked with value 'a' but more than one cells can be marked with value 'b' or 'c'.
There is 8 ways in which one can move form one cell to another, considerin... |
The halting-after-$n$ steps problem may be defined as the question if a given turing machine halts after a maximum of $n\in\mathbb{N}$ steps. Is it theoretically possible to solve this problem in general in less than $n$ execution steps (just execution the program) or can't this be done? If not, why not?
Thank you
|
Magenta's melody_rnn_generate method includes a parameter beam_size. What is it and how does affect the melody?
|
Binary tree with external leaves is a 5-balanced tree if the path from the root to the farthest external leaf is no more than 5 times as long as the path from the root to the nearest external leaf, and if his right and left subtrees are 5-balanced too. Show that the height of such a tree is O(logn).
I was trying to pro... |
TensorFlow's Magenta melody generation module has a parameter for branch_factor1. What is it?
|
I have the following problem: A large number $N$ of (finite length) line segments in the plane (if it helps, we can assume non-intersecting except at end points, and forming a graph with a small number of components); and a smaller number $n$ of points. For each point, I wish to find the closest line segment.
Given on... |
Here's the question: Do more baby names start with "A" or "B"? Write code to count and print those two counts ("A" count, then "B" count).
I then write this code down:
table = new SimpleTable("baby-2010.csv");
count1 = 0;
count2 = 0;
for (row: table) {
// your code here
if (row.getField("name").startsWith("A")) {
count... |
I don't understand a way of proving PSPACE-completness. The way was used by my lecturer. I can use reduction, however following method confuse me:
We consider sequence (of polynomial length) of configurations and check if transitions betweens configurations in sequence are legal. We also check if machine accept word ... |
Let's say an algorithm has an asymptotic time complexity of $\Theta(N)$. However in practice, $N$ is bound by a small upper limit (e.g. the size of a character set). Can we then say the complexity is $\Theta(1)$? Or is there a better way of describing the performance of an algorithm in a particular real-life situation?... |
I was told that we would use a list if the graph is sparse and a matrix if the graph is dense. For me, it's just a raw definition. I don't see much beyond it. Can you clarify when would it be the natural choice to make?
Thanks in advance!
|
unique numbers $1 - n$
combinations (sets) of size $k$
$k < n$
do not re-use an $n$ in a set [1, 1, 1] is not valid
How to generate all unique sets of size $k$?
[1,2,3] = [3,2,1] order does not matter
the number of sets will be ${\binom{n}{k}}$
input
$n = 4, k = 2$
output
[1, 2]
[1, 3]
[1, 4]
[2, 3]
[2, 4]
[3, 4] ... |
I am currently studying for a test on data structures.
I have to find the lower and upper bounds for the following problem:
Input: an array with $n$ numbers.
Output: boolean answer for the question if there exist $1\le i\le j\le n$ so that:
All the elements in the array between $1$ and $i$ are in ascending order.
Al... |
In my work, I had to essentially compute the following quantity.
Given a sequence of positive floating point numbers $\{a_i\}_{i=1}^n$, such that
$$6000 \leq a_i \leq 7000$$
I needed to compute the following quantity (for some $n>1$, but for now can assume $n=1000$):
$$\log_2\left(\frac{\sum_{i=1}^n 2^{a_i}}{n}\right)$... |
Natural language semantics (in computational linguistics) uses lambda terms for expressing the semantics of natural language sentences. There is vast literature about combinatorial categorial grammars and lambda semantics of natural language, e.g. tutorial about framework http://yoavartzi.com/tutorial/
The question is ... |
Let $\chi$ be a degree 2 equation over $\mathbb{Z}_2$ of the form:
$$x_{i_1}x_{j_1} + x_{i_{2}}x_{j_1} + \cdots + x_{i_m}x_{j_m} + x_{k_1} + \cdots + x_{k_l} = b $$ for $ k_i \in \{1, \dots, n\}, b \in \{0,1\}$ for some $m, l \in \mathbb{N}$
Prove that deciding whether a system of such equations has a solution is ... |
I am currently studying for a test on data structures.
I have to find the lower and upper bounds for the following problem:
An array is called a zigzag array if there are $1 \leq i \leq j \leq n$ so that the array increases from $1$ to $i$, decreases from $i$ to $j$, and increases from $j$ to $n$.
Input: a zigzag arra... |
Imagine you have two systems of delimiting. One with paired delimiters, [ and ]:
[abc]
Then another system which uses a single interstitial delimiter, /:
a/b/c
It's easy to see how to encode structure in the first case, as they nest cleanly:
[ab[cd[e]f]]
But let's say you are looking to encode arbitrary nested st... |
In the HRRN scheduling, priority formula is
P = (W+E)/E , where W: waiting time and E: estimated run time.
CPU finds the job that has highest priority value and does that job.
However, the formula is equivalent to P = 1 + W/E. If we just "minus 1" and make a new formula P' = W/E, the order of jobs does not change.
So t... |
I am learning a bit about machine learning, and I frequently see things labeled "linear function" or "nonlinear function."
For example when discussing a neural network created by combining individual logistic regression nodes, a book I read noted that logistic regression is a linear function, and that the entire networ... |
Can polynomial number of bits always encode the number of accepting paths of an $NP$ machine?
Can polynomial number of bits always encode the number of accepting paths of any machine in the polynomial hierarchy?
|
The definition of the class $UP$ is here. It is of course easy to see that $P\subseteq UP$.
I have a problem of proving that there is an oracle $O$ and a language $L$ such that $L\in UP^{\ O}$ but $L\notin P^{\ O}$, i.e. $UP^{\ O}\neq P^{\ O}$.
I find a lot of struggle of finding an explicit $O$, and more struggle to... |
There is an equivalent definition for the class $\mathsf{NL}$ with verifier. Those verifiers are deterministic Turing machines that can read the witness tape only once in one way from left to right.
Given a function $f:\mathbb{N}\to\mathbb{N}$ we say that $\mathsf{NL}[f(n)]$ is the class obtained by the above definiti... |
I have a situation where in a group of people, every person is trading with multiple people and giving them some money. It can be visualised as a directed bipartite graph with L and R as the total set of people. A directed edge from l to r means l gave r some money with weight w which is the weight of the edge. Now I'm... |
I have an application that needs to compute billions of levenshtein distance between pairs of strings. The strings are short (70 in length) DNA sequences, consisting only of 4 characters. Also it can be assumed that one of the strings is fixed, i.e., we are comparing one fixed string to a billion other strings.
I know... |
A logical formula is unsatisfiable if and only if for the formula to be true, at least one of its variables must be both true and false.
I discovered SAT today, and wanted to try my hands at solving it. I arrived at the above statement as a general principle for any attempt I want to make at solving SAT. Is the... |
I know that 3SAT is npc but i wonder why my little algorithm won't solve this problem:
given positive 3SAT - meaning: each of the m clauses is a disjunction of 3 literals over the variables $x_1,\dots,x_n$ ($n$ variables) and each literal is a positive appearance of a variable (no $~x_i$).
for example: $(x_1 \lor x_3 \... |
Definition: A maximal 3CNF formula is satisfiable 3CNF formula, but if you conjuct it with another any new different 3 disjuctive literals clause, then the formula becomes unsatisfiable.
Please don't confuse with the definition of minimal 3CNF formula from my previous question What is the set of all minimal 3CNF formul... |
I'm talking about functions such as Python's math.frexp() :
math.frexp(x)
Return the mantissa and exponent of x as the pair (m, e). m is a float
and e is an integer such that x == m * 2**e exactly. If x is zero,
returns (0.0, 0), otherwise 0.5 <= abs(m) < 1. This is used to “pick
apart” the internal representat... |
Given a sum of regular expressions, where each regular expression in the sum is n-1 concatenations of 0, 1 and (0+1).
There is need to show that the sum of all regular expressions is either equal to or not equal to the regular expression, which is n-1 concatenations of (0+1).
I want to know what is the complexity to sh... |
I seem to remember seeing somewhere (many years ago) a writeup of the math behind calculating the outline of Metafont glyphs. The basic idea is you have a "pen" that is a circle or oval, that you then trace along a cubic spline. The question then is can you define the curve that is the outline of that stroked glyph.
... |
I'm not sure the best way to name this problem, but basically I need to construct a complete $k$-ary tree for $k \geq 2$ which has this nice property as $k=1$ tree that we can create a ring out of it.
For example, to construct $k=1$ suppose $N$ is the number of nodes. If for each node $x$ ($\in 0..N-1$), we pick the ch... |
Every conjunctive normal form (CNF) formula can be converted to nonlinear system of equations, where each clause becomes an equation in the system and:
If A and B are logical/boolean variables and defined as A∈{T,F} ∧ B∈{T,F} or (A,B)∈{T,F}2 where
{T,F}2={T,F}⨯{T,F} = {(T,T),(T,F),(F,T),(FF)}
Then:
A=x, ¬A=1-x, B=y, ¬B... |
We have two processes. One process produces F and the other process consumes F
Initialization:
Consuming = false
Produced = false
F = EMPTY
The first thread (we can think of it as some kind of producer):
P1:
loop_for_ever:
Produce(F)
Consuming = true
Produced = true
while(Consuming) {Busy Wait)
And h... |
I am master student, and I work on project with camera tracking based on sphered Infrared (IR) markers.
Now I have to implement multi-camera calibration system with a wand like this one:
And I want to find out the details of each step, understand it.
My cameras has IR filter, and it helps to discard another informatio... |
What does this sentence mean?
For all $ε > 0$, it is NP-hard to approximate MAX CLIQUE to within $n^{1 − ε}$.
Is the fact that complexity of approximation depends on $\epsilon$ hidden in the statement? I mean, if not, I guess we can make $\epsilon$ arbitrarily small, (like $\epsilon = 0.9999$), and get a very good appr... |
If I have a probability density function, some f(x) which is >= 0 everywhere and integrates to 1, is there a method to generate random numbers using that PDF?
I know there is the box-muller transform to convert uniform random numbers to gaussian, but is there anything for the general case, or at least a more general ca... |
Why is $P^{NP}\not\subseteq NP$ possible? After all we have a $P$ machine which uses an $NP$ oracle and since $P\subseteq NP$ why cannot the $P$ machine with $NP$ oracle just be replaced by an $NP$ machine?
Similarly why is not the case $P^{coNP}\subseteq coNP$?
|
I know that 3SAT is npc but i wonder why my little algorithm won't solve this problem:
given positive 3SAT - meaning: each of the m clauses is a disjunction of 3 literals over the variables x1,…,xnx1,…,xn (nn variables) and each literal is a positive appearance of a variable (no xi xi).
for example: (x1∨x3∨x7)∧(x5∨x4∨... |
I recently started learning stuff with bits and now while I was solving one problem, I started thinking what is the most efficient way to calculate $$\lfloor \log_{2}K\rfloor$$
What I started thinking
It is clear that we can calculate log in $O(\log K)$. Here is my code for example
long long a;
long long result = 0;
fo... |
I am not very familiar with "heuristic", so please correct me if anything said by me is wrong.
Per my understanding, Algorithm is an automatic steps which guarantee to give a correct solution corresponding to a specific problem (and its input domain)
Heuristic is somehow a rule to guess the next step, hoping when repea... |
I recently tried coming up with an algorithm that uses dynamic programming for the counting variant of the change problem. Given a set of target and a set of denominations, print the number of possible combinations that add up to the target. So if my target is 5 and my set is { 1, 2, 5, 10 } then the solution is 4. Mor... |
https://en.wikipedia.org/wiki/B-tree#Initial_construction
Currently I know of 2 ways for building a B-Tree : bulkloading and just inserting key after key.
In the wiki example the keys are sorted, which I guess is a condition for this bulkloading concept.
What is the advantage of bulkloading if the keys are unsorted ?
... |
The normal tsp seems way harder than the euclidean one, is the euclidean tsp np complete? If so is there a simple reduction that gives an answer to the tsp if you have the euclidean tsp algorithm?
|
Suppose I'm looking for a some unknown number $x$ in the interval $[a,b]$ under the following assumptions:
$x$ is unique.
Given any $t \in [a,b]$ I can check, at some fixed computational cost, whether $t>x$. Let's call this operation $C(t)$.
Let $\epsilon>0$ be some small number. I'm interested in efficient algorithm... |
First of all, I introduce (2,3)-satisfability:
Formulas are in CNF form, the special property is that each clause has $2$ or $3$ literals. Formula is satisfied iff only and only if there exists valuation such that:
clauses with two literals are treated normally - it sufficient to
satisfy one literal (also $2$ litera... |
Let $L=\{a^nb^n | n \ge 1\}$, then $L^\star=L^0 \cup L^1 \cup L^2 \cup L^3 \cup \dots = \{\epsilon\} \cup \{a^nb^n\} \cup L^2 \cup L^3 \cup \cdots$ .
How to find $L^2$ and $L^3$, and is $L^2=\{a^nb^na^nb^n\}$? In this video https://youtu.be/rnGpW6RRAcw at 31:51, the professor said that $L^2 = \{a^{n_1}b^{n_1}a^{n_2}b^... |
Does exist an algorithm to find all equivalence classes of given regular expression without kleene star?
If yes then what is it?
Note that alphabet of the given regular expression is binary, i.e. it contains only 2 symbols exactly.
This is important, because I can easily construct NFA from the given regular expression ... |
While there are many types of probing in hash tables, such as linear probing,
quadratic probing, and more, I haven't encountered a so-called "hash-probing" (maybe this method which I describe below exits and I just don't know its name, and if that is the case I would love some references).
This is the concept:
When ... |
I have gone through many algorithms including streaming k-means, CluStream etc and they all have their pros and cons. What is the best performing algorithm in terms of
Computational Complexity
Memory Requirement
Quality of Clusters
can handle non-static, uncertain data stream
Algorithms needs to be online i.e worki... |
Lets say we have two wooden planks each 1m long. And we want to have 4 pieces, 60cm 30cm 50cm and 20cm. Is there an algorithm for calculating the least waste? When using brute force it quickly escalates in time :(
Formally we have $N$ wooden planks each $L_1, \dots, L_N$ cm long. And we want to have $M$ pieces, $l_1, l... |
I am currently working on a computer vision problem that involve 8 convergent cameras.
I am trying to recreate a 2D image (I actually don't care of the shape of the image) that is the representation of my scene seen from the 8 convergent cameras (like an above view ?).
I am currently working with Real-time Stereo-Image... |
I have a directed acyclic graph where the nodes are tasks and the edges are dependency relations between tasks - the edges go from the dependency to the task that depends on it.
It is possible that multiple tasks depend on the same parent task and that a task depends on multiple other tasks, so it can be any DAG.
I nee... |
Given: G(V,E) DAG, vertex s, and function w: V -> R. (the weight on the vertices)
Define: We define a weighted path in G as sum of all the vertices weight.
Question: Find the heaviest path in G that starts from s. in linear time.
Well, first of all we notice it's DAG, so we can use topological sort here. and also.
My t... |
I know that in order to build i's failure link, I compare i's and j's success links:
If they are the same (if a = b), then i's failure link should point to state j + 1.
If they aren't the same, we go to the state pointed by j's failure link and do the same. (we stop when we fail at the initial state)
How do you comp... |
Specifically, we need a Turing machine that on input $1^n$ outputs binary representation of $n$ on output tape in $O(n)$ time. I am not able to get any thing better than trivial $O(n \log n)$ time. Any hints or solution?
|
Suppose we have a game where there is no good measure of how "far" the target is (that we could use to nudge the agent towards the goal via the immediate returns).
If the agent gets only -1 reward per time step and experiencing a full episode where it reaches the goal is extremely improbable (it's equivalent to just bl... |
I have a particular problem I need to solve, but I'm not sure how to classify the problem or pick the right algorithm to solve it. I'm hoping someone here can lead me in the right direction.
I've generalized and reduced the problem to this:
Given an $M \times N$ matrix with elements in $\{0, 1\}$, cover all the $1$ ele... |
What is the motivation to pick "value restriction" over other candidates?
Examples of alternatives:
Enclosing pureness into the function type, for example:
pure_function : x -> x
impure_function : x => x
Polymorphism by name (call by name) as in Xavier Leroy, 1993
Xavier Leroy, 1993. Polymorphism by name for referen... |
What is the big-O of the function $2\log(\log(n)) + 3n\log(n) + 5\log(n)$?
Is it just $O(n\log(n))$ for the whole function? I'm not sure how to represent $2\log(\log(n))$.
|
I know this question is trivial. But I am looking for a concise formal definition of $\alpha$-approximation.
Is it correct to say that "An algorithm is an $\alpha$-approximation to problem $X$, if for any instance of problem $X$ the solution returned by this algorithm is within a factor $\alpha$ of the optimal solutio... |
Assume a binary tree of height N. All nodes have exactly 2 children and all leaves have height N. For example, the following tree has N=3:
3
/ \
/ \
/ \
2 2
/ \ / \
/ \ / \
1 1 1 1
/ \ / \ ... |
i have a problem solving the recursion $T(n) = T(n-20)+log(n)$, because
the Master Theorem is not applicable in this case.
This is my attempt:
$T(1) = 1$(given)
$T(n) = T(n-20)+log(n)$
$T(n) = T(n-20-20)+log(n-20)+log(n) $
...
...
$T(n) = T(n-k)+log(n-(k-20))+....+log(n)$
Let be $ k = n-1$
$T(n) = T(n-(n-1)) +log(n-(n-... |
We use a simple uniform hash function to insert 300 keys into two tables of size 1000, we use chaining at one table and linear probing at the other. We are given that the keys were mapped into 290 different cells. What is the expected time of unsuccessful search in each case?
I think that the expected time will be 30... |
Let's say we have a binary min-heap of size $n$, and we want to get an array of the smallest $\log n$ values in the heap, sorted. What is the best complexity that we can get and how do we implement it?
The simplest solution would be using $\text{Get-Min, Delete-Min}$, $\log n$ times, and that would be of time complexit... |
I come across the following claim:
For all positive, increasing function $f$, $g$, and $h$, if we have $f(n) \in O(g(n) + h(n))$, then we can conclude that either $g(n)\in \Omega(f(n))$ or $h(n) \in \Omega(f(n))$, or both of them are correct. (We say that a function $f$ is positive and increasing, if we can get that $f... |
x = n; y = 0
while x >= b:
x = x DIV b
y = y + 1
return y
This function takes in $n,b\in\mathbb{N}, n > 0, b > 1$, and returns $k\in\mathbb{N}$ such that $b^k\leq n \lt b^{k+1}$
So far I think it is:
$b^y \leq n$
$x \leq n$
but now I'm stuck
|
I'm going through a hackerrank challenge on recursion https://www.hackerrank.com/challenges/ctci-recursive-staircase
and I'm having difficulty understanding how the solution below solves the problem. Here's the tree (the recursion calls) like you would with the fibonacci problem but I don't see the insight
With N = 3 ... |
What does connected components mean in the context of non-graphs? Graphs have vertices and the vertices are connected by edges. Hence, you can build a spanning tree (for example) by systematically joining connected components (where connected components refer to connected subgraphs).
Previous discussion on this topic ... |
I have an array of words with their coordinates in the document, I want to turn them into sentences.
For example this:
[
{
"bounds": [
{
"x": 10,
"y": 10
},
{
"x": 15,
"y": 10
},
{
"x": 15,
... |
Problem statement: You are in an infinite 2D grid where you can move in any of the 8 directions :
(x, y) to
(x+1, y),
(x-1, y),
(x, y+1),
(x, y-1),
(x-1, y-1),
(x+1, y+1),
(x-1, y+1),
(x+1, y-1)
You are given a sequence of points. Give the minimum number of steps in which you can cover all of them. You st... |
Let's consider the language over $\{0,1\}$ containing such words $w$ that:
$$w = m_1m_2..m_n $$ where $m_i$ has length $n$. (so $|w|=n^2$) and $$m_1 + m_2 + .. + m_n \mod 3 = 0$$
($m_i$ we interpret as binary encoded number).
Prove, that the language is $NC^1$ class.
The first problem is: How to decide whether $m_... |
i have to calculate the asymptotic runtime of a nested sum:
Sum $\sum_{n=1}^{log_{4}(n)} \sum_{n=1}^{\sqrt{n}}1$
My solution is $\Theta(log(n) \cdot \sqrt{n})$, which is wrong, because the solution says $\Theta(\sqrt{n})$. I dont understand where my mistake is:
Sum $\sum_{i=1}^{log_{4}(n)} \sum_{j=1}^{\sqrt{n}}1 = \su... |
I believe that in the general case stable matching for 3 members rather than 2 is NP-Complete, but I wonder if in my case there's something that I am missing that could have reasonable time complexity.
The specific purpose of the program I am trying to write is to take an arbitrary number of objects and split them int... |
I read that system being in safe state doesn't guarantee that deadlock is not possible.
Can someone give me an example where system is in safe state and deadlock is possible?
|
I'm looking for a small function from integers to integers - in a language that only has floats - that can act as a visual RNG. Normally I would use a function such as the one described here:
int cash(int x, int y){
int h = seed + x*374761393 + y*668265263; //all constants are prime
h = (h^(h >> 13))*1274126... |
Given a hash function $H:\{0,1\}^*\rightarrow\{0,1\}^n$, a difficulty $d\in\mathbb{N}$, and data $D\in\{0,1\}^*$, the framework of the Hashcash/Bitcoin Proof-of-Work entails finding a nonce $c$ such that $H(c\Vert D)$ starts with $d$ zero’s. That is to say, Hashcash/Bitcoin Proofs-of-Work appear to find a preimage $c\... |
Suppose I want to find the numbers that appear in at least 3 of the 10 sorted lists, is there an efficient way to do it apart from iterating over all 10 of them in parallel?
|
I am contemplating the project of writing a compiler. I am wondering if, aside from the availability of easy google results, it is easier to write a compiler for a more explicit/verbose language such as ada, compared to a very compact language such as APL, for example.
I should add that i am especially interested in wh... |
Can the HTML5 parsing algorithm (https://html.spec.whatwg.org/multipage/parsing.html#parsing) be implemented in $O(n)$, or at worst $O(n\mathop{log}n)$, time, even for malicious input? It seems difficult; there appear to be places where a malicious document could force the user agent to perform $O(n)$ traversals $O(n)... |
I am wondering if a pair prefix/AS may change often ?
I mean let's say we have a list with many given prefixes (e.g. 4.6.20.0/24) that are mapped to ASN (e.g. 10753), this list is built on a given date. The question is, should we expect that several prefixes are mapped to other ASN in a list built few days later ?
I ... |
The class DP is defined as the set of all languages $L$ such that $L = L_1 \cap L_2$ where $L_1 \in NP$ and $L_2 \in coNP$.
For example, the language SAT-UNSAT is defined in the following manner ($\varphi$ is a $3-CNF$ formula):
$\{( \varphi, \varphi'): \varphi \in SAT \wedge \varphi ' \in UNSAT \}$. This language is t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.