instruction stringlengths 35 29.1k |
|---|
I know 3SAT is NP-complete and QSAT is PSPACE-complete. However, is it true that
$$\exists X_1 \forall X_2 \cdots Q_k X_k \colon \varphi(X_1, \ldots, X_k)$$
is complete for $\Sigma_k$, the existential side of level $k$ of the polynomial hierarchy if each clause in $\varphi$ has at most 3 literals (or some other constan... |
Consider the following recursion:
$\begin{cases}
T(n) = 2T(\frac{n}{2}) + \frac{n}{\log n} &n > 1 \\
O(1) &n = 1
\end{cases}$.
The master theorem doesn't work, as the exponent of $\log n$ is negative. So I tried unfolding the relation and finally got the equation:
$T(n) = n[1 + \frac{1}{\log(\frac{n}{2})} + \f... |
Given an undirected connected graph, I wrote the following algorithm based on BFS. The algorithm detects wether this graph contains a cycle. If it contains a cycle then prints it. I'm pretty sure that it works just fine, but I don't really know how to prove its correctness properly.
Here is the pseudo-code:
Let s be t... |
What are the definitions of a type constructor and a type operator?
What are their differences and relations?
I think a type operator is a function whose parameters are n types and return is a type. A type constructor also means the same thing.
I use them exchangeably. But some reply used type constructor when my ques... |
Can somebody give intuition how to answer those questions? From one side I can say that most of them are undecidable because we can reduce the halting problem to them (or halting problem can appear because we don't know about given TM anything so it can behave unpredictably, can simply loop on any input), but on anothe... |
I'm interested in the intersection of linguistics and computer science, I've been reading on Chomsky hierarchy, and would like to know if there exist lambda calculus types that are equivalent to the Chomsky types, especially the type-1 that's context-sensitive and has the linear-bounded non-deterministic Turing machine... |
Given an array A(1 indexed based) of positive integers.For each element A[i] find the minimum index (say idx) such that the product of all the elements from index 1 to idx is divisible by A[i].where(1<=idx<=i).
constraints are: the number of elements of the array 1<=n<=10^5 and
1<=A[i]<=10^5.
For example let A[]={2,4,... |
I understand that vector clocks are preferred over lamport clocks because sometimes lamport clocks cannot account for the casuality and we use extra space to store the timestamps in the vector clocks.
What i dont understand is about the resetting of the vector clocks.
Why do the vector clocks overflow and how the reset... |
In my slides for my algorithms class, I have a method of finding the complexity of recursive functions called Recurrence Relation with "partizione bilanciata" which means "balanced partition".
My course is in Italian and looking online in English I could not find any trace of this method, I know of the recursive tree, ... |
Given a directed weighted acyclic graph G=(V,D,W) and a subset of edges D' of D. The problem is to find the longest path in G that passes by exactly one edge of D'.
What is the complexity of this problem?
|
Suppose I had a dictionary that contains events and the corresponding periods they are occurring. For example:
$$
\begin{align}
\textrm{Event 1} &\rightarrow \textrm{[1, 2, 3]} \\
\textrm{Event 2} &\rightarrow \textrm{[2, 4]} \\
\textrm{Event 3} &\rightarrow \textrm{[4]} \\
\textrm{Event 4} &\rightarrow \textrm{[2, 3]}... |
Call a language $L$ Hamming connected iff, for every pair of strings $x, y \in L^2$, where $|x|=|y|$, $x$ may be transformed into $y$ by a sequence of single symbol in-place replacements, so that after every replacement, the resulting string is in $L$.
Is Hamming connectivity a decidable property for regular languages?... |
We are given a array of positive numbers. We can perform two types of operations on these sequence of numbers.
If number E is even, then we can replace it by E/2
If number E is odd, then we can replace it by 2E
We have to find the minimum absolute difference between any two elements after performing these operations ... |
In my data mining course, we are working with a data set. I have to identity the ranges of each attribute. I am given the set of data for all 150 points and i am given the visualization (charts) of all attributes. However I do not know how to use that set of data or the charts to find the ranges of each attribute. I do... |
Introduction to Algorithms books claims BFS only classifies an edge for an undirected graph to be either tree or cross edge. But how about this simple example below where forward edges are naturally appearing?
Given graph with just 2 vertices A and B and 3 edges from A to B!
exploring A adjacent vertices
(1) A->B (tre... |
I have a list of pairs with values and costs:
| value | cost |
11, 1000
7, 700
7, 700
6, 700
2, 400
2, 500
1, 600
The list is ordered by value/cost decreasingly.
The task is, given a budget X find the maximum value you can get while keeping the total cost within the budget.
I... |
def.
A predicate M(x,y) is partially decidable if the function f given by " f(x,y) = 1(if M(x,y) holds), f(x,y) = undefined(otherwise) " is computable.
Thm.
If M(x,y) is partially decidable, then so is the predicate ∃yM(x,y).
proof.
Take a decidable predicate R(x,y,z) such that M(x,y) iff ∃zR(x,y,z).
Then...
I can no... |
Is ∀x∀y∀z[φ(x,y)∧p(y,z)->p(x,z)] equivalent to ∀x∀y∀z[φ(x,y)∧p(x,z)->p(y,z)] ?
The only thing I can think of is that this question can be answered if we show that p->q is equals (↔) το q->p, but that's not true because p->q ↔ ¬p->¬q, hence p->q is not equals to q->p. However, I do not know if my logic is correct and if... |
In Types and Programming Languages by Pierce, is it correct that
the language introduced in Chapter 3 Untyped Arithmetic Expressions is not Turing complete? Because it doesn't provide recursion.
the language introduced in Chapter 5 Untyped Lambda Calculus is Turing complete? Because it provides recursion.
Thanks.... |
Source of the problem is https://codeforces.com/contest/1152/problem/D . I think i understood the problem , but if possible please explain the problem in simple way and the solution also .I tried very hard to understand the solution mentioned on the website but i was unsuccesful . The problem is following-
Neko is pla... |
An array is given eg:-1 2 2 2 and we need to count the number of subsets for it of size k which has the sum of elements minimum possible
here the subsets of size k=3 are:-
122
122
122
222
we see that there are 3 subsets having the minimum sum
I did this in bruteforce approach..first I stored the subsets of size k in a ... |
You are in a xy plane with a set of points F. You also have a collection P of N sets { P1,...., Pn} where each of the set consist of points of the form (Px,Py). Each set has a different number of points. The problem is given a value k and a distance D, find points existing in F which are within D distance of any point ... |
I am trying to understand the difference between byte addressing and word addressing.
A 4-way set-associative cache memory unit with a capacity of 16 KB is built using a block size of 8 words. The word length is 32 bits. The size of the physical address space is 4 GB.
No of sets in the cache $= (16 * 1024) / (4 * 8 ... |
For e.g if the array is 2,2,3,3,5 and k=3
there are total 18 subequences
1 subequence of length 0(i.e empty subsequence)
5 subsequences of length 1
8 subsequences with length 2
4 subsequences with length 3
how to proceed?
|
In "More Is Different," an article about reductionism in science, the author makes the following off hand remark near the end:
I find that at least one further phenomenon seems to be identifiable and either universal or remarkably common, namely, ordering (regularity or periodicity) in the time dimension... [It] is no... |
(Not sure if this is the right place to ask this question.)
Let's say I get a computer to calculate 1+1. It should give 2, obviously. Will it always give 2? Is there any possible combination of circumstances that could cause a computer to, after finishing its calculations, give a number other than 2?
To illustrate what... |
From this codegolf question.
Consider an $r$ by $c$ matrix of nonnegative integers, called $M$. You also have a zero matrix of the same dimensions, called $N$. A "move" consists of replacing a rectangle of numbers within $N$ with any positive nonzero integer.
Valid "moves":
2 moves:
0 0 0 0 0 0 0 0
0 2 0 0 => 1 ... |
How many bits are required to represent an integer $ x $ with base $b$?
|
I have an AVL tree with height h. I understand how to get h $\thickapprox$ 1.440 log N. However, I can't figure out how to calculate the minimum depth of a leaf node from root. I tried constructing a recursive formula where d = 1 + min(dL, dR) where dL and dR are the depths of the left and right subtree of the root. Bu... |
I am trying to solve the following problem:
We're given a network flow $(V,E,c,s,t)$ and an edge $(u,v)$. We have to provide an algorithm that computes the maximum flow which has maximum flow on $(u,v)$ also.
The idea that I had was, computing max flow and on the residual graph trying to compute a cycle that starts fro... |
I need to prove that if finite automata $M$ with $k$ states accepts a string with at least $k$ characters, then the language $L(M)$ is infinite. I have no idea where to start. Any suggestions?
|
In Types and Programming Languages by Pierce,
The level of types contains two sorts of expressions.
First, there are proper
types like Nat, Nat→Nat, Pair Nat Bool, and ∀X.X→X, which are inhabited
by terms. (Of course, not all terms have a type; for example (λx:Nat.x) true
does not.)
Then there are type operato... |
When parsing, certainly precedence and associativity effect the AST. But, do precedence and associativity alter the set of accepted sentences? In other words, can precedence and associativity be "ignored" (defined in some random precedence all associating left, say) in the grammar, and then the AST fixed later based on... |
In Types and Programming Languages by Pierce,
Section 9.4 Curry–Howard correspondence on p109 has a table
Does the table mean that the simply typed lambda calculus λ→
corresponds to propositional logic (i.e. the zeroth order logic)?
Does the following quote on p109 mean that System F correspond to
the second order ... |
A diametral path in a graph is a shortest path whose length is equal to the diameter of the graph. Now, given a tree with $n$ nodes, I would like to find the set of edges (possibly empty) which are present in all diametral paths. Is there an efficient algorithm to do that?
I know how to do it in $O(n^3)$ which is basic... |
Problem Statement:
Let $G= (V, E)$ be a directed graph with costs $c_e \in \mathbb{R}$ on each edge $e \in E$. There are no negative cycles in $G$. Suppose there is a sink node $t \in V$, and for each node $v \in V$, there is a label $d_v \in \mathbb{R}$. Give an algorithm that decides, in linear time, whether it is tr... |
In Types and Programming Languages by Pierce, on p461 in Section 30.4 Fragments of Fω
30.4.1 Definition: In System F1 , the only kind is * and no quantification (∀) or abstraction (λ) over types is permitted.
F1 is just our simply typed lambda-calculus, λ → . Its definition is super-
ficially more complicated than Figu... |
I know in some many-to-many relationships, an entity is related to other entities on an individual basis. But is this always the case?
For example, in the Authorship relationship between authors and books. An author can write many books, and a book can have many authors. In each such connection, an author is individual... |
We have four categories:
additive constants, multiplicative constants, polynomials, and
exponentials
When determining the growth order of functions, we only care about polynomials and exponentials and ignore additive/multiplicative constants.
To determine whether some arbitrary function f(x) is Big-O of another fu... |
How am I supposed to read the P=?NP relativization proof? I am reading the classical paper Relativization of the P=?NP problem by Baker, Gill and Solovay, in particular the proof that there exist an oracle $B$ such that $\mathsf{P}^B \neq \mathsf{NP}^B$ on page 436. I have some questions and your help will be appreciat... |
If you implement a stack with a dynamic array-based with LinkedList you need more memory than with a dynamic array, and with dynamic array for insert in amortized cost is O(1), so the advantage of the LinkedList now is not and advantage, so why you should use a LinkedList, and why is this a useful data structure?
|
what will be kleene star "expansion" of expression $a^*b^*$ in lexicographic order?
I'm confused and I really want to clear my concepts so I can proceed further
|
I stumbled on this problem and I wanna know if there is a better solution.
There are $n$ 3d vectors with $x$, $y$, and $z$ components and I wanna find all pairs of perpendicular vectors in this set. Is there any better way than to verify all possible pairs of 3 vectors, some kind of optimization (not the obvious ones)... |
First of all, I am not completely sure whether this problem belong to the category of assignment problems so feel free to correct me in this case.
The problem:
We are given a set of $m$ workers $A = \{ a_1, a_2,...a_m \}$ and a set of $n$ tasks $T = \{ t_1, t_2,...,t_n \}$. Each worker either can or cannot perform any ... |
I have tried to find an answer to this but haven't found exactly what I'm looking for.
I am trying to develop a way in which I can have a random team selected based on skill set (1-5 with 5 being the strongest skilled player) as well as by position (Forward of Defense) so that the algorithm can organize the players ba... |
I understand that Master Theorem can be used to solve divide-and-conquer run times if they're in the form of $T(n) = aT(\frac{n}{b}) + n^clog^k(n)$ The reason behind it has to do with drawing a tree of the subroutines and see how each level k behaves, right?
Now suppose your divide-and-conquer algorithm can be describe... |
I just learnt decision tree concept in class. I have a question for homework. It says to prove that for searching an element in n*n matrix the lower bound is logn and prove it using decision tree.
My question here is using comparison based model, how can we have the lower bound as log n. what if the matrix is unsorted?... |
I am interested in embedding a Knowledge Graph in a vector space jointly with logical rules.
Through Google, the best work I have found about that is Tim Rocktäschel's paper Injecting Logical Background Knowledge into Embeddings for Relation Extraction.
The problem is that there is no throughly explanation about the ma... |
Section 24.2 in Types and Programming Languages by Pierce defines ADTs in existential types:
A conventional abstract data type (or ADT) consists of (1) a type name A, (2) a concrete representation type T, (3) implementations of
some operations for creating, querying, and manipulating values of
type T, and (4) an ... |
I've watched multiple videos and read articles about recursion but I'm still confused. I've got this problem here but I'm unsure how to answer it:
The following function calculates $x^n$ recursively. How many multiplications does the function make to calculate exp_rec(2, 64)?
def exp_rec(x, n):
if n==1:
ret... |
I'm working on a "semantic" browser engine where all search engines should look the same. One way to do this is to hard-code parsing rules for each site; another is to use machine-learning. Of course the latter alternative is the hip and cool one. ;)
I need a method to cluster links from search results from Bing, Googl... |
We learn how to write compiler. I know that we can use grammar to construct a parser for compiler or otherwise use a syntax graph to represent grammar and generate code when move on it's node. our teacher use second approach. a simple graph for only expression (limited) is:
You can see that when we see a sub graph, we... |
Let me explain what I want to achieve. I'm working on the coloring book project. On the input, I'm getting transparent images with black borders (Like this). Currently, I've created the 2D Matrix with colors in points. And basing on this Matrix I want to form an array of regions.
Region:
class Region {
var set = Se... |
Does this always mean that a program can be correct in regard to that spec or is there any correctness of the spec itself ?
|
This is a practice question I have, but I can't wrap my head around it.
.............
Let L = {M | M is a TM that halts with exactly two words on its tape in the form Bw1Bw2B}.
B = Blank Position
the problem of deciding whether an arbitrary Turing machine will accept an arbitrary input, is undecidable. Use this result ... |
I have a language $L= \{a^nb^nc^m : n, m \ge 0\}$.
Now, I wanted to determine whether this language is linear or not.
So, I came up with this grammar:
$S \rightarrow A\thinspace|\thinspace Sc$
$A \rightarrow aAb \thinspace | \thinspace \lambda$
I'm pretty sure(not completely however) that this grammar is linear and con... |
I am learning about the P/NP problem right now, and I don't understand when to use polynomial reduction and when to use a certificate.
How I understand polynomial reduction is that you can use it to show that:
Problem A is in P if:
B is in P and you can reduce A to B in polynomial time -> A $\leq_p$ B
Problem A is... |
Given a weighted directed acyclic graph $G=(V,D,W)$ and a set of arcs $D'$ of $D$, where the weights of $W$ are on the vertices. The problem is to partition $G$ into a minimum number of vertex-disjoint paths that cover all the vertices of $G$ subject to the constraints that:
the weight of each path is at most $k$.
eac... |
It is famous that for float numbers:
.1 + .2 != .3
but
1+2=3
It seems that multiplying floats by 10 allows you to preserve more precision. To further illustrate the case, we can do this in python:
sum([3000000000.001]*300)
#900000000000.2957
sum([3000000000.001 * 1000]*300) / 1000
#900000000000.3
By multiplying eac... |
Coq includes let-expressions in its core language.
We can translate let-expressions to applications like this:
let x : t = v in b ~> (\(x:t). b) v
I understand that this does not always work because the value v would not be available when typechecking b. However this can be easily fixed by special casing the typechecki... |
I was reading a research paper and there I read the following:
$t=O\left(d^{2} \log _{d}^{2} n\right)$ matches the lower bound $\Omega\left(d^{2} \log _{d} n\right)$ in the regime where $d=\Theta\left(n^{\alpha}\right)$ for some $\alpha \in(0,1)$.
It also says $t=O\left(d^{2} \log n\right)$ outperforms $t=O\left(d^{2} ... |
Let's assume $L$ is a language. $L$ is bounded if for some natural number $n \in \mathbb N$ applies $|x| ≤ n$, where $|x|$ is a length of a string, with every $x \in L$. Let's also assume that $L$ lies in a finite set of alphabets $\Sigma$.
How to prove that $L$ is bounded if and only if it's finite?
|
When comparing random-variable sequences generated from probability distributions, what's a formal proof that a distribution with higher entropy produces a sequence that's "harder" to compress?
In background reading, I haven't come across this analysis for a general, abstract probability distribution. The information t... |
The following question is in my homework:
Is the statement $f(n) = O(g(n))$ true, when $f(n) = n/2 + 4$ and $g(n) = \sqrt{n} + 2\log_2 n + 3$?
I understand how $f(n)$ is the upper bound of $g(n)$. However, I am unsure how to prove it mathematically.
|
I have made a red-black tree and I think that it is not valid. Could someone please verify?
B
/ \
/ \
/ \
/ \
R R
/ \ / \
B B B B
/ \ / \
R R R R
/ \ / \... |
A certain algorithm executes $n$ operations of three types: insert, delete, and find.
We know that $n/10$ of the operations are inserts, and the rest are deletes and finds.
You are given two implementations of the algorithm. The first one implements insert in worst case $\Theta(n)$, and the amortized cost of every oper... |
I take it that the concept of a modular subroutine call/return existed prior to the concept of a call stack (and hence to the possibility of recursive subroutines or of recursion limits). I would guess that reentrant routines were conceived prior to preemptive multitasking (perhaps in the context of recursion or of har... |
Can you have a process that generates a binary sequence with high compression rate (low entropy) but impossible to predict next symbol?
'impossible to predict' - sequence cannot be predicted theoretically. But I was also asking about the real life example (no polynomial algorithm).
|
Say there is a function $f:\mathcal{X} \mapsto \{1, 2,...,n\}$. We want to solve a specific instance of $f(x)$.
We have black box access to a BPP algorithm where it takes $T$ time to answer $\{YES, NO\}$ to $LessThan(x,k) := f(x) < k$ and has error probability of $1/3$.
1) How can you solve $f(x)$ in time $O(T\log n ... |
In my class a student asked whether all finite automata could be drawn without crossing edges (it seems all my examples did). Of course the answer is negative, the obvious automaton for the language $\{\; x\in\{a,b\}^* \mid \#_a(x)+2\#_b(x) \equiv 0 \mod 5 \;\}$ has the structure of $K_5$, the complete graph on five no... |
An image is taken and then rotated by an arbitrary angle and cropped. Let us assume that the original image is rather meaningless and is not aligned in any way. Given the rotated image, is it possible to learn anything about the original orientation? For example, using:
1. lossy compression artefacts (e.g. some aver... |
Is there any feature detector or extractor that uses color information?
Detectors like SURF and SIFT and many others work with grayscale. How do you think, may be transform can be sued to generate a grayscale image without loosing color info but suitable for those algorithms?
In particular, I need to distinguish object... |
The question here is that: There is an unbalanced binary tree with n-nodes. What is the time complexity to balance the tree?
The solution I thought of involved solving using Recursion where for the worst-case I took a maximally unbalanced tree like this
And then try to balance this using rotations.
But I cannot come ... |
So i was trying to write an efficient sorting algorithm and i came up with this method,
Sorting an array in ascending order by flipping (exchanging) 2
adjacent integers not in the correct order until there is no such
pair.
The leftmost swappable pair must be swapped first, i.e. the first pair
encountered while g... |
Suppose $L$ is the language of the unambiguous grammars. That is, a sentence $w\in{}L$ if it is a string that describes an unambiguous context-free grammar.
Considering that deciding whether a context-free grammar is ambiguous is non-decidable, would it be correct to say that $L$ exists but is not recursively enumerabl... |
I'm trying to understand Section 3: L1 Cache Missing in the paper Cache Missing for Fun and Profit. I'm stuck on trying to figure out how the covert channel is being constructed.
Specifically, I don't understand the following construction (the especially confusing parts are highlighted):
A covert channel can therefor... |
The first line of Sipser book for the Chapter- 'Time complexity', says that:
Even when a problem is decidable and thus computationally solvable in principle, it may not be solvable in practice if the solution requires an inordinate amount of time or memory.
My question is, yes we do have limited space and time, so the ... |
Grammar is as follow:
$S \rightarrow aaAb | aab | A$
$A \rightarrow aaAb | aAb | \epsilon$
I think that this grammar has equivalent unambiguous grammar as follow.
Let’s first rewrite the grammar as below such that this grammar has same language as one in question:
$S \rightarrow aaSb | aSb | \epsilon$
Because this gram... |
Given a weighted directed acyclic graph $G=(V,E,W)$, where the weights are non-negative and are on the vertices. I am searching for a simple path of maximum total weight, but this total weight should not exceed a given constant $K$.
Perhaps my question is elementary but I cannot find any solution. Indeed, it is well kn... |
So I had an assignment which asked me to find the smallest integer $i$ which when represented as a float is such that $i+1=i$
My approach- By making a simple C++ program , we get $i=16777216$ or $i=2^{24}$ But if we want to do that theoretically, I am unable to arrive at this number.
So a float is 32 bit variable and t... |
Given the following problem.
Given an $n\times n$ matrix $A := \{a_{ij}\}$. Find an $n\times n$ matrix $X := \{x_{ij}\}$, where $x_{ij} \in \{-1, 1\}$ for $i, j \in [n]$, that minimizes the following expression. $$\sum_{i,j}a_{ij}x_{ij} - \sum_{|i-k|+|j-l|=1} x_{ij}x_{kl}$$
My question is: is this problem equivalent ... |
I am currently reading Functional Programming in Scala and have encountered a statement in the book I cannot quite make sense of.
On page 67, we are told the formal definition of strictness:
"If the evaluation of an expression runs forever or throws an error instead of returning a definite value, we say that the expres... |
int coffee(int n) {
int s = n * n;
for (int q = 0; q < n; q++)
s = s - q;
for (int q = n; q > 0; q--)
s = s - q;
return s + 2;
}
int tea(int n) {
int r = 0;
for (int i = 1; i < n*n*n; i = i * 2)
r++;
return r * r;
}
int mocha(int n) {
int r = 0;
for (int i=0; i<=n;... |
The Bellman-Ford Algorithm uses a less-than symbol rather than a less-than-or-equal-to symbol. How does this identify that there is a negative cycle?
For instance, say I have the below example going from initialization state through the first iteration and on to the second.
Initial state
(0)S----(1)----B(inf)
... |
I am trying to show for every c, there exists $M\text{ such that }(x,y,z)\geq M$ then $S_1(x,y,z) + S_2(x,y,z) \leq ( f (x,y,z))^{-c} $ . For a particular $S_1,S_2,f$. Does it suffice to prove there exists M1, for corresponding $S_1$, with $S_1(x,y,z) \leq (f(x,y,z))^{-c} $ and $M_2$ for $S_2({x,y,z)} \leq (f(x,y,z) ... |
I want to find a way to generate sets that contain elements that sum to a certain target. Initially, I have an array that contains elements representing the maximum value that can be stored in that index.
For example, the input is [8,6,1] and the target is 10. The algorithm should produce all sets that have elements [ ... |
The english description of the question is (from my understanding) N accepts all strings that are both palindromic (the same forwards as it is backwards) and accepted by M. After a lot of toil and trouble, I'm not convinced that such a definition of N is even possible. My thinking is as follows:
Say M above is the DFA ... |
Problem :
In the weighted interval scheduling problem, we want to find the maximum-weight subset of nonoverlapping jobs, given a set $J$ of jobs that have weights associated with them. Job $i \in J$ has a start time $s_i$, a finish time $f_i$, and a weight $w_i > 0$. We seek to find an optimal schedule — a subset $\cal... |
I am studying for an upcoming exam and this is an old exam question from two years ago (all exams were made available through our lecturer):
Show that $L:=\{(a^{k}b)^{i}|i,k \epsilon \mathbb{N}_{+} \}$ is context-sensitve.
I could easily construct a LBA for this language.
But since the notation/construction of LBAs wer... |
Given a graph (say in adjacency list form), is there an algorithm to find a partition of vertices such that the number of edges between the two sets of the partition is the maximum possible?
For example, for the following set of edges of a graph with vertex set $\{1, 2, 3, 4, 5, 6\}$:
$\{(1, 2), (2, 3), (3, 1), (4, 5) ... |
I can't help but notice the uncanny resemblence JavaScript has to LISP. JSON (JavaScript Object Notation), for instance, is a data structure that can be reconstituted into an object by subjecting it to an eval() function. Likewise, LISP data can also be executed as code.
This leads to my question: Is JavaScript Homoi... |
I have some confusion with regards to AVL trees and the heights of various subtrees.
When initially reading the overview of the algorithms purpose(to keep the tree balanced) I thought it put limits on the maximum height difference between the shortest path and the longest path in the tree - my initial understanding is ... |
We can learn the big-O of building a binary heap using recursive method is O(n log n) from wiki
"This approach, called Williams’ method after the inventor of binary heaps, is easily seen to run in O(n log n) time: it performs n insertions at O(log n) cost each.[a]" we can also know if we build the heap using other met... |
Given a directed acyclic graph $G=(V,A)$ and a set $A'$ of $A$. It is well known that searching for a minimum number of vertex-disjoint paths that cover all the vertices of $G$ can be solved in polynomial time. Will the problem remain polynomial if we add the constraint that each path should contain at least one edge o... |
I had an exercise to solve a recurrence relation in my exam, I think it was a tricky question but I am not 100% sure.
The recurrence was $ T(n) = 2*T(n) + \sqrt{n} +42 $, it was specifically asked to be solved using the master theorem, and I wrote it cannot be solved using master theorem because it requires for b>1.
D... |
I am trying to understand A star algorithm. I am aware that it follows the sum of the current cost and heuristic, therefore f(n) = c(n) + h(n) in order to expand a new node. So every time the code with the smallest f(n) from the root is expanded. However, I am confused about the backtracking of the algorithm when it do... |
I have an algorithm that I am performing on a graph and I am looking to do an analysis of how to speed it up and would appreciate any comments.
The algorithm iterates over every edge in the graph.
For each edge it (1) finds the shortest path from the input node of the graph to the source node of the edge (Task 1).
It t... |
I have a device that sends its coordinates every 30 seconds. When I receive the coordinates, I classify the point as either belonging to (ie being inside) one of a number of predefined areas (so I assign an area number > 0 to it), or an "external" point (indicated by area -1).
External points can be caused, essentially... |
In a Binary Search Tree you have the following orders for traversal:
Left, Root, Right is called Inorder (or ascending order).
Root, Left, Right is called Preorder.
Left, Right, Root is called PostOrder.
But how is Right, Root, Left (or descending order) called?
|
I'm going through Adam Chlipala's "Certified Programming with Dependent Types" (available here for convenience), and I'm a bit stuck at internalizing the introduction of co-induction principle for the stream_eq predicate in Chapter 5.
Firstly, I'm used to induction schemes defined for data structures (stream in this ca... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.