instruction stringlengths 35 29.1k |
|---|
Edit Jan 31: important special case is when the sums form a nested structure, search for "Hasse diagram is a tree" below
Here's a practically relevant variation on matrix chain problem:
Find optimal way to compute a sum over all weighted paths in a graph, where the weight of each path is the matrix product of edge labe... |
I have a homework task to show that $\mathrm{TILING} = \{(T, 1^N) \mid \text{it is possible to cover } N \times N \text{ square with tiles from }T\}$, where $t\in T$ is $C^4$ for some color set $C$, is NP-complete.
It is not hard to show that $\mathrm{TILING}$ is in NP.
How can I show that it is NP-Hard? Can I reduce s... |
I'm currently trying to show that the language $L_2=\{0^n \text{ } | \text{ } n=2^k, k\geq 0\}$ is not regular by using the Pumping Lemma (at least I think it is not regular, because I couldn't find any regular expressions or DFA for it). I know all the steps that I need to go through, but I am having a very hard time ... |
For a formal problem statement, I quote from the text Introduction to Algorithms by Cormen et. al
Suppose we use a hash function $h$ to hash $n$ distinct keys into an array $T$ of length $m$. Assuming simple uniform hashing, what is the expected number of collisions? More precisely, what is the expected cardinality of... |
Suppose we are given n open intervals $(a_1, b_1), ..., (a_n, b_n)$, with interval $i$ being assigned a weight $w_i$ for all $i$. Define a "good subset" of intervals to be a subset of those $n$ intervals where each pair of intervals in the subset overlap (i.e. share a common value). Given an integer $k<n$, we would lik... |
I'm learning assembly programming and I can't seem to get my head around the register usage, as I'm using emu8086 which emulates old 8086 processors.
According to 8086 (16-bit architecture) the four General Purpose Registers are:
My confusion is: why does using DL and DH give different results, as they both are the lo... |
Suppose we are given $n$ open intervals $(a_1, b_1), \dots, (a_n, b_n)$, with interval $i$ being assigned a weight $w_i$ for all $i$. We are given an integer $k<n$, and we are allowed to choose $k$ arbitrary numbers. Suppose an interval is covered if it contains one of these $k$ numbers. With an $O(n\log n)$ algorithm,... |
So, I have an issue with the following problem (CS 161 Stanford 2013, Problem Set 2):
Suppose that you have found a collection of historical records indicating the relative order in
which various people lived and died. Each record tells you one of the following:
• Person A and person B were alive at the same time.
• Pe... |
Suppose that I have a 2D array $B[i,j], 1 \le i,j \le n,$ such that $B[i,j]=X$ or $B[i,j] = O$. I want to write a program to check if there is a path that exists from $B[1,1]$ to $B[n,n]$ that only consist of $O$'s. The path must only consist of the 4 directions: North, South, East, West and does not include the diagon... |
If you created two very large numbers represented by binary data (perhaps using sha512 with random input for each hash) could you determine what binary block is numerically larger by iterating over bytes from left (largest bit) to right (smallest bit)? If at any point the left has a 0 bit where the right has a 1, you’d... |
I just completed a Data structures and Algorithms course in my university. I know how data structures work and how different DS are used to solve specific and to improve efficiency. I have also started to work with databases to develop CRUD applications.
My question is: If I have to for example, use a tree data structu... |
I'm trying to understand how you compare the following for order of growth.
With the below working out with $f_4$ I don't get where the $x^5$
and $x^6$ come from at the end. With $f_4$ you have $n^{\log n}$ when
for example $\log 64$ doesn't equal 6? Can someone please explain where
$x^5$ and $x^6$ come from?
Working ... |
Why is option "(C) $n^{1.98}$ is $O(n^2)$" the question below correct? Is it because "Big $O$" is upper bound meaning worst case, therefore $n^{1.98}$ is not worst case $n^2$ ?
How is it still $O(n^2)$? Wouldn't it have to be equal to it, not $.02$ less?
Secondly, regarding (A), how do you work out if $2^{20} n$ is $O(... |
Suppose that matrix A is a symmetric positive definite matrix over the integers, i.e., $A \in Z^{n\times n}$, if B is a matrix over the real numbers, it is not difficult to find B such that $A = B \cdot B^T$. However, if B is restricted to be an integer and square matrix, in general, there is no solution. It is known t... |
I am asked to find a probabilistic algorithm to determine the size of the maximum matching of an arbitrary simple undirected graph $ G $.
My claim is that, it is equivalent to find a global min cut on $ G $ (where each edge had capacity 1). To find that, I can output all $n \choose 2$ min cuts, determine the longest an... |
I have a set of numbers and I want to find the sums of all possible pairs of elements. With the set $\{1, 2, 3\}$ for example, I would want $\{1+2, 1+3, 2+3\}$ as my answer. I could do that in n^2 time complexity by starting at the first element and adding all the other elements to it one-by-one and then moving to the ... |
"Introduction to algorithms" also known as CLRS, proves the correctness of the algorithm to compute the Strongly Connected Components in two ways, one of which is
Here is another way to look at how the second depth-first search operates. Consider the component graph $(G^T)^{SCC}$ of $G^T$. If we map each strongly conn... |
I was told that the runtime of OCAML or Scala is EXPTIME - which seems really bad! However, since people use type inference (deciding the type of a term or program or expression) in practice - it must be fine in programs humans write somehow.
I was looking for an official reference for such a facts - especially in the ... |
I am talking in reference to this question from this compiler test. I think it is actually true that a GOTO and REDUCE can't be present in the same set, but am having a hard time coming up with an example or counterexample.
Pls provide and example and explanation to make me understand.
https://gateoverflow.in/299820/Go... |
We are given that the following algorithm finds the vertices inside a negative cycle and we need to show an example for it such that it fails.
for each v in V
dist[v] = inf+
dist[s] = 0
for i=1 to |V| - 1
for each (u,v) in E
relax(u,v,w)
for each v in V
dist'[v] = dist[v]
for i=1 to |V|
for each (u,v) in E... |
Given points $x_1, \ldots, x_n$ in the Euclidean space and $K \in \mathbb N$, I'm interested in the following objective.
Partition the points into $K$ clusters $C_1, \ldots, C_K$ so that:
$$\max_{i \in [K]} \frac{1}{|C_i|}\sum_{j \in C_i} \|x_j - \mu(C_i))\|^2$$
is minimized, where $\mu(C_i) = \frac{1}{|C_i|} \sum_{j \... |
Looking for any idea for reduction from $SAT \leq 3-SAT$ where $SAT$ is known to have $d$ variables at most in each clause. I am looking for a reduction in which the resulting formula will not depend on the value of $d$. The classical reduction adds $O(d)$ new variables per clause, so this is not good to my case.
Do su... |
Suppose given $T= a_1\leq a_2\leq\dots\leq a_n $ that $a_i$ is real
number and given a number $k$. we want to find $k$ triples $x_i\leq y_i\leq z_i\in T$ such that
$$\sum_{i=1}^ k (y_i-x_i)^2$$ minimized, also each $a_i$ can belong to at most one triple.
How we can solve above problem in $O(nk)$? I think it's possib... |
Here is the full version of the problem I'm dealing with.
Let $G=(S,T;E)$ be a bipartite graph and let $X$ be one of the two classes of its bipartition (i.e., $X \in \{S,T\}$). For a subset $C \subseteq X$ we define: $$\sigma(C)=\min\{0, |N_G(C)|-|C|\},$$ where $N_G(C)$ is the neighbourhood of the subset $C$ in $G$) (... |
In digital signatures, the private key is used to encrypt a (hashed) message and the public key is used to decrypt it. This made me wonder since the receiver has the cipher text (digital signature) and can easily reach the original plain text— by decrypting the digital signature using the sender's public key— if there ... |
I've seen the classical proofs of CFLs are not closed under intersection or complement, but I haven't been able to wrap my head around this. Intuitively, I think that this would be not a CFL but I can't think of any counterexamples.
|
Given a full binary tree with 256 leaves and depth <= 64,
let H be the set of Huffman codes described by the tree (using 0 to go left, and 1 to go right, where the most significant bit represents the move from the root node
e.g. "100" means that starting from the root, we head right, then left, then left
transform ... |
What's the sum of heights of a random binary search tree?
By a random binary search tree, I mean the usual definition: you have $n$ keys to be inserted, and all Permutations are equally likely.
The sum of heights is the sum of the heights of each node. similar to Sum of heights in a complete binary tree (induction)
My ... |
The standard LP gap example for the held karp relaxation for TSP
min $ c^tx $
$x(\delta(S)) \geq 2 $
$x(\delta(v))=2 $
$x \geq 0$
Is to have two triangles and three long paths connecting the corresponding vertices yielding a 4/3 integrality gap example.
Does this not work for Euclidean TSP? I saw this paper here ... |
Let $R = \{\emptyset,a,\epsilon\}$ (the elements here are regular expressions) and let $+$ be the or operation, which can be applied over the regular expressions of $R$. Is $(R,+)$ some kind of an algebraic structure, such as a subgroup, a monoid, or a group?
I was told that it is monoid and that $(a+\epsilon)=a$, and ... |
CAN SOMEONE FIND A BETTER (MORE DESCRIPTIVE) NAME FOR THIS QUESTION, THANKS
I recently thought of this interesting Tree problem:
Given a tree with $N$ nodes, let $val_i$ = the "value" for each node. Process $Q$ queries of two types: the first consisting of a single node $i$. For this type of query, $val_j += dist(i, j)... |
Here's a simple question but I'm not sure there is a simple answer. This came up in an undergraduate algorithms class.
Consider the following divide-and-conquer algorithm $A$ (here, $x_1, \ldots, x_n$ are bits; assume $n$ is a power of 2 for convenience):
$A(x_1, ..., x_n)$:
if $n=1$ then return $x_1$
Else return $A(x... |
I remember learning in a class that type inference is decidable but usually takes a long time (e.g. type inference in OCaml is EXPTIME).
I was wondering, since Coq allows programs/values themselves to be in the Type somehow my guess would be that type inference is either:
Doubly EXPTIME
Undecidable
Does someone know ... |
Here's a problem that uses graph to find task assignment among a group of workers. Assume there are N number of tasks to be completed, with dependencies among the tasks. For example, task i depends on task j, which depends on k, etc. A directed graph can be used to model this, G = (V, E), where the Edge (a, b) implies ... |
I have a set of $n+\binom{n}{2}$ random variables $\{x_i\}^{i=n}_{i=1}\cup \{x_{ij}\}_{i\leq j}$ and their probability distribution is given as:
$$P(x_1,...,x_n,x_{12},...,x_{ij},...x_{nn}) = \prod_{i}P(x_i)\prod_{i\leq j}P(x_{ij}|x_i,x_j)$$
Now, this can be represented as a bipartite Bayesian Network with the followin... |
I have a server. It has e.g. one million documents. My website has a spreadsheet. Each page has space enough for e.g. 50 rows. As I scroll down, I will want to request the rows from the server, and I will cache the range I asked for in memory.
However, if I scroll up again (or place the scrollbar arbitrarily), I only w... |
I have an undirected graph $G=(V,E)$ and I want to find an ordering of $V$, $\pi=(v_1, v_2, ..., v_n)$, such that for each $1 \leq i \leq n$, $v_i$ is of minimum degree in the subgraph $G_i = [\{v_1, ..., v_{i-1}, v_i\}]_G$ in $O(n+m)$ time, where $n=|V|$ and $m=|E|$. I also have to prove that if $G$ is a tree, then a ... |
Given the address 00011001111011101111101011011111 and it save a value
0x1FA0CBB7. Calculate the memory size in KB
What i try: the address has 32 bits so the memory size is 2^32 = 4294967296 bytes but then i wonder so the value 0x1FA0CBB7 for what ? I'm not sure i'm doing right.
Can someone help me solve this problem... |
A problem : Given a string of number in base $10$ we want an algorithm to calculate the number of numbers, where we replace (only) a single digit to produce a number so that that number is divisible by $3$.
example of input and output:
If the input is "23", the algorithm should produce an output $7$ since all the numb... |
This is a really short question and a straightforward one for anyone who knows the subject well. But its also super specific, so I can't find the answer online.
I know a program counter is saved when a context switch occurs. I can't seem to make sense of how this could happen in software. In order for the CPU to run th... |
I have a problem and I'm not sure where I am going wrong with this, description
so as you can see it is given a 3 level paging system with 8 bit page index on every level, now I break down logical address as ( 8+8+8+12 ) first 24 bits being page no bits in logical address space, and 12 being page offset bits, with tha... |
We often hear about some algorithms' running time that is polynomial, and some algorithms' running time that is exponential.
But is there an algorithm whose time complexity is between polynomial time and exponential time?
|
"We cannot recognize a set of languages as the language themselves"
What is the meaning of the line and why we cannot do it and how is the encoding of TM is helping in that?
|
I have a set of parameters $\{\alpha_s\}$, and I have $u$ functions of the form $w_i(\{\alpha_s\}) = \prod\alpha_s^{c^{i}_s} $ for some known values of $c^{i}_s$. Similarly, I have $b$ functions of the form $w^{ij}_l(\{\alpha_s\}) =\prod\alpha_s^{c^{ijl}_s} $. Now I
the following optimisation problem to be solved:
$$\t... |
I'm having trouble understanding the simplification of the following regular expression
\begin{align}
R = ε | 1 | (ε | 1)(ε | 1)^*(ε | 1) = 1^*
\end{align}
In my lectures only the simplified solution was given but not the steps. I tried on my own but only came this far:
\begin{align}
R & = (ε | 1) | (ε | 1)(ε | 1)^*(ε ... |
I'm looking for some algorithms/patterns to solve a distributed systems problem.
Lets say I have created a trading platform buying stock (I haven't), and I have a distributed system of 50 nodes that are making these purchases for me. I also know that I have a budget of $50k, and it needs to be spent by the end of the ... |
The halting problem is $RE$ complete. With an oracle for the halting problem could you decide problems in $co RE$ with an oracle for RE?
|
We are given a flow network $G = (V,E,c)$, where $c$ is the capacity function as well as a maximum flow $f_m: E\rightarrow \mathbb R$ from $s$ to $t$. The goal is to find edges such that if decreased by one unit, the value of any max flow decreases as well. The time complexity should be $O(VE)$.
I found this question i... |
Is there a way of generating random isomorphic graphs for the purposes of testing tools like Nauty or BLISS? Every paper I've found says the authors had a database of certain isomorphic graphs, but I don't know how they constructed them or where I find test sets for graph isomorphism algorithms. I expect the answer to ... |
I particularly have a problem creating DFAs for multiples of larger numbers like 10, 11 ,12 etc. but I can create simple ones like 1, 2, 3 etc.
Even more so, I have a problem creating a minimized DFA for these problems. I think if a DFA has 10, 11 or so states, minimizing it properly could take a long time as there can... |
For example for the traveling salesman problem which is a proven NP-Complete problem, if we spawn a thread at each node in the graph such that each of those threads will, in turn, spawn as many threads as needed, would this work as a simulation of Non-deterministic Turing machine. Are there any theoretical gaps in this... |
Recently i wrote a programme using random module of python. Then i realised that the same output was being repeated quite a number of times though it was supposed to be completely random.
|
The subset sum problem is as follows:
Given a sequence of integers $\mathcal S=(a_1, ..., a_n)$ with cardinality $n$ and an integer $T$, determine whether there is a subsequence of $\mathcal S$ whose sum equals $T$. Denote this problem $SSP$.
I was given a variant of the subset sum problem:
Given a sequence of $\col... |
I'm stuck with the following problem:
Given an n*m board, find the maximum number of square groups that can be positioned on the board.
What are square groups?
They contain 4 distinct squares named: a, b, c, d
a should be the neighbor of b
b should be the neighbor of c
c should be the neighbor of d
Two squares are con... |
I'm confused with polynomial-time reduction and NP-hardness.
Let's say that the following integer programming is NP-hard.
$\min_{x \in K} f(x)$, where $K$ is a finite subset of $\mathbb{N}$.
But it is a special case of the following linear programming.
$\min_{x \in X} f(x)$, where $X$ is a compact subset of $\mathbb{R}... |
Question:
Ackermann Hierarchy defined as following: $$A_{k}(n)=A_{k-1}^{(n)}(1), \ k\geq2, \ A_1(n)=2n$$
In addition, Ackermann function defined as following: $$A(n)=A_n(3)$$
A. which of the following grows faster to infinity? $A_7(A_4(n))$ or $A_4(A_7(n))$.
B. suppose we want to find a function that grows faster tha... |
On wikipedia it says that $BQP ⊆ EXP$. However it is not known if $BQP \subset EXP$ Also I've seen that $PSPACE$ could contain $NEXP$ and does contain $BQP$. For this were assuming the incredibly unlikely scenario that $BQP = PSPACE = NEXP$. What would the implications be? I assume this would render P vs NP completely ... |
Consider the following basic problem, for which the statement is "obvious," but I can't seem to find totally convincing proof.
Problem: Let $S$ be a set of $n$ elements, where $n\geq 2$ is even. And let $f:S \rightarrow \{0, 1\}$ be a function that maps half of the elements in $S$ to $0$, and the other half to $1$. S... |
i need to convert this CFL to CFG
$$ L = \{\; 1^n 0^m 1^k 0^p \mid n\ge 2, k,m,p\ge 1, n+k=m+p\;\} $$
I am trying to solve this problem for a few days but i couldn't. Is there anyone to help me? I'm gonna blow my mind..If somebody can help i will be so grateful..
|
I was wondering if I could say any of the following is true.
Given a grammar $G$,
If the LALR parser has reduce-reduce conflict for $G$, then the SLR parser also has reduce-reduce conflict for $G$.
If the SLR parser has reduce-reduce conflict for $G$, then the LALR parser also has reduce-reduce conflict.
The LALR pars... |
I have to design a PDA that recognizes the language $\{a^nb^m \mid 0<n\leq m\leq3n\}$
I tried to partition the stack into 3 partitions with the first partition being the size of $n$ with character A, the second partition being the size of $2n$ with character B, and the third partition size of $n$ with character A.
I go... |
I'm trying to prove that the following language is L-complete
A is a language where each word is comprised of 0s and 1s & the number of 0's is double that of the number of 1's
So far I've managed to show that it can be solved in log space using a counter that adds 2 for every '1' and deducts 1 for every 0.
I need to pr... |
New to tsp and christofide algorithm pls help
What if instead of using a spanning tree as described in christofide algorithm we use two or more intersecting circles of the input points to determine shortest distance?
Suppose we have 5 points, we draw 5 circles around them of same radius as per the choice of the user an... |
I am taking a course on Eductive on System Design and I read about the ways the data can be partitioned amongst DB servers. See the snippet below:
b. Hash-Based Partitioning: In this scheme, we take a hash of the object we are storing. We then calculate which partition to use based upon the hash. In our case, we can ta... |
It is well known that "regex" with back-reference is not a regular expression anymore.
For instance, (.*)\1 matches any string repeated twice.
However, is it possible to construct a DFA for regex with lookaround?
I found this question and particularly this answer, which says
Look-ahead and look-behind are nothing spec... |
In my computer graphics course I came across this "pro" for point clouds:
Useful for large datasets (>> 1 point / pixel)
I'm trying to wrap my head about it, I know drawing is expensive, but, it somehow counterintutive to me that for larger datasets having to store more points is more efficient?
Why wouldn't it hold ... |
From the wiki this is the algorithm and we know that final complexity is O(n) but how we reached to this , is my problem :
algorithm welzl is
input: Finite sets P and R of points in the plane |R| ≤ 3.
output: Minimal disk enclosing P with R on the boundary.
part 1: if P is empty or |R| = 3 then
... |
I was reading the paper "Kou, L. T., Stockmeyer, L. J., & Wong, C. K. (1978). Covering edges by cliques with regard to keyword conflicts and intersection graphs. Communications of the ACM, 21(2), 135-139" and from what I understand, they prove that SET-ECC is NP-complete by constructing a graph G' and showing that (G, ... |
I'm reading the book Cracking the Code.
The answer for this question suggests a solution using timestamps and two separate queues. This is straightforward and involves simply enqueuing into the appropriate queues. Dequeuing oldest involves checking timestamps of front of both queues and removing the oldest.
I'm wonderi... |
I have a sequence of source files that are very similar (akin to frames in a video), and each file can be compressed by a codec independently, but there is no temporal compression.
I want to further compress the data by exploring the temporal correlation, but I don't know how to do that with the source files. However, ... |
I'm trying prove the correctness of my algorithm.
This is the problem in codeforces: https://codeforces.com/contest/1428/problem/C
Here's my code in C++ which was accepted:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
int num, ans, top;
string s;... |
Suppose that the stop-and-wait protocol is used on a link with a bit rate of 64
kilobits per second and 20 milliseconds propagation delay. Assume that the transmission time for the acknowledgment and the processing time at nodes are negligible. Then the minimum frame size in bytes to achieve a link utilization of at le... |
I'm new to Linear Programming and trying to create an automated scheduling algorithm, and am having trouble defining the objective function and decision variables. Any help would be appreciated:
Let there be E employees who need to be assigned to K types of shifts distributed over N days. Each shift K has an associated... |
In the (unlikely) event that $P=NP$ with a constructive proof of a polynomial time algorithm that solves 3SAT, obviously things will be very different. However, practically, it could happen that the degree of the polynomial run time is very large (e.g. $\Omega(n^{10000})$) such that any reasonably large problem is stil... |
What types of logic should one study as foundation before diving into the area of software verification? What I can think of are:
Hoare Logic (for proving correctness of imperative programs)
Linear Temporal Logic (to model-check programs)
What can be others?
|
So I've been reading Sipser's theory of computation book, and I've come across the pumping lemma for context-free languages, which as a reminder says that if a language is context-free, then there is some length p such that all strings longer than p can be represented in the form
$s = uv^i x y^i z$
and be pumped and re... |
I've got this question that asks me to make changes to the 2-3 trees that would make it possible to do a find(x) function that would find x with O(log(rank(x))) .
**rank(x) is x's index in a sorted sequence of all of the values of the tree. However we have to still do insert(x) and delete(x) with O(log(n)).
So I though... |
It is know that the Gabriel graph of a point set $P \subset \mathbb{R}^2$, $\mathcal{GG}(P)$ is a subset of the corresponding Delauney graph $\mathcal{DG}(P)$, i.e. $\mathcal{GG}(P) \subseteq\mathcal{DG}(P)$.
A Gabriel graph is defined as:
The Gabriel graph $\mathcal{GG}(P)$ of a point set $P \subset \mathbb{R}^2$ is... |
I have a question. I read many blogs, websites about CAP theorem. They say that single-node systems are CA, but how can it be "A" if that single node goes down ? Because if it does, the system will be unavailable, right ? And is "availability" in CAP equal to "availability" in HA of distributed systems ?
|
I have a 0-1 integer linear program for a set of $2n$ variables $S = \{x_1, ..., x_n, y_1, ..., y_n\}$. My objective is to maximize the number of pairs $(x_i, y_i)$ such that $x_i = y_i$, $i = 1, ..., n$.
$$
\max \sum_{i=1}^n \mathbb{1}(x_i = y_i)
$$
where $\mathbb{1}(x_i = y_i) = 1$ if and only if $x_i = y_i$, $i = 1,... |
Description
The task is to identify repeated patterns in a string and do lossy compression of the input string using the found patterns. The output is a list containing different ways of encoding the string (information loss VS description length).
For simplicity, I'll be using a binary string, though the solution shou... |
The PARTITION decision problem is defined as follows (taken from COMPUTERS AND INTRACTABILITY from Garey and Johnson):
Instance: A finite set $A$ and a size $s(a) \in \mathbb{Z}^{+}$ for each $a \in A$.
Question: Is there a subset $A' \subseteq A$ such that
$$
\sum_{a \in A'} s(a) = \sum_{a \in A \setminus A'} s(a).
$$... |
Suppose we have a sequence of $m$ tokens $(T_1, T_2, \ldots, T_m)$. We can split this sequence considering two parameters $w$ (which is the width of the window) and $x$ which is the overlap between windows. This is depicted in the following figure:
Now, suppose we have the function $f$ which takes as input a window an... |
So I basically had an exam question in which we were given a problem and we had to prove or disprove that it was in NP-complete. I tried to prove it but could not because apparently it could not be proved.
In the solution that the instructor sent us, they proved that we cannot prove that this problem is in NP; therefor... |
A binary image is encoded as a sorted array of non-overlapping runs, which represent value 1. Each run is defined by $r$, $c_s$ and $c_e$, with $c_s \leq c_e$. These are the row, starting and ending column coordinates of the run, inclusive. The runs are sorted by row then column. The image contains $N$ runs.
I want to ... |
Requirements:
Given a 2D array of 1's and 0's (black and white cells) find blocks of white cells of size 1xT or Tx1 where T >= 1. Any block should not be a subset of a larger block.
Return the number of these blocks.
This is an example solution of a 5x3 grid. There should be 8 blocks. Block y:1, x:0 is not a block b... |
Let L be a language of pairs $\langle R,G\rangle$, with the first element being a regex and the second being a CFG.
Is it decidable that G accepts whatever the regular expression does? In other words, is it decidable to say if $L(R)\subseteq L(G)$?
|
I know, the inner loop here is O(log n). But, I get confused by the multiplication in the outer loop part.
for (int i = 1; i <= 5*N; i++) {
for (int j = 1; j <= 1000; j = 2*j) {
doSomething(i, j);
}
}
The correct answer to the question is, O(N) with regard to: how many times does the function doSomething() r... |
Why do we use a private IP address instead of using the MAC address in a local network?
It makes sense that we have IP addresses for large networks where packets have to be routed because the IP address is location-dependant. Meaning routers can just route a packet to a location. But if routers had to route a packet t... |
There are many efficient algorithms for finding the shortest path in a network, like dijkstra's or bellman-ford's. But what if the weights of edges are time-dependent? I'm trying to find an efficient algorithm to find the path of graph with the lowest cost, where weights of edges depend on what time the edge is being w... |
I know that an existential type $ \exists t. t $ can be represented using universally quantified types as $ \forall r. (\forall t. t \rightarrow r) \rightarrow r $ and I have some basic intuition for this result. I wanted to try to derive this representation by hand to gain more understanding of it. I tried the followi... |
I looked at all possible options for $vx$ when you look at $z = uvwxy$ and can't find a contradiction in the case where $b$'s and $c$'s are in $vx$.
|
Suppose I have a graph $G=(V,E)$, where each edge $e$ has both a non-negative length $\ell(e)$ and a non-negative cost $c(e)$. Given a start node $s$ and a destination node $t$, I want to find a set of Pareto-optimal paths $s \leadsto t$. In other words, for each budget $b$ in some set (say $\{0,1,2,\dots,B\}$), I wa... |
I'm looking for an example of a randomized algorithm that halts with probability 1 (halts almost surely), uses only logarithmic space (worst case) and whose expected run time is not polynomial in the size of the input.
|
Link to the problem: https://codeforces.com/problemset/problem/1221/A.
The problem:
You are playing a variation of game 2048. Initially you have a
multiset $S$ of $n$ integers. Every integer in this multiset is a
power of two.
You may perform any number (possibly, zero) operations with this
multiset.
During each opera... |
I am working on a uni project, for which i will model synthetic electricity consumption time series using Markov-Chains. I am reading through current academic literature on that topic and came across an interesting paper (link below).
The authors use a 24x24 probability matrix for the different states that a household ... |
Let $v_i, s_i$ be the value and size of item $i$, let $\rho \in \mathbb{R}$, n be the maximum number of items. Then we add items based on $\frac{v_i}{s_i^{\rho}}$ in decreasing order. I was trying to understand a proof in a paper, but I get stuck at some points. The utility function $u_{\rho}$ is the value of items sel... |
I just read the definition of lambda calculus. Apparently it's Turing complete, but I tried writing a very simple function and I couldn't:
f(a)=b
f(b)=a
f(x)=x otherwise
so it just swaps the variables a and b.
Functional languages already have conditions which makes it easy, but how do you do it using only abstraction... |
I'm doing this problem https://leetcode.com/problems/maximum-alternating-subsequence-sum/ and attempting to change my code to use a matrix/array. I'm unable to figure out what the dimensions are. Drawing it out hasn't made it clear for me either and I think I'm missing a core concept or the recurrence relation. As far ... |
List $[E1,E2,...,Ek]$ in lambda expression can write as
$$λc.λn.cE1(cE2(...(cEkn)...))$$
Based on this, how to define head and empty lambda expressions
So that
$head[M..]$
can be beta reduce to M
and
$empty[]$ can be beta-reduce to True
$empty[N..]$ can be beta-reduce to False
So far I only figured out the True and Fal... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.