instruction stringlengths 35 29.1k |
|---|
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... |
I am learning the Theory of Computation, and I came across the language $\Sigma^n$. Could someone please explain what that could mean if $\Sigma$ is the alphabet?
Thank you so much!
|
I'm trying to get CFGs for these two languages which still remain unsolved in my practice problems sheet:
$L = \{ a^kb^ra^m | m=k+r\}$
$L = \{ a^nb^m | 1\leq n\leq 2m\}$
With the first one, I thought of this:
$$S\rightarrow aSa | T$$
$$T\rightarrow b T a | \epsilon$$
but what if $k>r$ or $r>k$?
With the second one, I t... |
I am not able to find out the time complexity of the Leiden Algorithm. Can anyone here help me?
https://doi.org/10.1038/s41598-019-41695-z.
|
I need to find the Myhill-Nerode equivalence classes for the language $$ L = \Sigma^*\setminus \left( \{\epsilon, cc \} \cup \{ cca^i: i\geq 2 \} \right) $$ over $\Sigma = \{a, b, c \}$
I'm familiar with the idea of separating suffix, but I really don't know where to start here.
Thanks!
|
So I was wondering if there is a way of reading process memory of one device on another. So lets say a process is running on computer A, I then use some form of connection lan, pcie etc. Once the two computers are connected. Would it be any way possible to then, say open something like cheat engine and read process mem... |
According to this recursion formula for dynamic programming (Held–Karp algorithm), the minimum cost can be found. I entered this code in C ++ and this was achieved (neighbor vector is the same set and v is cost matrix):
recursion formula :
C(i,S) = min { d(i,j) + C(j,S-{j}) }
my code :
#include <iostream>
#include <ve... |
Imagine you have a matrix m of dimension MxN
What I'm trying to do is get a set of elements (of length N*(N-1)/2) of the diagonal elements (each of whose individual length would be M) of the outer product which is formed by every possible pair of columns within the matrix m
For instance, I would take outer product of ... |
I'm relatively new in machine learning and I am trying to put together my undergraduate thesis on masked face recognition.
I've read Ejaz and Islam's paper (available at https://www.researchgate.net/publication/340690545_Masked_Face_Recognition_Using_Convolutional_Neural_Network) about feature extraction using FaceNet ... |
I'm reading Computer Organization and Design MIPS Edition 5th Edition The Hardware/Software Interface on how memory cache works. I came across the following paragraph on page 393;
The other key aspect of writes is what occurs on a write miss. We
first fetch the words of the block from memory. After the block is
fetche... |
Consider a bipartite graph G=(U+V,E) and suppose |U|=|V| and that G has a perfect matching. Therefore by P. Hall's condition, for every subsets A of U, the neighborhood N(A) of A has size at least |A|.
I am interested in subsets A for which N(A) has the same cardinality as A. Do they have a name?
It seems that any perf... |
I would like some help for the computation theory.
There is a PDA that accepts the language $\{0^n 1^a 2^b \mid n = a+b\}$, so how can I express it into context free grammar? Any help would be appreciated!
That's what I was trying, I am not sure if it is correct or not
S -> 0SA | 0SB | empty
A -> 1
B -> 2
|
For example, if I have 11X1111X as input, the result should be X. For another example, input: 1111XX -> 1111X. I am a complete beginner and all my tries so far failed to meet the expectation.
This was my latest try:
|
I am trying to solve some questions on partial decidability of languages and I am getting confused in how to construct proper arguments through the idea of Universal Turing Machine.
I am not posting my questions here, so I would like some examples showing a certain language is partially decidable with a proof.
|
I am trying to understand the No-Free-Lunch-Theorem for search (can be found here: http://axon.cs.byu.edu/~martinez/classes/678/Papers/Wolpert_NFLsearch.pdf) and have a question regarding the assumptions that were made by Wolpert et al. with respect to the "general nature" of a search algorithm.
In the paper, the follo... |
With Given Graph $G$ why finding that $G$ has a vertex cover of at most $4$ is in $P$ and Not in NP Complete. it means there us poly-time algorithm for this problem !!?
|
I read in my notes:
If we use Dijkstra $|V|$ times ($|V|$ number of vertices) for finding all-pairs shortest paths in graph $G$, we get time complexity for Dijkstra algorithm as $O(VE+ V^2 \log V)$, and if we run Bellman–Ford algorithm $|V|$ times, we get time $O(V^2E)$.
The above details are not important.
I read to... |
I wonder if there is a formal definition of lexical scope so that people can prove things with respect to it, for example, that an interpreter implements lexical scope. You may ask what level of formality I am talking about. For example, I deem the usual definition of the free variables of a lambda term formal: a varia... |
The Problem (in words)
I want to sort $N$ items where the value of item $i$ at position $p$ is given by the function $f_i(p)$. The "best" order for these items is the one that maximizes the total value of my items but I am willing to accept a "good" order if it means finding it quickly.
The Problem (in maths)
Given $N$... |
Here's the problem: I have some $n$ ordered containers, each with $m$ slots. I have $p$ temporary slots that I can use to move items between containers. Sorting within containers is not costly, however moving items between containers is, so the more temporary slots that can be used to move items between containers, the... |
In the CLOSEST STRING problem, one is given (bit-)strings $s_1, \dots, s_t$, each of length $L$ and an integer $d$. The question to be answered is whether there exists a string $s$ that has hamming distance to each $s_i$ that is at most $d$.
In this paper, the authors show that (assuming ETH) the problem cannot be solv... |
Quick question:
Say for example there are 10 colinear points. my question is does a convex hull have to be a convex polygon? or can it be a line as well according to the formal definition of the convex hull?
Thanks in advance.
|
I would like to know if there is any reason why many programming languages use the notation % for the modulo operator?
It is used in the most "famous" languages:
C
C++
C#
Go
Java
Julia
Lua
Perl
Python
|
Hi I am wondering if L is a CFL and R is RL then would the difference R - L be a context free language?
The difference might be the CF part of the language left then it would be, but I'm not sure how I could go about proving this without giving an example
|
I have a question about the Floyd Warshall algorithm. Here is the code from the Wikipedia page:
let dist be a |V| × |V| array of minimum distances initialized to ∞ (infinity)
for each edge (u, v) do
dist[u][v] ← w(u, v) // The weight of the edge (u, v)
for each vertex v do
dist[v][v] ← 0
for k from 1 to |V|
... |
Recall that $\mathsf{AC^1}$ is the class of circuits with unbounded fan-in, polynomial size, and logarithmic depth.
Is this class closed under Kleene star?
I thought it would be simple since it is easy to check every subword (using a polynomial number of gates), but the part where I have to check every partition makes ... |
If we are given an NFA and a DFA, can we determine if there exists a string accepted by the NFA and rejected by the DFA and vice-versa. What complexity class would these problems fall into?
|
The Post correspondence problem (PCP) asks, given two sets of words $a_1,\ldots,a_n$ and $b_1,\ldots,b_m$ over the same alphabet, whether there are indices $i_1,\ldots,i_s \in \{1,\ldots,n\}$ and $j_1,\ldots,j_t \in \{1,\ldots,m\}$ such that
$$
a_{i_1} \ldots a_{i_s} = b_{j_1} \ldots b_{j_t}.
$$
It is well-known that P... |
Suppose I want to randomly sample from a large set of items, each of which has a "score". I want my probability of sampling to be proportional to the score. One simple way to achieve this is divide each score by the total, then randomly sample based on each probability. This is at least O(N), and running it the next... |
i am studying on trapezoidal maps. In the last section, "Analysis" of this paper, it says "The expected query time is indeed O(log n). Again the search structure size can be quadratic in the worst case, but the expected size is O(n)."
Here is what i did not understand well. How it is possible to reach a quadratic size ... |
I am currently studying hashtables and whilst the concept of chaining makes perfect sense, as does why searching is O(n) and also inserting (at head) is O(1), I dont understand why deleting an item is also O(1), hopefully someone can help me understand.
I am referring to text such as this:
In the worst-case scenario, ... |
Trying to find the length of the longest representative of an equivalence class in suffix automaton, such that it has the form:
$\{v\in{}\Sigma|v$ is the longest representative $\wedge$ $(\exists{}u\in\Sigma*)(v=uu)\}$|. In other words how can we find the length of the longest node $v$, such that $\overset{\overset{w}\... |
I am revising for my algorithms exam and I have come across one topic in particular that I do not quite understand;
What I would like to ask, if there is a certain way to find out O-Notation? Actually I know that the purpose of O-Notation, it helps us to estimate the effciency of algorithm. But in a specific questions ... |
I was asked this question today:
given a very long string x, which contains only lower case alphabets. A valid substring can only started with [a, b, c, d, e] and ends with [h, i, j, k, l, n]
IF we sort the valid substrings alphabetically, what will be the first one and what will be the last one?
If we do need to sort ... |
I have been practicing problems on graphs and shortest paths and
I encountered a problem that I'm struggling to understand.
Can you give me any tips and/or can you confirm that I got the general
concept of the problem right?
In a given undirected weighted graph $G=(V,E)$ and an integer $k$ and
edges with positive weig... |
I am solving a problem that is asking to provide an equivalent for $\neg ((a \wedge b) \Leftrightarrow c)$ and the equivalent shouldn't contain $\wedge$ (and), $\Rightarrow$ (implication) or $\Leftrightarrow$ (iff).
What I have worked out is:
$\neg(\neg((\neg a \vee \neg b) \vee \neg c) \vee \neg(\neg(\neg a \vee \neg ... |
According to this statement:
Every regular language is context-free. Regular languages are closed under complement, so the complement of a regular language is regular. Consequently, any regular language and its complement are a pair of complementary context-free languages.
$\{a^n b^n c^n \mid n\ge0\}$ is not determin... |
I need to create a parabolic shape with a given starting point, maximum point, and end point. I thought the most efficient way to do this is to use a bezier curve. However there is no major relationship (that I could find) that relates a control point of a Bezier curve with its maximum point (which is why I am asking t... |
I want to find an algorithm to find the shortest path in a vertex-colored vertex-weighted graph. Every vertex with the same color has the same weight and the total weight of a path should be the sum of the weights of the colors used. If we have for example a path A->B->C where A and C are red colored and B is blue colo... |
In class we defined "local features size" $\rho$ as follows:
Let $C$ be a smooth closed curve in the plane, and let $x$ be a
point of $C$. The local feature size $\rho(x)$ of $x$ is the shortest distance from
$x$ to the medial axis of $C$. (The medial axis $M(C)$ of a closed smooth
curve $C$ is the locus of the center... |
Suppose we have a statement: "Tom has a car" and we have an auxiliary clause that is
has(x, y): x has y then to write the statement in logic I am guessing the following ones:
$\exists$y has(Tom,y)
or
has(Tom,car)
The reason I am not sure which to select is I don't know whether or not "car" is a specific constant simila... |
How is possible to construct a finite state transducer that multiplies a number by 5? We can assume that numbers are supplied in binary notation, from least significant bits to most significant.
|
In a sorted array, I am trying to find just one pair that sum up to a certain value. I was wondering if anyone could help me improve my code in performance or memory. I know the code which is $O(n)$. If there are other method for finding pairs the sum up to a certain value that is much more efficient.
I was asked this ... |
I always wonder why machine learning is native to computer science rather than its more close fields like statistics and mathematics? In machine learning we CS engineers learn stats and maths and implement it by coding. Wouldn't it be much more easier for say a mathematician and a statistician to learn coding and imple... |
I have two data sets of a particular structure:
User 1:
Salad1: Tuna, Mayo, Lettuce
...
Breakfast1: Egg, Avocado, Toast
User 2:
Salad1: Tuna, Mayo
...
Breakfast1: Egg, Toast, Sausage
There are thousands of dishes, and the goal is to ensure that all the ingredients from User 1 dish are present in the cor... |
I am stuck at the following exericse:
Let $\rho$ denote the local feature size. Draw an example where the curve C contains the line segment from $(-1, 0)$ to $(1, 0)$, but where $\rho( (0,0) )$ is arbitrarily small.
Here are the definitions that I heard in class:
Let $C$ be a smooth closed curve in the plane, and le... |
I am currently studying the textbook Artificial Intelligence: A Modern Approach, 4th Edition, by Russell and Norvig. Chapter 3 Solving Problems by Searching says the following:
Another type of grid world is the sokoban puzzle, in which the agent's goal is to push a number of boxes, scattered about the grid, to designa... |
TLDR: CLRS is claiming that a certain "pseudo" or "proto" tree structure does not have fast deletion, but I seem to have an algorithm that is efficient, and I would like to know whether it works or not.
In particular:
In Section 20.2.1 of CRLS, the book introduces a "proto" Van Emde Boas (vEB) structure that has some, ... |
I have a question about the following recurrence relation:
$$T(n) = 27 \cdot T\left(\frac n 3\right ) + n^3 \log n$$
Using the master theorem, will this be
$T(n) = \Theta(n^3)$, or
$T(n) = \Theta(n^3 \log \log n)$?
|
When you first learn more about computation you can imagine it in terms of boolean circuits. That is you get a boolean vector $v \in \lbrace 0,1\rbrace ^n$ which you can then apply a circuit $C$ to which then produces an output boolean vector, and $C$ must be constructed from some basic gates (and or not).
It's fascina... |
Let $G$ have a vertex cover of size at most $m$ and let the degree of $G$ be bounded by $k$. Then $G$ has at most $m(k+1)$ vertices.
Note: Remove all vertices of degree $0$.
Answer:
The idea is to have $m$ graphs like the below one.
But how can I prove this proposition formally?
Thank you in advance for your answers.... |
I'm studying Comparability and Complexity, and through the course, a number of problems (namely, the halting problem for Turing Machines, etc.) have been proven undecidable through elementary proofs and reductions.
Next, the course discusses polynomial time reductions between several problems, which makes sense: it's r... |
The following problem is a problem I faced in one of my coding competitions.
Given two positive integers $N$, $M$. You can have $M$ distinct types of stones, for which different types of stones must have different weights. Find the maximum of $k$ such that any weight in $\{1, 2, ..., k\}$ can be formed as a total weig... |
Just a thought-experiment, could a program be written so that the computer generates it's own if-statements (semi/randomly) and runs them, gathers the results, then tests them in new scenarios, and iterates from there?
This idea came to me because it's kind of how we humans operate. When we're born, we have a genetic ... |
This is what do I have to solve:
Byron Book: Exercise 8.3 chapter 8
Verify the use of Chebyshev’s inequality in (8.6) of Example 8.16. Show that if the population
mean is indeed 48.2333 and the population standard deviation is indeed 26.5170, then at
least 8/9 of all tasks require less than 127.78 seconds of CPU time.
... |
Given a graph $G$, is there a 3-coloring with colors $c1$, $c2$ and $c3$ such that at most $k$ nodes are given the color $c1$ and that no two adjacent nodes are given the same color?
Is there a decently fast algorithm to solve this? My only solution is to go through every subsets of size $1$ to $k$ and remove those nod... |
I realize this may be an opinion-based question, but relevant nonetheless in my opinion.
Context:
I have a local search optimization algorithm, A.
I designed A to address a specific biological question.
A returns many local optima and often gets stuck near said optima.
My target audience (biologists) don't understand t... |
The following function getCombinations, is a recursive function that can be used to generate all combinations of an array. How exactly can we find the time complexity of this function? I would appreciate the workings or simply an idea about how to approach this. Thanks in advance
function getCombinations(chars) {
var... |
Context: I'm looking for a better state resolution algorithm for https://github.com/MichaelMure/git-bug
Summary of the current algorithm and shortcomings
git-bug is a distributed bug-tracker that embed in git, the distributed version control system. To do so, bugs are stored in the native git data structure (commits an... |
I have the following problem. I do not know where to start or how I should approach this problem. I am not sure about how to prove if a problem is in a complexity class of P . I know how to do NP but P confuses me.
|
I want to learn whether I can create regular expressions from the given Context Free Grammar. I found some examples that can be translated to regular expressions. However, all of them were like this: "S-> aB | bC". Whereas my example is like: "S-> AB | BC". Here is my example:
Can I create RE's from this? What is the ... |
I started to learn about compilers and interpreters. But I still can't understand how program execution happens under the hood.
This is what I have understood so far.
Compiler
The Compiler does not run a code, instead, just converts the code into another (low-level) code. This part is clear to me.
Interpreter
First I t... |
Given a graph $G$ on $n$ vertices with $m$ edges, show an algorithm that determines if there's a $P_3$ as an induced subgraph in $G$ in $O(m+n)$ time. ($P_3$ is the path on 3 vertices).
What I was thinking at first is that any vertex $v$ that has at least two neighbors could indicate a $P_3$ but it wouldn't be induce... |
in my notes I have one fact:
in a binary tree with $n$ elements ($n$ divisible by three) there is a node $u$ such that the number of nodes in the subtree with root $u$ is at least $\frac{n}{3}$ and at most $\frac{2n}{3}$.
Does it work for every binary tree or only when $n$ is divisible by three?
How can I quickly prov... |
So we all know it's easy to read a number from lowest place value to highest.
A simple algorithm would be like :
while(n):
a=n%10;
n/=10;
but the question is how do you read it oppositely?
for eg : 12312. must result in me getting first 1 then 2 then 3 and so on.
I don't wanna form an array or reverse the numb... |
This problem was given to 9-graders. We write down numbers except for the ones which contain the digit c. Find the nth such number. I looked at the indications, but the algorithm used there stumped me. I will describe in here: if $c \ne 0$, then we transform the number n - 1 (since 0 is part of the series) in the 9th b... |
I am given with this information:
"CMP OP1,OP2 will compare registers OP1 and OP2 if they are equal,
flag values will be ZF=1, CF=0,
if the first
operands value is greater flag values will be ZF=0, CF=0,
if the first operands value is less than the
second operand flag values will be ZF=0,CF=1."
I need to design instruc... |
Given a sum of flat symbolic products like $axc + byc + ayc + bxc$, how can I efficiently factorize it as a product of sums like $(a+x)(b+y)c$? For my problem, the products are not commutative -- it's more like a sum-of-tuples becoming a tuple-of-sums.
What have I tried:
So far, I have this Prolog program (run in Swish... |
I'm working through Samuel Mimram's book Program = Proof. In the first chapter, he discusses recursive types in OCaml, and inductive types. An exercise he provides on the topic has me a little bit confused. In the exercise, he asks the reader to define the function induced by the inductively defined type of lists, and ... |
I'm struck how to find DP recurrence for:
You are given a binary square matrix M of size nxn. We define a (p,q, l)-triangle of M, where p >= 1,
q >= 1, L >= 1, p+L >= n+1, and q+L >= n+1, as the set of elements M[i, j] satisfying p =< i < p+L,
q =< j < q+L, and i+ j < p+q+L. Design an algorithm to find the largest (p,q... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.