instruction stringlengths 35 29.1k |
|---|
I have a square matrix (call it $A$) of size $n$ ($n$ is a positive integer). Each column is a permutation of $[1:n]$.
I take the first row of $A$, i.e. $A(1,:)$ and wonder what will be the frequency of the mode. This is, how many times the most common element in the first row of $A$ will appear and whether the mode wi... |
I have in the lectures a sentence in English, which I have to translate to First Order Logic.
Someone who loves all animals loves all humans.
Textbook solution:
∀x.(is_human(x) ⇒ is_animal (x))
⇒
∀y.(is_human(y) ∧ ∀z.(is_animal(z) ⇒ loves(y, z)) ⇒ ∀z.(is_human(z) ⇒ loves(y, z))))
My solution:
I would have interpret... |
Given a list of $n$ pairs (cost,points) and number $k$ ($0 \le k$), find the maximum possible sum of points s.t their sum of costs no more than $k$. return the maximum possible sum of points and their corresponding sum of costs.
For example the list $[(5,10),(1,2),(4,3),(6,12),(11,18)]$ and $k=15$, the maximum sum of... |
Consider an unweighted and directed graph G(V, E). Suppose, for every vertex v ∈ V we assign a vertex label y(v).
We say that the vertex labeling is valid if for every edge (u, v) ∈ E that is directed from u to v, y(v) − y(u) ≤ 1.
We say that the edge is admissible if y(v) − y(u) = 1. Now consider a directed path P tha... |
So I have this Recursive Descent Parser which outputs a Syntax Tree for arithmetic expressions.
While doing some reading, I learned that LL(1) grammars have a lookahead of 1 - I remembered using a lookahead so I grepped for it. But instead of finding it in my parser, I found it in the lexer.
case "*":
if self._pee... |
I've been trying to solve this problem:
Given a minimum heap $H$, which contains $n$ elements, where each of its keys contain natural numbers, as well as $k\in\mathbb{N}$.
Add the value $k$ to each of the keys on the left from the root, (Which means to add to each element in the heap which has an index of the form $i ... |
I've been trying to study some graph algorithms and, as part of it, prove a bunch of graph theorems in order to practice my ability to do theoretical work with graphs.
Specifically, I've been trying to prove that given a directed graph $G$, the minimal (in terms of vertex count) non-empty subset of vertices with no out... |
The problem:
Given an undirected graph G = {V, E}, a source-vertex s, and each vertex having a "capacity" between 0 and |V|, is there a tree which covers all vertices and does not extend from a vertex more times than its capacity allows, while also not covering every edge? Demonstrate that it is NP-complete.
An example... |
I would be very grateful if someone can clarify a little bit about the Dancing tree data structure that the Reiser4 filesystem uses. It's a presentation topic that I picked, however, there seems to be little resource about it. The only things that I could found are:
Reiser4's description of Dancing Tree: http://web.ar... |
Given the following grammar:
S -> A
A -> AB
A -> ϵ
B -> aB
B -> b
Check whether it is CLR(1) or not.
I have drawn the canonical itemsets as well as the parse table. But I'm not sure whether it is actually correct or not. I have tried searching for some similar examples that have epsilon productions but could not find... |
When applying the DC3/Skew algorithm to the string yabadabado, I can't quite get it to sort correctly. This issue happens in other cases, but this is a short example to show it.
This first table is for reference:
These are the triples of R12
We have a tie between i = 1, and i = 5 since both their triples are aba.
We ... |
Assuming $\mathsf{P} \neq \mathsf{NP}$, then all NP-complete languages are countably infinite. I know not all subsets are NP-complete, but I am wondering if there's a simple proof that every NP-complete language can be partitioned into two subsets $X,Y$ such that both $X$ and $Y$ are NP-complete.
|
Using the algorithm provided by this paper, they said that:
The algorithm defines a single phase of the local max algorithm. Each step of the phase takes at most O(log(m + n)) = O(logn) time and O(n + m) work in the CREW PRAM model. Over O(logm) phases, each with geometrically decreasing number of edges, the local max... |
Let $P$ be a partial order on $X.$ Does the relation $E(P)=$ { $(x,y)\in (X\times X)\setminus P:P$ $\cup$ { $(x,y)$ } is a partial order on $X$ } have a name? If not, what's a good thing to call it?
|
so this is my question:-
If I manage to find a vertex cover which has ....let's say 100 more vertex than the minimum vertex cover. Can I find the minimum vertex cover in polynomial time from this vertex cover?
Here, vertex cover is general vertex cover for any random graph.
Thank you.
|
I am trying to grasp the concept of triple sat compared to 3Sat. I understand that 3Sat has 3 literals for each for each clause. ${Triple-Sat} = \{ \phi | \phi $ has at least three satisfying assignments $\}$. Im just not exactly sure what the difference is between them.
|
Wondering which approach is faster in terms of time complexity. In short, is having a single loop that clears out the vector every time there's a difference lesser than the minimum so far faster than having two separate loops: first determines the minimum difference, second appends the corresponding elements with minim... |
I'm trying to apply the master method to the following recurrence:
$$T(n) = 2 \cdot T(2n)+n.$$
We have $a=2$ and $b=1/2$.
Also,
$f(n)=n$
and
$n^{\log_b a} = n^{\log_{1/2} 2} = n^{-1}$ since $\log_{1/2} 2 = -1$.
So, case 3 applies since $f(n) = \Omega(n^{\log_b a+\epsilon })$ , i.e., $n = \Omega(n^{-1+2})$ for some cons... |
I have a large array of bits of length $N$.
The query $f(k, m)$ means "find $kth$ zero in the array and the next $m-1$ zeros after it", $k \in [0, N-1], m \ll N$
Currently I use a segment tree over the bit array and my approaches were:
use kth zero search procedure $m$ times in $O(m \log{N})$
use the same kth zero sea... |
Given a collection of tuples $X=\{(x_1,y_1),\dots,(x_n,y_n)\}$, where elements
$x_i, y_i \in R_{\geq 0}$ are non-negative real values. The collection $X$ is
sorted if $x_i \leq x_{i+1}$ and $y_i \leq y_{i+1}$ for all $i \in [n-1]$. Sorting $X$ is not
always possible for instance if the given input has two tuples $(x_i,... |
I want to generate spatial scale-free networks for my project. Are there any python libraries that enable it?
I read about the BA model (https://www.science.org/doi/pdf/10.1126/science.286.5439.509) which seems like the pioneer of scale-free networks but I am not sure it takes the spatial aspect into the account.
Can a... |
Is there a standard terminology for the topological sort count over a partial order? I went with magnitude of a poset rather than dimension as this is too close to linear algebra terminology. I wonder if there is a generally accepted choice.
|
How can I convert a 1D index in the lower-left triangle of a grid into a row and column?
For example, consider this table of 1D indices, indexed by row and column
// 0 1 2 3 4
// +--------------- ...
// 0 | 0
// 1 | 1 2
// 2 | 3 4 5
// 3 | 6 7 8 ... |
I have the following problem: Given an undirected graph with n vertices v1,…,vn, a positive integer weight on each edge, and a n×n symmetric matrix Rij. The objective is to find a subset S of the edges such that the total cost of the edges in S is minimized and for every pair of vertices vi and vj there exist at least ... |
This problem's been stumping me for the better part of a week:
You're given a set of triplets of variables. The variables are all distinct and ordered. Each triplet $a,b,c$ means that either $a<b<c$ or $c<b<a$. The problem is to find an ordering of the variables satisfying all constraints.
For example, the set $\\{(a,b... |
I understand that the problem of whether a PDA accepts all strings is undecidable. However that doesn't mean such PDAs exist. To start, I'm working under the assumption that a PDA must read it's entire input, have an empty stack, and be in an accept state in order to accept. I am also working with the convention that a... |
I found many solution online on how to reduce Subgraph Isomorphism problem to Clique, but how do I prove that it is NP complete by reduction from independent set?
I'm struggling to figure out this proof through independent set. Any hints?
|
Problem: find all anagrams in a string such that one substring can be formed from another substring by rearranging its letters. Given a string $s$, find the number of pairs of substrings of the string that are anagrams of each other.
Below is the traditional solution to this problem that uses $O(n^2\times n\log{n})=O(n... |
I want to remove ambiguity from the grammar below:
S → ABC
A → abA | ab
B → b | BC
C → c | cC
I have removed left recursion and left factoring and obtained the grammar as follows:
S → ABC
A → abA'
A' → A | ε
B → bB'
B' → CB' | ε
C → cC'
C' → ε | C
Now, how can I remove ambiguity from the grammar? Is removing left recur... |
My lecture notes for minimum spanning trees say that:
A graph can have several minimum spanning trees but if the edge weights are distinct then the minimum spanning tree is unique. Without loss of generality, we can
assume that the edge weights are distinct
I'm trying to convince myself that the distinct edge weights... |
Global variables are given fixed addresses in main memory by the C compiler, called static memory allocation. Function local variables are created on the stack, this is called automatic memory allocation.
Why is it done this way?
|
I am trying to understand stacks a little better.
I don't understand why the content of the program counter is saved on the stack for the function call (call), but not for a jump (jmp)?
can someone please explain it to me?
thanks in advance!
|
I was just wondering if there exists problems that are solvable in polynomial time (a correct solution can be found in polynomial time) but not verifiable in polynomial time. My professor says no, but doesn't rlly give a clear explanation besides saying you can just use the solution to verify, but I fail to see how thi... |
Let $\Delta_n :=${$x\in \mathbb{R}^n\colon \sum_{i=1}^n x_i = 1$} denote the probability simplex in $\mathbb{R}^n$ and $A^{n \times n}$ be diagonalizable matrix.
I would like to know what is the fastest way (computationally-speaking) of solving the problem $\text{argmin}_{x\in \Delta_n} ||A x -y||^2$.
When $A=I$ is the... |
I'm not sure how to show that the language L = {M | M is a TM and {b}* ∩ L(M) ≠ ∅ } is recursively enumerable. I understand that if there is a DTM that accepts every word of the given alphabet, it is recursively enumerable. But I dont know how to properly show this, can anyone help?
|
I am struggling with this question as I am not sure whether the answer that has been provided is correct or not. The image should be sufficient to tell the question.
The attached image is of the answer. For the question, imagine all but the first two columns are empty.
Here's what I am struggling with:
1. Why is when t... |
I'm taking a course about the formality of programming languages and while reading Semantics with Applications: An Appetizer by H.R Nielson and F. Nielson
I came across the following exercise:
I'm referring to the last statement - I managed to proof that the statement is semantically equivalent using the Natural Opera... |
Prove/disprove: if $L\in \text{coRE}$ then $L$ is mapping-reducible to $\text{PAL}_{\text{TM}}$, where
$\text{PAL}_{\text{TM}} = \{~\langle M,w\rangle ~|~ M ~\text{is a TM and}~w~\text{is a palindrome}~\}$
It feels like there's not necessarily a mapping reduction from every language to a harder language, but I couldn't... |
I'm given a description of a regular language $L$, and I have a candidate regular expression $R$. Is there a systematic, step-by-step way to test whether the candidate regular expression is correct?
I know that there can be multiple regular expressions that are correct.
This is intended as a reference we can point oth... |
I'm new to optimization and I have a little problem that I want to resolve with my job. Here we go!
I need a certain number of drivers per day and each driver has 2 consecutive days off during the week. My optimization problem is that I want to have as few employees as possible with the number of driver per week. I nee... |
Let $\Sigma$ be an alphabet, and denote by $\mathrm{ind}(\varphi_M^{(k)})$ the index set (w.r.t some numbering) of the $k$-ary partial computable function $\varphi_M^{(k)} : (\Sigma^*)^k \rightarrow \Sigma^*$, which represents the $k$-ary proper function of the Turing machine $M$. Is it the case that $\mathrm{ind}(\var... |
I want to prove, that 2OrMoreSAT is NP-complete. It's defined as follows:
A formula is considered strongly satisfiable if there exists a model such that two or more different literals in every clause evaluate to true.
$\textit{2OrMoreSAT} = \{\langle \phi' \rangle \mid \phi' \text{ is a boolean formula in CNF which is ... |
Data Structure
a data structure is a data organization, management, and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data.
Language has primi... |
Planar Convex Hull is a problem where you have $N$ points in a Cartesian plane, and you want to find the smallest convex polygon that encloses the points. QuickHull seems to be the best available algorithm for this, and it finds the hull in $O(N \log h)$ where $h$ is the size of the output.
Interestingly, Michael Shamo... |
Consider a flow network $G$. Let $(S, T)$ be a min-cut of $G$. Let
$(u, v)$ be an edge that crosses the cut from $S$ to $T$. Claim:
increasing the capacity of $(u, v)$ causes the value of the maximum
flow in $G$ to increase.
I'm 99% sure this is false, but I'm struggling to disprove it. Can anyone give me some tips t... |
My lecture notes for gomory-hu trees says that it's easy to see that every GHT of the utility graph $K_{3,3}$ is a star with 5 edges. Is there any easy way to see this without manually computing every gomory-hu tree of the graph? Could I make use of the symmetry of the graph?
|
Given a sequence of real numbers $\{a_1, a_2, a_3 \ldots a_n\}$, I wish to design a data structure that supports the following operations on it.
$\mathrm{REVERSE}(i,j):$ Reverse the contiguous subsequence $a_i, a_{i+1}\ldots a_j$ i.e. swap $a_i$ with $a_j$, $a_{i+1}$ with $a_{j-1}$ so on and so forth.
$\mathrm{REPORT}... |
I am just wondering how you would write out a proof that the independent set is the complement of the vertex cover. I know how to explain it in common language, just wondering what a more official proof would look like.
|
I am currently learning about context-free grammar, however, I am confused as to why context-free grammar is used over regular languages(Regular expression) and what makes CFG more powerful. Even though the structure is more complex than regular expressions. Any suggestion would be highly appreciated.
|
Thank you. I see how it makes sense going in the opposite direction but i need help proving that this is true.
Below is the definition of ATM.
ATM={<M,w>| a TM, M accepts w}
The question from my understanding is that a language needs to be reducible to ATM for it to be considered semi-decidable. What I've tried to do i... |
I have been led to believe that the following statement
$X \in NP \land Y \not\in NP \implies X \not\le^m_p Y$
Is True.
But I am having difficult proving it. And I'm not even sure it IS true anymore.
At first it seemed reasonable that it was true. Since X is in NP there must exist some NP-complete problem Z that it red... |
I know that languages that have LL(1) grammar also will have LR(1) grammar as LL(1) grammar can be written only for a subset of DCFL whereas LR(1) grammar can be written for all DCFL, but I wanted to know where LL(1) will fall if I had it put it along with LR parsers.
L1 is defined as languages for which LL(1) grammar ... |
I was reading Kleinberg's and Tardo's book (especifically, this one) and, on page 38, these authors define the Big-Theta notation the following way:
Let $f$ and $g$ be two functions that $\lim_{n\to\infty}f(n)/g(n)$ exists and is equal to some number $c>0$. Then $f=\Theta(g)$.
Then, they provide a proof that connects... |
The stack allows subroutines to be used. It can store return address for "return from subroutine" instruction (RTN) and also arguments for the function.
It is not possible to store return address in the program instruction list itself, because the subroutine might be called from many different places in the program, an... |
I already know that SAT and 3-SAT are NP-complete.
If in 3-SAT the Boolean expression should be divided to clauses,such that every clause contains at most (in the original problem it says exactly) three literals would it still be NP-complete?
I think the answer is yes but I'm not sure of my solution. I think the reduct... |
Baker, Gill, and Solovay has shown in their famous paper, that there are oracles $A$ and $B$ with $P^A = NP^A$ and $P^B \not= NP^B$. So, one can't solve the $P$ vs. $NP$ Problem
with methods like diagonalization alone.
To find the oracle $A$ is easy. But the construction of oracle $B$ is very
complicated in the paper. ... |
Is 4DM NP-complete?
An instance of 4DM consists of four disjoint sets X, Y, W and Z of size k, and a set Q of quadruples $Q = \{ (x, y, w, z) \mid x ∈ X, y ∈ Y, w ∈ W, z ∈ Z \}$
Question: Is there a subset $M ⊆ Q$ such that each of the elements of X, Y, W and Z is in exactly one quadruple in M?
The answer I found onlin... |
The following exercise is taken from Theoretical Computer Science by Atiba.
Use Rice's theorem to demonstrate that every decidable language is Turing reducible to some language that is already guaranteed to be decidable (for example, the language of strings that represent the primes).
My reasoning is the following. A... |
I'm interested in testing some Traveling Salesperson (TSP) greedy approximation algorithms for finding the shortest Hamiltonian path for very large graphs. Assume I can construct whatever graph I choose; how could I build a graph with a known shortest Hamiltonian path in polynomial time with edge distances that satisf... |
In the context of $P$ vs $NP$, I was taught the following during my CS education:
$P$ is the set of problems that can be solved in polynomial time
$NP$ is the set of problems for which solutions can be verified in polynomial time
Until $P$ vs $NP$ is solved, we only know that $P \subseteq NP$
However, I can also imag... |
When an operand encodes an address, and that address changes the "memory address register" and the word in memory being addressed, it seems like timing issues could be a problem. Examples, LDA instruction (load address from memory, load word from that address. )
Illustrated in timing diagram below.
How is this usually... |
I am searching for datasets to evaluate an algorithm designed for tasks such as node-classification (edge-prediction, etc.) on weighted and potentially directed graphs.
The Stanford Network Analysis Project (SNAP) repository only contains datasets containing temporal weighted graphs.
Are there standard datasets for suc... |
The stabbing number of a triangulated simple polygon P is the maximum number of diagonals intersected by any line segment interior to P. Give an algorithm that computes a convex polygon triangulation with stabbing number O(log n).
A convex polygon with n vertex is given, assuming n is even for simplicity. I've already ... |
Let's say that I have an NP-complete problem such as the Clique Problem. Let's also assume that I have a finte set of graphs. What is the complexity of counting Yes/No instances?
More specifically let's define a new decision problem that returns Yes on a finite set of graphs if the number of Yes instances is $\geq$ a c... |
I am trying to find an encoding function e:{0,1}^20→{0,1}^10 and a decoding function d:{0,1}^10→{0,1}^20. Goal is to find d and e so that maxBdH(d(e(B)),B) is as small as possible. Here, dH denotes the Hamming distance, and the maximum is taken over all possible bit arrays of length 20.
Haven't been able to find a suit... |
Let's say I have some problem $A \in \mathcal{NP}$, and the problem of certifying a solution of $A$ is a $\mathcal{P}$-complete problem (I'm considering $\leq_{logspace}$ reductions). Does this imply that $A$ is $\mathcal{NP}$-complete?
Example / Motivation: $\text{Circuit-SAT} \in \mathcal{NP}$, and certifying a solut... |
Why is it important to know if a program terminates or not? In particular, what are some consequences of a non-terminating program?
|
A boolean expression is valid if it is true for every valuation. The problem
$\text{BOOL-VAL}$ asks whether a given boolean expression is valid. As the question suggests I need to show that $\text{BOOL-VAL}$ is decidable in linear time. I have no idea how to go about proving this.
Is $\text{BOOL-VAL}$ the complement of... |
Given a definite program, how can I obtain its Herbrand base?
For instance, given the program $P$ below, what is its Herbrand base $B_P$?
$p(f(x)) \leftarrow p(x)$
$q(a) \leftarrow p(x)$
I know the definition of Herbrand base for a first-order language $L$, which relies on the concept of a Herbrand universe for $L$ (... |
I hope this question is not out of place here, but I am currently attempting to implement the problem(a reduction algorithm) stated in the Title. I included the steps I am following as of now and an existing attempt at implementation. Are there better/simpler ways to go about this?
Logic:
Create a non-deterministic Tur... |
"DeepMind has predicted the structure of almost every protein so far catalogued by science, cracking one of the grand challenges of biology in just 18 months thanks to an artificial intelligence called AlphaFold", reads newscientist.com.
If protein folding is supposedly an NP-complete problem, does DeepMind deserve a m... |
I am currently studying Computer Network, and I have some problems when encountered CSMA/CD, I can understand how it works, but I am struggling in understanding this graph, anyone can give me some help?
|
So I've been really confused about the act of flipping a kernel in image processing. Is there any intuitive way to think about it or does it only help computing efficiently and maintain the mathematical symmetry?
Do we necessarily flip a kernel in image processing? (say the kernel is not symmetrical). Do we only flip ... |
From the definition I know that regular grammar should be Left/Right Linear (ie it should have variable on Left/Right side of each production rules)
But, my question is why it is mandatory?
Can't we have "Grammar which has DFA(Determistic Finite Automata) or NFA be called Regular Grammar"?
S --> SaS | e (e is epsilon/n... |
My supposition is that this is was more or less an automatic designation based on the fact that Rule 110 requires an infinite "background tiling" of the 14-bit sequence 00010011011111, and since by convention a proper Turing-complete system is supposed to begin with a blank tape or its equivalent, this doesn't count.
I... |
If there is an algorithm with time complexity $O(n^{n/log(n)})$, is that already exponential time or still subexponential time?
It shouldn't be considered quasi-polynomial since the exponent is also depending on $n$, right?
|
I have the following predicate: $empty(r)\Leftrightarrow L(r)=\emptyset.$ Now I am given the following regular expressions where $e, f$ are any regular expression:
$r=\emptyset$
$r=\varepsilon$
$r=a:\forall\in\Sigma$
$r=e+f$
$r=ef$
$r=e^*$
Now I have to write a recursive definition for $empty(r)$. And this is the thi... |
I recognize that it has overwhelming consensus at this point, but from what I understand, it's still technically considered "probably true" instead of "definitely true".
If we go by their original definition, then it amounts to dealing with things that can be accomplished by "effective methods", meaning finite sets of ... |
I'm attempting to solve this problem:
Given an undirected connected graph $G=(V,E)$ with $\mathrm{weight}(e)>0$ for all $e \in E$, and a subset $S \subseteq V$, we define that a sub-graph $H=(V',E')$ of $G$ spans $S$ if $S \subseteq V'$ and $H$ is connected.
We define $H$ to be minimal spanning if the sum of all weight... |
What is the asymptotic complexity of doing a convolution of an unbounded Gaussian on an NxN input matrix $M$?
The naive approach is $O(n^4)$ ($R_{ij} = \sum_{k=1}^{n}\sum_{l=1}^{n}M_{kl}*g(\sqrt{(k-i)^2 + (l-j)^2})$; $O(n^2)$ work on each of $O(n^2)$ elements); there is a fairly trivial lower bound of $O(n^2)$ (at leas... |
Suppose we are given $m$ points on $\mathbb{R}^2$. Consider $n=1, 2, 3, \dotsc$; we want to cover the $m$ points with $n$ triangles (of any shape) while minimizing the total area of the $n$ triangles.
I first consider the case when $n=1$. We create a convex hull (a polygon) that contains all $m $ points. And by using l... |
Is there a reasonably accurate method of computing an FFT of logarithmically-represented input data (with a sign bit, that is $±2^{\text{double-precision value}}$)?
The naive method (convert to linear representation, do an ordinary FFT, and convert back to logarithmic representation) very quickly runs into overflow/und... |
I recently had this question answered on stack exchange:
if X is in NP but Y is not in NP then can X be reduced to Y?
The answer proposed a counter example using an element of complexity theory I had not given much thought to, specifically it was the problem
$A = \emptyset$
that is, $A$ is the empty problem (or contr... |
In the following let $\Sigma=\{0, 1\}$. I'll prove that every language over $\Sigma$ is recognizable.
Let $L\subseteq\Sigma^*$. Let $w_1,w_2,\ldots$ be the list of words in $L$. For every $i=1,2,\ldots$, let $M_i$ be the Turing machine that decides the language $\{w_i\}$, which trivially exists. Consider a Turing machi... |
I am currently working my way through Language Models are Few-Shot Learners
, the initial 75-page paper about GPT-3, the language learning model spawning off into ChatGTP.
In it, they mention several times that they are using 175 billion parameters, orders of magnitudes more than previous experiments by others. They sh... |
The language is: L1 = {w | n0(w) or n1(w) is prime}
n0 means number of 0s and n1 means number of 1s I can show a^n (n is prime) is not context-free. But I can't find any solution for this one.
|
Introduction
I have simple polylines as sequences of points. I need a triangulation with a configurable width. The goal is to get a 2D 'band' from the input polyline without self-intersections.
Description:
Input is a 2D point sequence {P1, ..., Pn} (Polyline) and a target width of the triangulated band. Output is the ... |
I am trying to create a circuit based on this truth table below:
can you describe how to make the circuit using only logic gates
In_1 In_2 In_3 Out
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
This is what I hav... |
I have a binary search tree of size $N$.
The tree is height balanced: difference of heights of a node's subtrees is no more than 1 (true for RB or AVL trees).
$K$ is the number of nodes that have a non-empty right subtree.
If the tree is intentionally created to minimize $K$, then what is $\min(K)$?
|
I have found two ways of applying dynamic programming to the coin change problem of finding the minimum number of coins from a given set of denominations to make a given sum. I wanted to know if one is better than the other:
def money_dyn1(m, coins):
a = [[float("+inf") for j in range(m + 1)] for i in range(len(coi... |
How can a 4-bit two's complement operation be implemented using boolean NOR gate?
I search lots of 4-bit two's complement videos and articals, but most of them are using XOR gate.
|
How can a 7 segment decoder operation be implemented using boolean NOR gate ONLY?
Question:
Here's my truth table and k-map:
Normal circuit diagram:
|
Let $M$ be a $m\times n$, in which rows and columns of $M$ are sorted in increasing.
Problem.
Find $k^{th}$ smallest number in $O(m\log(mn))$.
My attempts.
I merge all rows in a single sorted array in time $O(mn\log(mn))$ but this idea isn't efficient and I think there is a solution with running time $O(m\log(mn))$. Af... |
I came up with a thought experiment on the limits of artificial intelligence that I was hoping to get advice on how to solve as well as any recommendations for further reading that explain relevant concepts for solving/dissolving the thought experiment.
Suppose some superpowerful artificial intelligence A1 attempts to ... |
While working on a job distribution problem, I ended up hitting a graph problem that I can't seem to get a foothold on.
Consider a not-necessarily connected graph, like one shown below. Each step, we can delete up to N vertices from the graph, but can't delete two nodes if they are connected, only one or neither of the... |
How to solve this recurrence relation:
T(n) = R(n-1) + n log n
R(n) = T(n-1) + n^2
|
FOO = {M | The length of language that M accepts is less than infinity}
M: a turing machine
M such that |L(M)| is less than inifinity: a turing machine such that the length of the language that the machine accepts, is less than infinity.
For example, We have |M1| <3, it means this TM only accepts less than three wor... |
Suppose i have 3 coins: A, B, C. Each one of them have different value: a, b, c. And if want to exchange coins A for coins B, i need to be able to give exactly a units of currency A and get exactly b units of currency B in return.
The problem is to find how many different triples of coins i can have?
For example, if i ... |
By pumping lemma, we choose the word $w=a^{p^2}$ that the decomposing is $[a^sa^ta^{p-s-t}]^p$
such that $u=a^s,v^i=a^t,x=a^{p-s-t}$
$[a^sa^{it}a^{p-s-t}]^p=[a^{p+it-t}]^p$
We choose i=p+1,we get $ [a^{(1+t)p}]^p $ $=a^{(1+t)p^{2}}$
we see that the power $(1+t)p^{2}$ has 4 dividers thus doesn't belong to the Language L... |
I'm Nestor Mermoz Thea. I have two definition over the Directed strong pseudoforest and Directed weak pseudoforest that I don't really well understand.
Directed weak pseudoforest: A directed weak pseudoforest is a digraph, in which every weakly connected component contains at most one directed cycle.
The class of all d... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.