instruction
stringlengths
35
29.1k
I need to construct a DFA for a certain language with as little states as possible. so far my "best" solution contains 15 states. however, people claim it is doable in 7 states only. I tried for several days to come up with a smaller DFA but I failed miserably. So I thought I could try to minimize it. The only possibl...
The obvious way to encode, with minimum entropy, choosing s out of n (equiprobable) choices when x is already encoded is to identify s with a number [0, n) and set x = n * x + s, decoded with s = x % n, x = x / n. Is this optimal if the only constraint is that the encoded result must be a bitstring? Would *+/% still be...
I was given this real life problem and was asked if there would be a way to optimize this, I realize that this is akin to a job scheduling problem, but I can't seem to grasp how to make it work with the restrictions: Given: A list of jobs J = { j1, j2, ..., jn } 1 $\le$ n where each job will have a list of operations O...
Is there an algorithm for finding the number of primes in a given range $[N, M)$ that works in time linear to $M-N$? For context, $N$ and $M$ can go up to $10^{10}$, but the distance between N and M is at most $2\times10^7$. I know that the sieve of Eratosthenes method works in $O(n\log\log n)$ time, but it would requi...
I was reading M. Sipser, Introduction to the theory of computation 3ed. where he presents a proof by construction that the class of regular languages is closed under unions (Theorem 1.25). However, he omits the induction details for a formal proof of correctness. I tried filling in the details myself but it was a mess;...
I am learning quantum computing and as a background study, I am currently learning fundamentals of classical information theory. I thought it best to ask my doubts here. In Nielsen and Chuang, it is stated that mutual information I(X:Y) of two random variables X and Y is the information they have in common while in som...
I have an unweighted consistent graph and some node X(the source) and some nodes A, B, C and more. I need to find the shortest paths: X->A, X->B, X->C and so on. Note that the number of goal nodes will not be very big. If I were looking for only one path I would use BFS. But I'm quite sure how I can use BFS to find all...
I know there are a number of different tiling problems and some of them have been discussed here: Number of ways of tiling a 3*N board with 2*1 dominoes problem Domino and Tromino Combined Tiling DP tiling a 2xN tile with L shaped tiles and 2x1 tiles?. My domain has different requirements which are as below: https://ww...
Take an image, (the Google home page) is a good example. I want an algorithm to find the largest white rectangle in this image. That is to say, the largest rectangle that would fit in an area of white space containing only white space. Do you know any algorithms that would do this?
I have a binary search tree with integer keys. I have to remove a range (m, n]eZ of keys from the BST in O(s + h) where s is the number of keys to remove and h is the height of the tree. Attempted solution: The naive solution is just to find nodes in range and delete them and fix the tree one-by-one, but that doesn't ...
No. of rows in the table (as given in image) is not known beforehand . The problem I am dealing with generates different 2-D matrices based on the input data given. As soon as a matrix generates it should be placed in this kind of table (as a row) along with its output value. I have taken eight rows , but it can be an...
When using Huffman Code, to generate prefix-code trees for a sequence of letters, CLRS choose to use a normal Min-heap data structure. Using Fibonacci-heaps instead, are we not able to achieve a better bound on the running time, knowing that especially the INSERT operation of Fibonacci-heaps are constant time amortized...
It is known that the halting problem is undecidable even when we fix either the Turing machine $M$ or the input $w$. What if we fixed both the machine and the input? I.e., is it decidable for every fixed Turing machine $M_0$ and every fixed input $w_0$ that $M_0$ will halt on $w_0$ as input?
I am looking into FreeRTOS, just for personal learning and I am stuck on how the fundamentals of how it works with Linux. So for example, I am able to build FreeRTOS on my linux ubuntu machine. Now the part I am stuck on is: it must be running ontop on Ubuntu, so how do I get the real time performance from it? Wouldnt ...
I'm numbering generated files with two digits 00-99 and I want to retain the last 50. The algorithm should tell me the number of the current file that I'm about to save and which of the previous files to remove. If I scale it down to a toy version with one digits, here's how I want it to behave. As long as there are f...
This problem was originally given in "Introduction to Automata Theory, Languages and Computation" by John E. Hopcroft and Jeffrey D. Ullman as Exercise 4.3. $$ \text {Let }b_i \text{ denote } i \text{ in binary without leading zeros.}$$ We need to construct a CFG which generates the following language: $$ \{0, 1, 2\}⁺ ...
What is the big-O notation of the following functions : $\displaystyle\sum_{i=1}^n \left(\begin{array}{c} n-1\\ i \end{array}\right)\\\\ \displaystyle\sum_{i=1}^{n} \sum_{j=1}^{n-i}(3j)\\\\ n^{\textstyle\frac{logloglogn}{logn}}$ If possible I would prefer hints on what I should try doing instead of straightforward solu...
I wanted to write a program to print the values of pseudo random numbers in a range. So, i wrote the following: #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int i=0,x; while(i!=10) { srand(time(0)); x=rand()%51; if(x>=30&&x<=45) { printf("%d\n",x); i++; } } return ...
Suppose I have the array: [2, 3, 4, 5, 6, 7, 8, 9] Now based on few parameters: current_item - currently selected item. select_size - selection size, always odd. I want to get a sublist of the list that follows the conditions: current_item should be in middle of sublist if that is possible. In case when there is no...
I have a tree T, I need to generate all possible variants of T by permuting all its child nodes(please refer the following figure). how can I generate all variants, T, using recursion? any help is appreciated.
How would you write a language for a context-free grammar that generates an empty string. Is it something like E = { (G) | G is a CFG and L(G) = Ø}?
I have a very expensive black-box function and at least 15 parameters that I want to explore (usually 5-6 at a time). So far I have tried Genetic Algorithms and Gaussian Process Surrogate Optimization (bayesian optimization). Both methods work fine and efficiently up to 5-6 parameters. However, I am having an issue on ...
I am emulating the left shifting of a 128-bit integer using two 64-bit integers. For this I must calculate the bits that need to be moved into the higher portion. I have the following algorithm for generating a bitmask that masks the last until bits. Where until is an integer in the range 0..64: ~(power(2,64-until))-1...
Let's say we have a bipartite graph $G=(V_1\dot\cup V_2,E)$. We're now looking for a two-coloring (red/blue) of the vertices of $V_1$, so that for all vertices $v\in V_2$ the sum of edges coming from red vertices differs at most by 1 from the sum of edges coming from blue vertices. In other words, we're looking for a t...
Im pretty new here. My question showing me an algorithm: TRUE_SEQ(A[1...n]) for i <- 1 to n do A[i] <- FALSE for i <- 1 to n do k <- i while(k <= n) do FLIP(A[k]) k <- k + i FLIP(x) if x = TRUE then x <- FALSE else x <- TRUE Now i need to prove that after we finish TRUE_SEQ, the value of $A[i]$ is TRUE if...
Given two sets of $N$ integers, weights and reps, that store info about some dumbbells, find out the maximum profit by taking at most $M$ dumbbells. Each dumbbell can be taken at most once. The profit is given by the following formula: $$ \min(\mathit{takenweights}) \times \sum_{i=1}^m \mathit{takenreps}(i), $$ where $...
You have two $n$-point sets $P$ and $Q$ of two-dimensional points: $$ P = \{p_1,\dots,p_n\}, \text{ where } p_i = \{a_i, b_i\} \\ Q = \{q_1,\dots,q_n\}, \text{ where } q_i = \{c_i, d_i\} $$ You must determine whether there is a line $L$ so that $P$ and $Q$ are on opposite sides. This line essentially must separate b...
I've been reading about System F Omega lately, and I keep stumbling across a construct in typing rules that I cannot find an explanation of: Γ(x) = k. For example, in A Short Introduction to Systems F and F Omega: Γ(a) = k -------- Γ ⊢ a : k I see the same construct in Hereditary Substitution for Stratified System F. ...
let, low[] and disc[] be two 1D arrays disc[i] stores the discovery time of node[I] low[i] stores the lowest value between disc[i] and discovery time of children of node[i] I'm curious that what is difference between low[u] = Math.min(low[u], disc[v]); and low[u] = Math.min(low[u], low[v]); why is later incorrect? The ...
In CLRS book there is an exercise (19.4-2), the aim of which is to create a linear chain of nodes by a sequence of Fibonacci-Heap operations. I have solved the problem by recursively making a union with a chain of two nodes, inserting a new minimum node and extracting the minimum, after which consolidation takes place ...
When you edit information in a file, but you add in more information than was already present, how does the file system handle it without an overflow into the next section of the file? Here's an example. Consider having statements 1-12 in a 512-byte block, and you had statements 13-24 in the next 512-byte block. [Imag...
It is known that the halting problem is decidable for every fixed $M_0$ Turing machine and every fixed $w_0$ input. My related question would be the following: is it true that for every fixed $M_0$ Turing machine and every fixed $w_0$ input, an $M_{M_0,w_0}$ Turing machine can be constructed for which the possible inpu...
Given a matrix of 1s and 0s where 0 represents houses and 1 represents stores, find the square of minimum Euclidean distance of every house to nearest store. Return it as a vector of vector. [[1, 1, 0], [0, 0, 0], [0, 0, 0]] should return [[0, 0, 1], [1, 1, 2], [4, 4, 5]] Basic BFS: ( approach-1) If there a...
In a series graph, each edge $e_i$ exists with probability $p_i$. And if you want to examine the existence of edge $e_i$, it will cost you $c_i$. I want to test the connectivity between source $s$ and destination $d$ with the minimum expexted cost. I have figured out that the expected cost can be caculated below if the...
I have an algorithm which, when given a positive integer N, generates a permutation of the first N integers (from 1 to N) using a method called randInt(x,y). The method randInt(x,y) will generate a random integer between the numbers x and y, provided they are positive integers and y >= x. The algorithm is given by the ...
The more I think about programming and optimization, the more I think "why not just specify a goal and have the program figure out the optimal solution to it". I am familiar with basic "optimization problems" such as finding the best fit line to a curve, or gradient descent sorts of things. What I'm talking about is wa...
Is there any correspondence between the coproduct(sum) type in type theory and arithmetical summation? For example what does 3+4 or x+6 mean in type theory?
I want to generate a random partition of an $N\times N$ grid into $N$ connected groups having $N$ tiles each. How would I do this? Max grid size will be 10x10. Below is an example for a 5x5 grid.
How would we solve the knapsack problem if we now have to fix the number of items in the knapsack by a constant $L$? This is the same problem (max weight of $W$, every item have a value $v$ and weight $w$), but you must add exactly $L$ item(s) to the knapsack (and obviously need to optimize the total value of the knaps...
So , Basically assume there is a graph $G$ which has no bridges. Is it always true that there exists two edge disjoint paths between any two vertices in the Graph ? $\text{My Attempt at the Proof}$:- Suppose there isn't , then there must be at-least one edge common in both the paths , and if we remove it then it disco...
While familiarizing myself with polynomial hierarchy, I used this book which is written by Ingo Wegener. Now I'm practicing, and on page 132 I met this exercise: Let us consider a Boolean formula $\phi$ on the variables $x_1, ...,x_n$. Each $n$ bit vector $\overline x \in \{0,1\}^n$ is a possible assignment to variable...
Dr. John claims that he designed a comparison-based algorithm FastMerge that can merge $t$ arrays of size $t$ at most each in $O(t^2)$ time. In Dr. John’s own words, ”Given $t$ sorted arrays $B_1,B_2,\dots,B_t$ such that each $B_i$ contains at most $t$ elements, FastMerge will produce a sorted array $B$ that contains...
Addresses in system programming languages like C are one dimensional (i.e. one number). This forces the programmer to make a decision whether matrices are stored "row major" or "column major" causing the opposite access to be slower. This is somewhat surprising, since I think I remember that physical RAM is actually a...
I'm looking for an algorithm to split a bipartite graph into subgraphs with a specific constraint. I'm not sure if any existing algorithms solve my problem or not. I have an undirected bipartite graph where the nodes are customers ($C$) and services ($S$). I want to split this into several smaller subgraphs, limiting...
I'm trying to create an algorithm in SQL(syntax doesn't really matter) that will read the results table that consists of 2 columns: number (1,4,15,30...etc) and it's quantity(1,2,3,4,5...) like: number qty 3 5 7 3 15 2 30 9 and then creates a resultset based on how many of these numbers can fit within a ...
I want to prove that $\dfrac{3x^3+2x^2+x+1}{4x^2+1}$ is $O(x)$. I am having problem in finding $c$ and $k$ and proving that it is big O, since the function involves a fraction. How would I go about doing this?
I am having an issue in a specific part of the randomized quick-sort analysis. As per the randomized quick-sort algorithm the pivot is chosen from the given subset on which it is called from a random index, instead of just choosing a specific index each time. Now suppose that we give an array of size say $n$ to our ran...
Firstly 2 disclaimers, I am very new to the concept of a stack at a low level. I've only encountered it because I'm learning rust and the docs mention it. Secondly, I am aware of another similar question on this site, but it doesn't address a very specific concern. My understanding of a stack is that it follows First I...
The halting problem is undecidable, i.e. $\not \exists$ $M$ Turing machine s.t. for every $(M_0,w_0)$ input where $M$ is the description of a Turing machine and $w_0$ is an input word, the output of $M$ is "$1$" if $M_0$ will halt on $w_0$ and "$0$" if it will not. From this statement only, it does not follow that ther...
The book "Exact Exponential Algorithms" by Fedor V. Fomin and Dieter Kratsch is an excellent book to start learning how to design exact exponential algorithms. In their second chapter, they introduce the recurrence relations in context of a branching algorithm: $T(n) \leq T(n-t_1) + T(n-t_2) + \dots T(n-t_r)$ To solve...
Wondering if this was possible. If I have a sorted list, can I find the right spot for an integer and insert it, all in O(1) time? The only way I can think to do this is via having a MASSIVE hashmap with one slot for each possible integer. 2 billion different integers * 4 bytes per integer = 8 gigabytes....but it'd tec...
Deciding bipartite hypergraph coloring is NP-hard: While for bipartite graphs a 2-coloring can be found in linear time, it was shown by Lovasz [10] that the problem to decide whether a given k-uniform hypergraph is bipartite is NP-complete for all k≥3. Bipartite hypergraphs are colorable in expected (average) polynom...
I'm reading this chapter https://www.deeplearningbook.org/contents/mlp.html of the Deep Learning book, and on page 209, they have this equation (assume there is no regularizer and no bias parameter): $$ \nabla_{W^{(k)}}J = gh^{(k-1)T} $$ I'm not sure how this equation is derived, because I thought based on the equation...
in this 2minute-long video https://www.youtube.com/watch?v=TJ49N6WvT8M (pulled from a free udacity course on algorithms/theoretical computer sciences), whose purpose is to show how a SAT problem can be solved as the shortest path problem would be, I understand that there are n path paterns as n different boolean vari...
I have looked at a number of textbooks on computability theory. They typically have the following form: Define a language class (regular, context-free, context-sensitive, recursively enumerable) Define an automaton that recognizes the class (finite automaton, pushdown automaton, linear-bounded automaton, turing machi...
Apologies if this isn't posted in the right stack exchange, but I'm trying to come up with an algorithm that generates a set of sets ('set' as synonymous with 'array') with the following conditions: Element values range between 0-11 Set length is between 1-12 All sets must begin with 0 ([ 0 ]) Value of element n must ...
I am unable to find product of every contiguous subsequence of an array in less than O(N^2) time complexity. What actually i want to do is find the number of contagious subsequence whose product of elements is either odd or multiple of 4. The problem here is time i want an algorithm which can make it happen in O(N). p...
I am beginning to study type theory, using Hindley's book "Basic Simple Type Theory", and I would like your help in the proof of a theorem. I would like to know whether my idea for how to prove the theorem is correct or not and if there are better/other ways to do it. While learning about subject reduction and expansio...
I'm facing the following problem. I have a flat-file database (e.g. CSV). Since it's relatively large to store in memory, I'd like to compress it. Given a key, I need to return the uncompressed text (record of values). So one naive idea is to tokenize the text into words and to have the mapping $\text{word} \mapsto \te...
Sorry if this is too simplistic of a question, but over the last couple of months I have been working through the course mathematical foundations of machine learning at my college. I think I am really starting to understand backpropagation and its innerworkings of how it works, I am just hung up on this extremely littl...
Are there any known / efficient dynamic programming solutions to sorting? I understand of course that dynamic programming applies to scenarios where we have overlapping subproblems and optimal substructure, but I wonder if there are transformations and representations of the sorting problem where these conditions are...
Currently I want to learn the complexity of space, I read a few of the books on it. On this I encountered this example problem. I would just like to know how to show that the following problem $​\in L $ (deterministic logarithmic space). Input: series of open or closed parentheses Question: Are these parentheses prope...
I am working on creating a program to generate dense American style crossword puzzles of grid sizes between 15x15 - 30x30. The database of words I'm using ranges between 20,000 and 100,000 words of all varying lengths. The current algorithm I'm using takes some inspiration from this paper: https://www.aaai.org/Papers/A...
Task Bulid parsing table for grammar S -> iSeS | iS | a Resolve conflicts in this table and simulate parser work for word iiaea Problem I know how to make a parsing table for unambiguous grammar, and how to simulate parser. However this grammar is an example of dangling else problem. What I tried I was tought that I ...
I have a system of equations $Ax = b$ over some finite field $\mathbb{Z}_p$ and want to find a feasible solution. I'm sure this problem is NP-hard, but I'm struggling to find any literature on the subject. Does this problem have a name? What is known about the computational complexity of this problem?
Question: Show that $T_{NP}$ is NP-complete, where $$T_{NP} = \{m\#w\#^c\mid M_m\text{ is an NTM};M_m(w)\text{ has an accepting computation of $\leq$ c steps}\}$$ This question looks weird to me because itself is a TM. In general, when we say a problem is in NP, we can give an instance of that problem and using NTM ...
I am learning about TCP control flow and came across a question about how much data is carried by the 4th segment. The answer is supposed to be 1200 (2230 - 1030) but I don't quite understand why. By definition, I know that the acknowledgement number is telling the other side what is next expected from it. Thus 5 is t...
The Dikstra shortest path algorithm on a weighted graph, directional or bidirectional, pretty quick. There is also the Bellman Ford algorithm. However, these two find the shortest path between one source to all vertices. However, if I only want to know the path between two vertices, is there a faster algorithm that onl...
I need to know if there's a dynamic programming algorithm that returns all common subsequences between 2 sequences not just the longest one. Thank you.
I am reading the book Database Systems the Complete Book 2nd Edition. A slightly modified Question 13.4.5 states: Suppose we use three disks as a mirrored group; i.e., all three hold identical data. If the yearly probability of failure for one disk is F, and it takes H hours to restore a disk, what is the yearly ...
I'm curious if the origin of any successful computer virus is known to NOT have an intentional, human originator. To put it another way, do computer viruses ever "spontaneously" originate through the process of natural selection in the same way biological viruses originate; without an intentional "designer?" I imagine...
Let us say that our definition of a circuit is the one of a boolean circuit from [Vollmer]. He uses directed acyclic graphs to represent circuits where the computation nodes are labeled with some functions which come from a set of possible operations (called basis). Let us say that we only allow the operation $\land$ ...
I am reading the book "Fuzzy Logic with Engineering" written by Timothy J. Ross and there is a phrase in the book at page 90, he mentions about the "Features of the Membership Function". He says: The support of a membership function for some fuzzy set A under ~ is defined as that region of the universe that is chara...
What is the O-notation (or $\Theta$ notation ) of $\left(\begin{array}{c} n\\ \frac{n}{2} \end{array} \right)$ ? Can I use Sterling approximation : $n! = \Theta(\sqrt{n}\left(\frac{n}{e}\right)^n)$ and evaluate my function as $\Theta\left(\frac{2^n}{\sqrt{n}}\right)$ ?
One of the features the compiler for my programming language is supposed to have is the ability to draw AST-es, to make it easier to detect when syntax doesn't mean exactly what the programmer meant. That part of my compiler is runnable in a browser, you can see it here. Thus far, I've come up with an algorithm that su...
I came across this hoare logic for factorials but I don't quite understand it. We multiply F and X but we're not adding up all values of F so how do we get the sum/factorial at the end? Precondition: $\{ X > 0 \land X = x \}$ $F := 1$ while $X > 0$ do $\quad F := F \cdot X$ $\quad X := X - 1$ od Postcondition: $\{F =...
Define: $ \lg x = \log_2x $. Let $ f(n), g(n) $ be some non-negative functions. Define $ f(n) = \Theta (g(n)) $ if $$ \exists c_1,c_2 \in R\colon 0 < c_1g(n) \leq f(n) \leq c_2g(n) $$ I want to prove that the function defined by the recurrence relation $ T(n) = 16(T/4) + n^2\lg^3n $ has the asymptotics $ T(n) = \T...
Turing Machine stay at first cell and dont move to the left/right. Its condition!!!(Machine can only rewrite content of cell or dont do anything) Turing Machine looped when two iterations in which the content of the cell is same, the state of machine is the same, and therefore these are completely identical(*). And I ...
On Wikipedia, it says that that there are some algorithms that would run in polynomial time if and only if P=NP. They gave one example (without citation), but are there any others? I tried looking them up and couldn't find any.
The problem Given $n$ stacks of $k$ integers each. What is the maximum sum that can be achieved by removing exactly $p$ integers? The following example illustrates the problem. $n$ = 3, $k$ = 4, $p$ = 3 stack 1: 2, 5, 12, 5 stack 2: 10, 3, 12, 50 stack 3: 7, 4, 20, 20 Note that the top of a stack is the leftmost eleme...
In Michael Sipser's book, they prove that ALL_CFG = { G | G is a CFG and L(G) = Σ∗ } is undecidable using accepting computation histories and PDAs. My question is how exactly (with details of implementation)does a PDA go on to compare two configurations and figure out that the first properly yields the second. I know t...
Show that for each string $w ∈ \{0, 1\}^∗$ there exists a stay-put Turing machine $$M_w = (Q, \{0, 1\}, \Gamma, \delta, s, q_{\mathit{accept}}, q_{\mathit{reject}})$$ with $|Q| ≤ 5$ states that starts on a blank tape in state $s$ and ends in state $q_{\mathit{accept}}$ with the tape content $w$ beginning in the first c...
Suppose you have 1 room that you want to rent out. (AirBnb style) You want to maximize profits that you will get by renting it out. For example: Given intervals: [[1, 10], [2, 5], [7, 20], [23, 30]] - you could rent it out [2, 5], [7, 20] and [23, 30] Another example: ([[1, 2], [1, 11], [5, 8], [4, 33], [18, 72]]) = 6...
See here. Knapsack problem -- NP-complete despite dynamic programming solution? The only reason Knapsack problem is NP-complete is because input comes as binary numbers so n is actually 2^n. Since the weight is an axis of the DP array. Then for every single problem, for example one that requires an O(n) loop through an...
Are there any algorithms to find the size of an algebraic quotient of a free group? It would take the generators as input and output the size. For example, an input could be something like {a,b: a^8=b^2=1, ab=ba^3} (a quasidihedral group), and the output would be the integer 16, since there are 16 different ways to wr...
In the context of a distributed database, I'm trying to understand why 2PC (as described in e.g. https://www.cs.princeton.edu/courses/archive/fall16/cos418/docs/L6-2pc.pdf) is better than the following hypothetical protocol between a client, master, and slave: client tells master to commit master commits it master tel...
I have been assigned a task to come up with an algorithm for evenly distributing prizes over a given time frame, I am looking for advice as I am a bit stumped on where to start. Here are my requirements: Prize Types: Prize types are types of prizes which can be added by a user, there can be any number of prize types ...
Question I am considering the use of Cuckoo filter for a business case. To simplify the explanation here is an analogy of my needs: There are over $n = 30 000$ first names that exists in the whole world I have a Cuckoo filter storing the names of people who gave me a gift at least once I am certain that the Cuckoo fil...
Find a function that bounds from above and below (asymptotic) the rank of the root r in an AVL tree, i.e. find a function $f(n)$ so there exists a constant $c>0$ that for every AVL tree with $n$ nodes so $c * f(n)\le rank(r)\le n-c*f(n) $. $rank(r)$ gets his maximum value when his sub-left tree contains maximal number ...
After reading an answer at this link: https://serverfault.com/questions/503345/three-duplicate-acknowledgementss I am confused. Do ACK values repeat when a packet is lost or when an out of sequence packet is received? For example in the diagram, the ACK values are same at the 12th and 13th segment. However, there's a d...
I need to tell whether $\quad\exists a \quad T(n) = \omega(n^2)$ $T(n) = T(\frac{n}{2}) + aT(\frac{n}{4}) + n^2\\\\ \forall n<10 \quad T(n) = 1$ And if there is such $a$ I need to find the minimum one. I have tried to use recurrence tree but im unable to generalize $T(n)$ to a finite sum and im quite out of ideas on h...
I am trying to understand the following text which defines a greedy algorithm for center selection problem: It would put the first center at the best possible location for a single center, then keep adding centers so as to reduce the covering radius, each time, by as much as possible. It turns out that this a...
Suppose I'm using the algorithm below to perform Depth-First Search in a 2d Grid. It seems like it should be possible to adjust it to perform a Knight's Tour with little change. For example I would replace for each offset in ["up", "down", "left", "right"] with for each offset in possible Knight moves. EDIT: I woul...
If you were asked to construct a pda that recognizes all strings over the alphabet {a,b,c,d}, that is L={w | w belongs to (a,b,c,d)*} How would that be constructed? My idea is to have one state as the initial and final state and have all transitions loop on the same state without pushing or popping anything from the st...
This is the first question I'm asking here I'm trying to understand whether we can construct a PDA with a maximum of 3 states for every possible CFL or not? if so how?
I am learning about algorithmic complexities and I have this claim which I need to prove or disprove: $f(n)$ and $g(n)$ are asymptotically positive functions, if $f(n)=\Theta(g(\log(n))$ then $f(n)=\Theta(\log(g(n)))$. Is it true?
I have a set that is too large to hold in memory but I have a function that I can use to compute a value within the set given an index. I'm curious if there's a standard way to shuffle this set, a pseudo-shuffle is acceptable and expected. I imagine a function that is initialized with some parameters, including the si...
Typing out negative weight cycle again and again is kind of annoying, so for the rest of the question I'm going to abbreviate it to NWC. I'm writing an optimized version of Bellman-Ford's Shortest Path Algorithm on a directed, weighted graph. When I give it a regular graph with no NWC's, it works fine, and finds the an...
In many papers like Empirical Evaluation of the Tarantula Automatic Fault-Localization Technique there is a good explanation about how tarantula algorithm can be used with test suits. Is there any book or even explanation of how this could be usefull in case of model checking? with abstract reachability graph?
I know both have runtime complexity $\mathcal{O} (V+E)$, but Tarjan's algorithm does a single DFS pass, whereas Kosaraju's does two DFS passes. Both need extra space (e.g. a dynamic set, often a stack, for the former to keep track of low links, and e.g. a linked list for the latter to do the second traversal in decreas...