instruction
stringlengths
35
29.1k
I have a really specific problem to solve and i'm looking for an existing algorithm to help me (i hope i'm in the right section of stackExchange). I would have to make "random" association between items but all association need to have to answer to specific conditions. Below, an simple exemple in javascript. INPUT var...
I am working on the following problem: Recall the definition of a complete graph Kn is a graph with n vertices such that every vertex is connected to every other vertex. Recall also that a clique is a complete subset of some graph. The graph coloring problem consists of assigning a color to each of the vertices of a gr...
Show that $L = \{a^nb^l \ | \ n \leq l \}$ is not regular I'd like to check if my proof for this is correct. Proof: Choose any positive integer $m$. Pick $w = a^mb^{m+1} \in L$. Note that $|w| = 2m+1 \geq m$ and $1\leq |a^m| \leq m$. Write $w=xyz$ where $x=\varepsilon$, $y=a^m$ and $z=b^{m+1}$. We have $$xy^3z= \vare...
So, after a collision, a piece of information gets stored in the next bucket. When retrieving the value later with a key, how do we know it has not been shifted due to a collision and that we are in fact receiving the wrong value?
In other words, is artificial human level intelligence not possible yet just because of limitations in processing power and amount of data required to train the models? Or we don't have the knowledge of how to achieve it even in theory? Suppose that processing power and amount of training data is not a problem, could h...
Exactly 1 in 3SAT (X3SAT) is known to be NP-Complete. It remains NP-Complete even if we only consider instances that are monotone and linear. Monotone means all of the literals are positive. Linear means no two clauses share more than one variable in common. If $n$ is the number of variables then the maximum number of ...
I am working on tiny programming language (for our specific tasks). It's a script language. It looks like a library for C++ that can execute a code of this language. This library parses a source code and create required entities in the memory, i.e. a source code isn't compiled in byte code, it keeps in the memory as C+...
A clique in an undirected graph $G(V,E)$ is a subset of vertices $\mathcal{C}\subseteq V$ every pair of which is adjacent $u,v\in \mathcal{C}\implies uv\in E(G)$. Given a clique $\mathcal{C}\subseteq V(G)$ in a graph $G$, an outer-incident edge of $\mathcal{C}$ is an edge $uv\in E$ with $u\in \mathcal{C}$ and $v\not\in...
I am trying to use Myhill-Nerode theorem to minimize the DFA appearing below. The algorithm repeatedly runs the following step: If there is an unmarked pair $(Q_i, Q_j)$, mark it if the pair $\{δ (Q_i, A), δ (Q_j, A)\}$ is marked for some input letter. Initially only $\{0,3\},\{1,3\},\{2,3\}$ are marked. However, $\{...
Consider the following language $$EQ_{DFA} = \{ \langle A, B\rangle: A \ and \ B \ are \ DFAs \ and \ L(A) = L(B)\}$$ Given the fact that $EQ_{DFA}$ is decidable, how can I prove that the language $$SEQ_{DFA} = \{ \langle A, B\rangle: A \ and \ B \ are \ DFAs \ and \ L(A)\subseteq L(B)\}$$ is also decidable? Thank you...
Given a context free grammar how am I able to determine if $\varepsilon \in L(G)$ ? The only way I thought of is to systematically check if I can derive the empty word from the given grammar. (Assuming it's not in CNF) Is my intuition right though?
What are the difference between decision diagram and decision tree? Is BDD a type of DD? what are the other type of DD? what are the algorithms used for it
I have a language $L$ = {$vabu$ | $v$,$u\in \{a,b\}^*$, $|vu|_a = 0$ $($mod $2)$$\}$ where $|vu|_a$ is number of $a$ in $vu$. I came up with these rules: $\sigma \rightarrow aa\sigma | ab\xi$ $\xi \rightarrow aa\xi | \epsilon$ This generates words in form: $(aa)^iab(aa)^j\epsilon$, but not all words in $L$ look like t...
Given an integer $k$ and $n$ sets $A_1,\ldots,A_n$, denote $U=A_1\cup A_2\cup\cdots\cup A_n$, $A_i^0=A_i$ and $A_i^1=U\backslash A_i$. The problem asks whether there exists $(b_1,\ldots, b_n)\in\{0,1\}^n$ such that $$\left|\bigcup_{i=1}^nA_i^{b_i}\right|=k.$$ Is this problem NP-complete?
How can I design a Turing machine that takes string $a^n b a^m$ and check if $n>m$ then convert the string to $a^{n-m}$, otherwise reject it?
Given the following algorithm : input : a (integer), b (integer != 0) result = 0; while(a >= b) { a = a - b; result = result + 1; } return result; How to find the number of instructions and the time complexity of this kind of algorithm since we don't know neither a nor b nor th...
My goal is to do some large iteration Monte Carlo simulation of different card games that require on the order of 1 billion random decks to get a reliably accurate answer. The bulk of the computer time is actually shuffling/preparing the decks, not searching for the "hit" criteria I am looking for. I am using an strin...
I'm trying to implement this algorithm but I'm having problems reproducing the exemple that it gives a solution to. The general method that I tried is: Make a grid $\theta \in [0,2\pi)$, with say N=256 points in it Create a complex vector $G(\theta) = \frac{1}{F(e^{i\theta})}$, where $F(z) = z\tan(z) - 1$ is the compl...
Suppose we have the function below: def func(n): for i in range(n): for j in range(n - i): for k in range(n - j): if i + j + k == 0: break if i + j == 0: break if i == 0: break return n + 1 We have three ne...
Assuming that we have a problem $p$ and we showed that the lower bound for solving $p$ is $\mathcal{\Omega}(2^n)$. can lower bound $\mathcal{\Omega}(2^n)$ implies the problem in $NP$?
Hi I am a Computer Science student attempting to solve this problem for extra credit. Problem is I am unsure what this algorithm is asking for as the language is a bit hard for me to follow: Imagine that you have a robot arm consisting of a sequence of rigid line segments $L_{1}, L_{2}, \dots , L_{n}$ hinged togethe...
I was going through these notes and they have the following operator on partial functions: $$ \mathcal F^{k}(\bot)(\sigma) = \left\{ \begin{array}{ll} \alpha( [\![s]\!]\sigma ) & [\![b]\!]\sigma=true \\ \sigma & [\![b]\!]\sigma=false \\ \bot & [\![b]\!]\sigma=\bot \end{array} \right. $$ and supposed...
The motivation for this question is the fact that partitioning DFA into equivalence classes is the mechanism that is used in model testing to generate test cases. However, obviously, DFA cannot describe arbitrary programs. Perhaps DFA can be extended (w/o becoming fullblown PDA), while still having the property that i...
Are data segments,heap,stack etc also present in secondary memory with compiled code then later mapped by OS to RAM when I open it?
I have a dictionary that has keys and multiple values per key. Same value can be assigned to multiple keys. For the sake of simplicity, the keys are ints and the values are strings, so that it would look like in C#: Dictionary<int,string[]> As an example the dictionary is filled as follows: { 1, ["A","B"] }, { 2, ["A"...
I am working on a project of " Fraud detection using deep learning" . For that I have a dataset containing some numerical attributes . Now the task is to use CNN for the above purpose. Please guide me how can we do that as I have observed that it can be used only for image classification. I would appreciate if I get so...
I am currently reading the extended Version of the Paper Online Detection of Effectively Callback Free Objects with Applications of Smart Contract. I am trying to understand the proofs of Chapter 6. In particular, I cannot understand the premise of proofs 6.2. Indeed, the authors use a variant of SMAC, an Object-orient...
I'm doing and assignment where the problem is to find the combination with the least number of elements form an array of integers, given an integer sum. I have solved this using a gready algorithm which doesn't find the optimal solution, however I'm having problems finding the optimal solution using dynamic programming...
An array $A$ of $n$ distinct, ascending integers is rotated to the right by $k$ positions, resulting in the array $A_{k}$. That is, the element at index $i$ in $A$ is moved to index $(i+k)\mod n$ in $A_k$. Devise a $\Theta(\lg(n))$ algorithm to recover $k$ from $A_k$ where $\lg(n) = \log_2(n)$. To clarify, the algorith...
Given a p-digit number n, where p is atleast 500, if we have an algorithm whose computational complexity is in the worst case, $O(p\mathrm{log}(p))$, will it be counted as a poly time algorithm ? Or since $(p\mathrm{log}(p))$ is basically the logarithm of an exponent so it will inefficient. And such an algorithm will ...
Prove that the array prev[.] computed by Dijkstra’s algorithm, the edges (v, prev[v]) for all v ∈ V , form a tree In order to prove this I used induction. Lemma : "A tree with n vertices has n-1 edges" R contains vertices with shortest distance from s and rest are in R' Base case : s is added to R. There are 0 edges. ...
I'm basically looking for an example (in maybe graph theory) of a constraint satisfaction problem which has a 3-element set as a domain and the problem is known to be polynomial-time solvable.
I'm learning CSP now for my research. First time doing formal work in CS. I'm having a hard time understanding the difference between choice $\square$ operator and the nondeterminism $\sqcap$ operator. Does the former perform a completely deterministic choice only based on the inputs from the environment, while the lat...
My algorithm-fu is really weak and I do not know how to express following problem in terms of any other problem known to me: Given a small rectilinear grid and coordinates of four cells in this grid (let's call these cells A, B, C and D) find a shortest path which connects cells A => B => C => D (in this order, with no...
Premises or Givens: $∃x(A(x) → B(x))$ $∀x (B(x) → K(x))$ To Prove: $∃x(A(x) → K(x))$ My Solution: $A(z) → B(z)$ From premise and Existential instantiation $x$ for $z$ $B(z) → K(z)$ From premise and Universal instantiation $x$ for $z$ $A(z) → K(z)$ Transitivity of 1,2 $∃x(A(x) → K(x))$ From Existential gen...
I know that the Context-free languages are not closed under compliment. Given $L=\{wxw^r| w \in(a+b)^+,x \in (a+b)\}$ and this is a Context free language. I think it's compliment will contain words of the form $ww$ which comes under CSL.So, I think this $\lnot L$ must be not context-free.But I've read here Why are pal...
I am trying to figure out a sorting algorithm which can be used in $O(n\frac{\log{n}}{\log{k}})$ sorting time. I am allowed to use $k$ registers that can store key value pairs and these registers can insert a key value pair and return a key value pair in constant time. And when popping from one of these registers, it w...
If I have the following array: pieces = {35,15,20,25,30,10} and the time slot is 80 minutes. How do I do the following: 1. Fill the time slot with any pieces for the perfect fit. (In our case: 30,35,15 or 15,25,30,10 etc.) 2. Fill the time slot with the best fit possible with deviation: (Let's say our time slot is 10...
One definition of the class NP is that there is a certificate whose size is bounded by a polynomial function of the problem instance size which can be used on a deterministic TM, along with the original input, to decide whether the input is a part of the language. Doesn't this definition allow the trivial loophole wher...
I am recently thinking about proving the undecidability of some problem. This problem has been formalized in Coq and by staring at it, people including me think "for sure" this is undecidable. "For sure" is a good source for surprises so I think I should try to prove it, probably formally. But then I recall MLTT is com...
Time is divided into terms, and each term begins with an election. After a successful election, a single leader manages the cluster until the end of the term. Some elections fail, in which case the term ends without choosing a leader. The transitions between terms may be observed at different times on different serve...
TL;DR: Can I say, "K-rule in Agda enables people to match $ \forall a.a \equiv a $ with $ \mathit{refl} $"? In https://agda.readthedocs.io/en/v2.5.4.1/language/without-k.html#without-k, K-rule is introduced as an implicit rule and it's defaultly enabled. If I understand it correctly, it means parameter of type $ \foral...
I'm a little confused about some LTL syntax. When the Global and Future operator (GFx) or []<>x is used, what does it mean. In the lecture slides it is given as infinitely often. But I don't understand it. When used as FGx or <>[]x, I understand it as eventually in the future something will be true forever. E.g. eventu...
I am new to algorithms so sorry to ask simple question I am working on a problem which is about array of integers, my solution is right but not good enough, because I have time exceeded exception on codeforces. I think solution where solution's time < O(n^2) would be right. My solution: int n; cin >> n; int currentSc...
Problem Consider the pseudocode for the sort algorithm below, which takes as input an unsorted array $A$ of $n$ integers with no duplicates. sort(A, i, j) if i = j return m = floor[(i + j)/2] sort(A, i, m) sort(A, m + 1, j) if A[m] > A[j] swap A[m] and A[j] sort(A, i, j - 1) Write a recurrence that...
The alphabet is {0,1}, express all finite strings containing at least three 1's and at most four 0's. I've come up with a method that enumerate every possible number of 0's: $$111^{+}+0111^{+}+1^{+}011^{+}+111^{+}01^{*}+00111^{+}+......$$ But for three 1's and four 0's this is far too complex. Need some help.
I've got problem on integer programming, specifically with the following knapsack problem. I'd be happy to get some suggestions on how to solve the problem in a time efficient way. There are 120 items $i$, each with weight $w_i$ and the value $v_i$. Each item can be selected only once (or zero times). For each of them ...
We have two deterministic pushdown automatas A and B, which languages are deterministic context-free. The problem is to decide if there exists a deterministic pushdown automata, which language is an intersection of the languages of A and B. This problem is known to be undecidable. But I can't find a proof for it.
I'm currently learning about database systems and they mention a buffer management system which brings in pages from disk to memory. This buffer manager allows higher layers to operate as if the entire database on disk is actually in memory. The video I am watching talks about LRU and Clock as the page replacement poli...
So I recently discovered lambda calculus and for the most part I understand it. However, one specific part of it that I cannot understand is this: Let's say we define a very simple function $$ I := \lambda a.a$$ This is simple to understand, nothing confusing. However, if you add another input I will scratch my head fu...
We're given an unweighted directed graph with vertices $V$ and edges $E$. We're trying to find the shortest path from $s$ to $t$ but we're allowed to travel along up to one edge in the wrong direction. If we insist on using all edges in the correct direction, we can solve this using BFS algorithm with $O(|V| + |E|)$ co...
How do I prove that entropy is maximal for $P(A_2) = \cdots = P(A_n) = (1-a) /(n-1)$ while $P(A_1) = a$ (a fixed number) and $A_1,…, A_n$ is a partition of the sample space?
Is $n^3$ an asymtotically tight bound of $(n^{2.99}).(\log_2n)$? If so then how?
I'm having trouble proving the following: If $L_1$ and $L_2$ are languages then: $$(L_1^*L_2^*)^* = (L_1\cup L_2)^*$$ I could be on the wrong track here, but I figured an inductive approach is a good way? My approach was this: If I use my notation $L^{(n)} = \lambda+L+L^2+...+L^n$ so that I have a kind of 'partial' Kle...
I saw this relationship in my exercise. max{n,k}= Ө(n+k) Could somebody prove it?
I have a $\rho$-approximate algorithm for a minimization algorithm, where the objective is to minimize $O$ ($\rho \geq 1$ is some constant), such that the algorithm's solution is always within $\rho$ times the optimal. Is it possible to use this to get an approximate algorithm to maximize $-O$? What is the approximatio...
In regular expression implemented by language like perl or python, user can write a set of characters like [123abcd] or special notation like \d to represents digit or \w to represents word character. I wonder how they are converted to DFA, since you cannot really create expand edges in alphabet(Unicode). Take example ...
There are two questions that I am trying to draw a comparison between: Q1: Maximum Absolute Difference You are given an array of N integers, A1, A2 ,…, AN. Return maximum value of f(i, j) for all 1 ≤ i, j ≤ N. f(i, j) is defined as |A[i] - A[j]| + |i - j|, where |x| denotes absolute value of x. Q2: Min Steps in Infini...
It is commonly stated that hash functions remain secure in a post quantum world, the justification being that a quantum computer only has the advantage of Grover's search to give it a quadratic speedup. However, there is active research into, for example, commitments such as https://eprint.iacr.org/2015/361.pdf. These ...
From what I understand, the x86 family of processors understands the same instruction set and x86-32, x86-16 machine code can be executed by an x-86-64 processor because of backwards compatibility. Now since Machine Code is usually produced from Assembly Language and we use an assembler for that purpose, does that mean...
I cannot understand how to prove if a certain property of a Turing Machine M is decidable or not. For example, if a have this: (1.1) "M always halts within 100 steps" or this (1.2) "M recognizes all words with an ‘a’ in them" what do I do to prove if it's decidable or not? I know I should use reduction or diagonalizati...
I can not find the appropriate variable to change the second part $n^2\mathrm{log}^2n$.
I am creating some charts for elevation v distance data. The original source of the data is GPX files and from them I have extracted... The total route distance (km) and each point along the route as [lat, long, elevation, distFromStart] The chart plots distanceFromStart (X-axis) v elevation (Y-axis). The routes can be...
My question is similar to this one. I was wondering if a PDA exists, that accepts any words containing a's, b's and c's in a random order, where the total amount of a's is higher than the amount of the b's and higher than the amount of c's, so for example the word "abcacba" would be accepted.
In a few different places ( http://www.ams.org/journals/mcom/2004-73-246/S0025-5718-03-01539-4/S0025-5718-03-01539-4.pdf and https://books.google.com/books?id=qYYKBwAAQBAJ&pg=PA21&lpg=PA21&dq=np-hard+completing+hadamard+matrix&source=bl&ots=8sKv9bAtc8&sig=ITZSmtD2p2xr6Q4RDqhbQQk0NDI&hl=en&sa=X&ved=2ahUKEwiotuLdvfzdAhWB...
How to find the depth of a concurrency bug The below program runs on two separate threads and shares the variable x. Variables t1 and t2 are local to their threads. The program has a concurrency bug in it. Bug: Any time both threads perform a read before they write we loose an update to x. Thread 1 1. t1=x 2. t1=t1+...
We have followed the official code of the Graph trend filtering (GTF) https://arxiv.org/abs/1410.7690, and modified the code with Ford Fulkerson Algorithm (FFA) instead of parametric maxflow. The parametric maxflow and the FFA have the same residual capacities. We also implemented the push-relabel algorithm, but the r...
Consider a function $f(n)$ whose definition requires one to compute $f(1),f(2),..f(n-1)$ in order to evaluate $f(n)$. Suppose that some algorithm to compute $f(n)$ has time complexity that is given by the recurrence: $T(n) = n + T(1) + T(2) +...+ T(n-1)$. This is $O(2^{n})$. One can use dynamic programming to store t...
I have done absolutely everything that i could to try to understand this algorithm. I did NOT want to go on without understanding it completely even though I know it might only be a single problem in the midterm and I think I might have already burned myself out anyways. I even performed the algorithm by hand, which di...
I've an issue stated as follows: We have 10000 jobs to do, each with some length $l_i$ and weight (importance) $w_i$. Our goal is to arrange the schedule of doing these jobs (in other words, the order of doing jobs) in such way that minimizes the weighted sum of completion times For this, I'm using the ratio gr...
Is there any known $NP$-complete problem which hardness proof is non-constructive. A constructive $NP$-completeness proof is a proof that $L_1\leq_p L_2$ by a reduction $r$ and from the argument therein, one can extract two polynomial-time algorithms $f$ and $g$ such that: For every instance $x\in L_1$, given a certif...
By "subsets of $PSPACE$" I am referring to classes like $SPACE(n^k)$ for some constant $k$ (e.g. $k = 42$). Under the union, intersection, and concatenation operations, such subset is apparently closed. For the Kleene star and polynomial-time reduction, I am not so sure. Here's what I have tried: To show that $PSPACE$...
I am relatively new to computer science. There,s been something that i have been thinking now that i am studying how to make actual compilers. We are past the days of programming with binary and assembly language( granted its still around and in use. correct me if i am wrong ). We are told that high level languages mad...
Wikipedia says: a radix tree is a data structure that represents a space-optimized trie (prefix tree) in which each node that is the only child is merged with its parent. Now they are situations where the parent of the child represent a valid key in the data set like this example: from this answer. Obviously you c...
This code depends on agda-stdlib: {-# OPTIONS --without-K #-} open import Data.Nat open import Data.Bool open import Relation.Binary.PropositionalEquality -- this code doesn't check, cannot match e with refl why : (e : Bool ≡ Bool) -> ℕ why refl = zero but-why : (e : 1 ≡ 1) -> ℕ but-why refl = zero I know K-rule me...
I was going through the following slides and I wanted to show the following: $$ \lambda x. x \equiv_{\alpha} \lambda y . y$$ formally. They define a an $\alpha$-conversion on page 15 as follows: $$ \lambda x . E = \lambda z.(E[x \leftarrow z])$$ however, I wasn't sure how to formally show the statement I am trying to s...
I have a question about the details of microprogramming and hard wiring in CPU architecture. in hardwiring, we write a code the compiler translates it to the ISA. then ISA is run in the hardware. in microprogramming, we write a code the compiler translates it to the ISA(which is much more complicated than the ISA in ha...
I would like to know if my understanding of this is correct: The question asks to show that the Big-Oh of the following function is $O(n\log(n))$ $$ \log(n^n + n) $$ I think the first step is to play with the expression so: $$ \log(n^n + n) = \log(n(n^{n-1}+1)) = \log(n) + \log(n^{n-1}+1) $$ However, I don't know what ...
I am trying to find all the combination of options trades that make the highest profit. Each trade has a maximum profit and maximum loss. I have a list of maximum losses e.g. [5298, 1100, 500]. Each number corresponds to a trade. The combination of maximum losses must be under the money I have in my account, for exampl...
Suppose we have a simple undirected graph $G(V,E)$, where $V$ and $E$ are the set of vertices and edges respectively. we denote $d(v)$ as the degree of a vertex $v \in V$. I am interested to find closed form or a tight bound of the following quantity $$ D = \sum_{e=\{u,v\} \in E} \frac{1}{d(u)+d(v)} $$ For example, s...
Say I have a dynamic array of the proper length $n$. A sort pivot is given. I run the sort algorithm, wait, and get $j$ unbalanced pivots. Is the time complexity $O(n\log n)$ or has it destabilized to quadratic in the best case? I believe that it will be useful to use recurrences to model each scenario, but not sure ho...
I'm coding something... weird, and I'm running into some constraint satisfaction and graph theory problems, which are fields I'm not too experienced in. Here's the problem: I start out with this directed acyclic graph: The values describe the range that the edge lengths are allowed to be. So the edge B->E can't be s...
I am having a hard time understanding the quick sort partition operation. I understand what partition is supposed to do, I just don't understand how partition does it. Specifically, I don't understand how the two subarrays (q-1, q+1) are constructed. I have looked at various other SE articles, such as: How does Hoare...
For $k \in \mathbb N$, we define $Q(k)$ as follows: $Q(k): $ let $x, y \in \mathbb N$ and $x$ is a multiple of $3$ and $k = x + y$, then $FUN(x, y)$ terminates and returns $x + y$ I will prove $Q(k)$ using induction Base Case: let $k = 0 \to iff (x = 0, y = 0)$ By line 1, 2, 5, $FUN(x, y)$ terminates and returns $0 + ...
Let $P(a,L)$ remove every $a$ in $L$, for example $$ P(a,\{ab,aab,aaab,bba\}) = \{b,bb\}. $$ How to show that if $L$ is a regular language then $P(a, L)$ is also a regular language? My attempt: If $L$ is regular then $P(a, L)$ is regular. Namely, let $D = (Q,Σ,δ,q_0,F)$ be a DFA for $L$. Assume every state in $L$ is ...
If we want to write to write a C code, to check if halting problem halts on a given input, how it will be ? I tried this code as shown below but stuck int main(int argc, char * argv[]) { if(argc < 2){ printf("Please input an executable and its input enclosed in double quotes\n"); exit(0);} //and here argv[1] has the ...
I am a bit confused on how to reduce a problem. I'll give an example: Let's say there is a problem called HALTEMPTY and we know it is undecidable. $HALTEMPTY_{TM} = \{\langle M\rangle \mid M \text{ is a Turing Machine that halts on input } \varepsilon\}$ The problem we are reducing to is $HALT_{TM} = \{\langle M,w\...
A diameter-decreasing planted clique in an undirected graph $G(V,E)$ is a set of vertices $\mathcal{C}\subseteq V$ such that if we add all the missing edges between any pair of vertices in $\mathcal{C}$ to turn it into a clique, then the diameter of the obtained graph $G'$ is at most $2$. Diameter-decreasing Planted Cl...
I am a master computer science student, and I am interested in both geometry and complexity theory. So I would like to know what is the relations between discrete geometry, computer graphics, and complexity theory ? I know the answer partially but I would like to have a clear answer since I do like to work on these fi...
Hopcroft says it is a finite nonempty set of symbols. $\varepsilon$ (empty string) is not an ordinary symbol. $\mathbb{N}$ is not finite. So, no to both? On the other hand, I do not see why $\{\varepsilon\}$ cannot be an alphabet. Its Kleene closure is $\{\varepsilon\}$, so a language over this alphabet can be either $...
Consider algorithms to find shortest paths in a graph. The grassfire algorithm has a complexity of O(|V|) where V is the number of nodes or vertices. The Dijkstra's algorithm has a complexity of O((|V| + |E|) * log(|V|)) where E is the number of edges. Compared to A star, the Dijkstra's does not rely on properties of a...
In type theory, some inductively defined data types allow you to prove absurdity. For example type Bad a = MkBad (Bad a -> a) extract : Bad a -> a extract val@(MkBad f) = f val absurd : a absurd = extract (MkBad extract) Now, when you church encode this datatype it leads to badChurch : Bad a -> (forall X. ((X -> a) ->...
I'm working on an algorithm that takes an array of $N$ values and it will iterate through each of the values and in each of them iterate through the rest of the array to the right. So the first value will check $N-1$ positions, the next one will check $N-2$, etc I'm a bit confused about the time complexity of my algori...
I'm evaluating two different algorithms to choose one for my implementation, they just do calculations on top of arrays, get some input of $n$ elements, and produce some output of $m$ elements, and I'm looking for an opinion about which one will scale better. The output they provide given the input is exactly the same ...
I have a recurrence relation: $$f(a,b) = \begin{cases} 1 & (a,b) = (0, 0)\\ 1 & (a,b) = (a, 0)\\ 0 & (a,b) = (0, b)\\ 2a & (a,b) = (a,1)\\ f(a-1,b) + f(a-2, b-1) + f(a-1,b-1) & \mathrm{otherwise} \end{cases}$$ Where the constraints: $1 \leq a \leq 10^9$ and $1 \leq b \leq 1000$. I tried using recursion to fin...
I know they have different scoping: data a (n : Set) : Set where introA : a n data b : Set -> Set where introB : {n : Set} -> b n That's not what I'm caring about. Are they different semantically?
I did lot of research on internet but couldn't get my answer. I want to know what is the difference between the word size and CPU architecture? For eg.- I read that CPU of 32-bit architecture can address 2^32 memory locations. Now if we consider that one address points to a single byte, then it means we can have memory...
I finally started working on my Master's thesis, and have a problem with literature sources. My thesis is about distributed system built on top of custom library implementing actor model. But I can't find any good literature that goes deep into this side of distributed software. I've found quite a lot of literature tha...
Consider function wa'' (need natural number definition, either in stdlib or Agda.Builtin.Nat): postulate comm : ∀ m n -> m + n ≡ n + m wa'' : ∀ m n -> wa (m + n) ≡ wa (n + m) wa'' m n with comm n m ... | refl = { }0 The pattern matching on comm n m with refl fails. But if I add one more match: wa'' : ∀ m n -> ...
I need to find the fastest route passing in all vertices Each vertex is a class. I can choose the number of classes for semester. Some classes have prerequisites (A and B need to be done one semester before C), so I can't do A, B and C at the same time. Some classes (C in this case) have only in the second semester o...