instruction
stringlengths
35
29.1k
Problem: I'm looking for an algorithm to find the maximal Euclidean distance between points in a set $R$ and another set $S \subseteq R$. Specifically, given a finite set of points $S$ in $n$-dimensional space, let $R$ be the minimal bounding box of $S$ (so the product of the bounds across all dimensions). I'm only int...
I am trying to prove or disprove the following statement: If $A = (\Sigma, Q, \delta, q_0, F)$ is a complete DFA where $F \neq \emptyset$ then $L(A) \neq \emptyset$ So my initial thinking is to find a counter example. If say we were to construct a DFA with one accepting state, and that state is never reached then the...
Suppose it's possible for a symbol to escape the scope in which it is defined. What are considered the possible policies for handling that? I mean possible in the sense of what choices of language design that could be implemented -- different choices yield languages which differ in this respect. For example, it's conce...
I was going through the text of the book Computer Architecture: A Quantitative Approach. It has a section in Chapter 5 where it discusses the fact that OS code undergoes more cache misses as compared to user code. Here is the text: Although the user code executes more instructions, the behavior of the operating syst...
I have learned that HOG angular bins have values from 0 to 180 since the algorithm uses unsigned gradients. I am failing to understand why. As far as I know gradient orientation is calculated as angle = atan(S_y / S_x) where S_x and S_y are image gradients in x and y directions respectively. Provided that S_y and S_...
Can any expert explain the reasoning behind the constraint in the following formulation of the minimum spanning tree? To formulate the minimum-cost spanning tree (MST) problem as an LP, we associate a variable $x_e$ with every edge $e \in E$. Each spanning tree $T$ corresponds to its incidence vector $x^T$, which is d...
I have developed a locality sensitive hashing algorithm for the 3-way or k-way dot product. When I say 3-way dot product I mean the following. Suppose we have $x,y,z \in [-1,1]^{S}$ for $S \in \mathbb{N}$. Then the 3-way dot product is $\sum_{i = 0}^{S}x_{i}y_{i}x_{i}$. I was hoping to find some applications of the 3-w...
The question is as follows: A scientist creates a new compound, called compound A, that will explode 10 days after being mixed with compound B. This compound A was stored in a label-less bottle on a shelf with $n-1$ bottles of non-reactive material, and the scientist doesn't know which is compound A. There is exactly ...
Can a point be used as the input for a perceptron/neural net? The relationship between the two numbers that make up a 2D point does not affect the output, but does this not matter when the satisfactory weights are found? If I wanted to use a point $(x,y)$ as an input for my perceptron, would I simply have two input nod...
I have the following code snippet for combinations of n pairs of parentheses. def parens(n): if n <= 0: return [''] else: combinations = [] helper('', n, n, combinations) return combinations def helper(string, left, right, combinations): if left <= 0 and right <= 0: ...
Let $\Sigma$ be the alphabet, $0<R<n$ be an integer and let $\Sigma^n$ denote the set of all strings of length $n$ over the alphabet. The task is to find the minimum $m$ such that there exist strings $S=\{s_1, \dots, s_m\}\subseteq \Sigma^n$ that satisfy: $$\forall x\in \Sigma^n\;\; \exists y\in S\colon ED(x,y)\le R$$...
Does there exist a Boolean function for which no sum-of-products expression that minimizes the number of products also simultaneously minimizes the number of literals (counting repetitions)? Minimization methods like K-maps choose one of these objectives and optimize; I am just wondering if minimizing one automatically...
I am trying to create a generalised suffix tree from a very large number of strings using Ukkonen's algorithm, however I run out of unique symbols to use as string termination characters. I was wondering whether there is any way to work around this problem? For example, would it be possible to mark string ends as integ...
Given a network flow $G=(V,E)$ with capacity function $C$ source $s$ and hole $t$, and given 2 edges $e_1 , e_2 $. Find if there exists a min-cut such that only one of the edges belongs to the min-cut. Hope to get help.
let's assume we have ant at node $1$ and she has $\{2,3,4\}$ vertices. How do I compute which one she choose? I mean if the formula $p_{ij}(k)$ is the probability of $k$-th ant at node $i$ choose $j$ node, for example, do I take $j=2$, compute the probability and if it satisfies $random(0,1)<p_{12}(k)$, the ant choose ...
I am learning for my computability and complexity exam in which there is always an exercise to decide whether some problem is decidable or not. In one of the past exams, there was the following problem: Given Turing Machine M, decide whether there exists a prime number on which M halts. I am supposed to decide whether...
In this page: https://en.wikipedia.org/wiki/Lexicographically_minimal_string_rotation there is the Booth's Algorithm for lexicographically minimal string rotation but there is no proof. I can't access to article(https://www.sciencedirect.com/science/article/pii/0020019080901490?via%3Dihub), can someone put here the pro...
I am currently browsing the lecture notes on computability/decidability and I have encountered the following exercise I am unable to solve. Given $M_1$, $M_2$ Turing machines, is it true that for every $x \in \Sigma^*$ $M_1$ performs at least as many steps while working on input $x$ as $M_2$ does with input $x$? Ther...
Is this grammar LL(1)? Would it be a problem that S can be both E/S and E? S -> E / S S -> E E -> letter E -> ‘ S ’ Can it derive ‘a / e / ‘g / s’ ’ / q like this? S - > E / S S - > ‘S’ / S S - > ‘E / S’ / S S - > ‘a / S’/ S S - > ‘a / E / S’ / S S - > ‘a / E / ‘E / S’’ / S S - > ‘a / e / ‘g / s’’ / q
Why is the above statement true? my understanding is: (1)3SAT reduces to X implies X is NP-complete or harder. (2)Set Cover reduces to X implies X is neither NP-Complete nor harder. This contradiction gets me a bit lost as to why the conjunction of 1 and 2 implies that X exists in P. I'm hoping someone can explain t...
This documentation states that the generic structure AnyIterator is a type-erased iterator of Element.
General Given a regular language $L \subset \Sigma^\star$, I wish to generate at least one string not in $L$. (Obviously, this requires that there exists such a string; i.e., that $L \neq \Sigma^\star$. I would be interested in ways to decide this, if any exist.) (Harder) I wish also to generate at least one string not...
I have found this interesting problem in graph theory and geometry which is allegedly an open problem but latest status seems to be from 01/25/02. I can't seem to find any more information about it, not even other papers describing it.
I was doing this problem: A move consists of taking a point (x, y) and transforming it to either (x, x+y) or (x+y, y). Given a starting point (sx, sy) and a target point (tx, ty), return True if and only if a sequence of moves exists to transform the point (sx, sy) to (tx, ty). Otherwise, return False. Examples:...
I was wondering about the possible existence of an algorithm to essentially play an extended version of the game '24'. Essentially, we are given N cards, each between 1 and 10. We aim to use the basic operations (+, -, *, /) and parentheses wherever we like to obtain a desired value T using all of the cards. Assuming t...
A collection $\Sigma$ of polynomials is an algebra if: (1) $\lambda f + \eta g \in \Sigma$ for any $f,g \in \Sigma, \lambda,\eta \in \mathbb{R}$ and (2) $f,g \in \Sigma$ implies $fg \in \Sigma$. We say that $P$ is in the algebra of $\{P_1,\dots,P_n\}$ if $P$ is in the smallest algebra containing $P_1,\dots,P_n$. I was ...
I'm facing the following question : If there is no $\leq_$ reduction, does this necessarily mean that A is not decidable? for any choice of B. thanks in advance.
Pardon me if this is a very naive question. Suppose I search for something on Google and my next-door neighbour searches for the same thing (on Google) at the same time. Do we get the same or different results?
Say we want to write a (MI)LP to model the following problem: Find a parking plan for a set of cars $K=\{1, ..., k\}$ with lengths $\lambda_i$. Parking is organised in lanes $P=\{1, ..., p\}$. The length of a lane is the sum of the cars parking there and may not exceed a specified constant $L$. The goal is to bala...
I am looking for a streaming algorithm for converting a decimal number to a hexadecimal number. I am assuming the input is a string represention of a decimal number (i.e., each character is a decimal digit) in digit-reversed order, and I'd like the output to be a string represention of a hexadecimal number (i.e., each...
In a two-dimensional grid, there are $n$ "snakes" (sets of contiguous grid-blocks). The snakes do not touch each other. The goal is to cut the grid into $n$ rectangles using $n-1$ "fences" (horizontal or vertical lines along grid lines, from edge to edge or to a previously-built fence). It is allowed to "trim" at most ...
I have this question to solve. According to my understanding, it basically requires a turing machine that outputs lines on the tape, with the number of the lines being any prime number. My idea is to take the AKS test's conclusion and making a case that since, calculating primes is a problem that can be solved in poly...
Maybe this is a very ignorant question. I don't understand imperative computing very well, would it be correct to think of it as simply scripting (as in, running one or a few commands at a time, typically run through a shell language, as opposed to writing a fully fledged program)?
Suppose I have a number of items $\{A ... Z$} which are ordered accordingly. Each item has an associated weight, for example $W_A$. Between all items, there's a criterion $c$ which determines whether they fit together. So if $A$ and $B$ don't fit together, maybe $A$ and $C$ do, and then the next fitting neighbour from ...
I am struggling to answer the following question: How many different languages over the unary alphabet {a} are recognized by 2-state DFAs? According to the textbook, the hint was to first calculate the number of 2-state DFAs over that alphabet and then see if any of those DFAs accept the same language. I am able to...
Can a computable program produce an infinite output from its (presumably finite) input? *I wouldn't think so for similar argument as to why it can't compute over an infinite input. A follow on (basically the same?) question: Are there non-halting programs that are computable? Thanks!
Let's say I have an algorithm with time complexity $T_n = T_\frac{n-1}2 + 1$, $T_0 = 0, T_1 = 1$. Assume (Induction hypothesis) $T_n = C\log_2(n+1)$ for some $C$. $T_1$ imposes $C \geq 1$. Therefore from I.H. (plugging in the formula at $\frac{n-1}2$): $$T_n = C\log_2(\frac{n-1}{2}+1) + 1$$ $$T_n = C\log_2(\frac{n+1}{2...
Is there a non-halting program for every undecidable program? is undecidable the "same thing" as non-halting? Thanks!
LT codes are practical fountain codes that are near-optimal erasure correcting codes. Simply stated, for encoding a $n$-block message, each packet first chooses a degree $d\in\{1,\ldots,n\}$ according to a specific distribution, and then $d$ random blocks are xor-ed to create the packet's message. The analysis shows th...
I am having a very hard time understanding tree based DP problems. I am fairly comfortable with array based DP problems but I cannot come up with the correct thought process for tree based problems and I was hoping somebody could please explain their thought process. I will talk about my thought process behind array ba...
My problem is that we have an array of $N$ integers $(N <=5000)$ on the interval $[-10^6,10^6]$. We also have $Q$ queries $(Q <= 10^5)$ giving us some range in the array. For each query, we want to find the number of triplets of indices in the range such that the sum of those array values equal to zero. More formally w...
I was trying to ask this question in StackOverflow, but later realized that this question is more relevant to general computer science, not specific engineering problems. If you think it's not, please let me know. Recently I've found out what CSP(Communicating Sequential Processes) is. According to the article Bell L...
Given a list of sets: a b c -> _ c d -> d b d -> b a c -> a a c -> c The objective is to find the max partition of unique elements with each element corresponding to the set containing that element. I was thinking about ordering the elements in n * log(n) based on occurrence in other groups and then iterativel...
I'm reading about the Hiring Problem in "Introduction to Algorithms" and read Interviewing has a low cost, say $c_i$, whereas hiring is expensive, costing $c_h$. Letting $m$ be the number of people hired, the total cost associated with this algorithm is $O(c_in+c_hm)$. For clarification, this is the algorithm being ...
Program flow and path are discriminated in the literature of program analysis. However, I have failed to find a formal definition of program flow and path. Can anyone please point me to some authentic literature, e.g. research paper or popular books? Also, an example will be highly appreciated.
Is there an algorithm that can efficiently solve the following question? Given a directed acyclic graph G with n vertices each assigned a random color from a set of size <= n - 1 colors, a source vertex s, and two distinct vertices a and b both having the same color and reachable from s. Determine if there exists at l...
In my course materials, there is one sentence about how if CFG is in Chomsky Normal Form, it is not regular, and if it is in Greibach Normal form, it also is not. But when a grammar is simultaneously both GNF and CNF, it somehow implies that the grammar is regular - why is it so? I struggle to understand what would the...
According to Efficient algorithms for interval graphs and circular arc graphs there is an $O(n \log n)$ algorithm for finding the max clique in an interval graph, assuming you have the interval model. Unfortunately, neither the paper nor the references actually elaborate on what the algorithm is, beyond saying that you...
I have to decide for which value of "Klasse" How do i do it? I know that I have to decide on maximum information gain So first off I've calculated the entropy of "Klasse" That is E(Klasse)= -(3/11*log(3/11)+3/11*log(3/11)+5/11*log(5/11)) = 1.067 So how do I proceed from that? I now need to find the first decision node...
When using BFS search on an unweighted graph to find the single-source shortest paths, no relaxation step is required because a breadth-first search guarantees that when we first make it to a node, we have found the shortest path to it. However, my understanding is that Dijkstra's algorithm has no such guarantee becaus...
I am reading OS Concepts dinosaur book which says, "Each entry in the TLB consists of two parts: a key (or tag) and a value. When the associative memory is presented with an item, the item is compared with all keys simultaneously." I checked How does a TLB and data cache work? but it does not say anything about the imp...
I am solving a graph problem, which can be formulated as an integer programme. Based on computer experiments, it seems that the branch and bound method works well. I would like to analyse the running time, and wonder whether there have been other problems where branch and bound method was used and the theoretical bound...
Although I seriously code with computer languages in general since 2010 and as an amateur programmer with programming languages in particular since 2015 (primarily Bash and JavaScript imperative scripts) and codes I wrote are scattered through my Stack Exchange accounts, as in my Code Review SE account, I think I still...
So I have a complete and directed graph with weights. I wish to find the shortest path from S to T that visits all other vertices in the graph at least once. Another important piece of information I might have negative weights but i don have negative cycles. I found this problem very close to the salesman problem but ...
I was given the follow proof: $$T(n)=n+2T(\frac{n}{2})$$ Will prove that $$T(n)=O(n*logn)$$ For $2:$ $$T(2)=2+2T(1)=2\leq 2*log(2)$$ Assume it is correct for $n-1$ in particular for $\frac{n}{2}$ and prove for $n$: $$T(n)=n+2T(\frac{n}{2})\leq n+2(c\cdot \frac{n}{2}\cdot log(\frac{n}{2}))=n+cn(log(\frac{n}{2}))=n(1+c(l...
Given two line segments the problem is to find an intersection point of corresponding lines (assuming that they are not parallel or coincide). There is a Wikipedia article which gives us exact formulas, but there are two of them: one that uses t ratio and approaches intersection point from first line segment and the ot...
This is a question from a competitive programming competition. Given a tree with n nodes and a number k, find the total number of paths of length k in that tree. I know for a fact that a solution can be found by using a centroid decomposition, however I am simply not sure on the exact relationship between the original ...
I'm working on some kind of multiplayer game and for the best experience for the users I want to make sure the rooms are somewhat balanced at all time. By balancing I just mean the amount of users in the room (not score based or anything). I already figured out what the size of rooms should be and how many users there ...
Given a group $G$, the sumset of two sets $A,B$ is denoted as $A+B = \{a+b:a\in A,b\in B\}$. We have that $A+B$ has no multiplicities if $|A+B| = |A||B|$. For practically, let's say $G$ is integer addition modulo $N$. We define an exact cover-eqsque problem. We let $[N] = \{0,1\dots N-1\}$. Input: a set, $S$ of subsets...
How do you prove that there exists no term with the type $\forall t. t$ in System F? I tried searching through Pierce's TAPL and Reynold's ToPL, but could not find anything. I suspect that the proof may involve some kind of model theoritic argument, but I fail to see where to start.
As I've been struggling to get a deeper understanding of monads in Haskell, I started reading about functors and their counterparts in category theory. Keep in mind that I have no background in the latter. According to Milewski(1), any polymorphic function of the type F a -> G a, where F and G are functors, automatical...
In a hypothetical world, we have a machine that can find median of $n$ numbers in $O(\sqrt{n})$. (Of course this machine is not real). Can we use this machine to sort an array in $O(n)$? I don't know how can I approach these type of questions which have a wrong statement as given. I know if the machine also partiti...
Given a group $G$, the sumset of two sets $A,B$ is denoted as $A+B = \{a+b:a\in A,b\in B\}$. We say $A$ injects $B$, if $A+B$ has no multiplicities, i.e. $|A+B| = |A||B|$. We let $I(B) = \max \{|A|:A \text{ injects } B\}$ . For practically, let's say $G$ is integer addition modulo $N$. Given a set $B$, can we determine...
I want to do some research, but I don't think it's important the number of bits it takes to represent the integer input and arithmetic on the abstract machine. So what is the model that addresses this? Specifically, I want to prove that integer factorization is not in P. If the above is a bad idea, then what model sh...
Given an $N\times N$ matrix $M$ whose elements are integers, find the largest element that occurs in each row of the matrix. I tried using hashtable as follow: Idea is to use hash-table(let's call it $ht_1$) to keep track of count of occurrence of each element. Now, To handle case where element repeats in same row we u...
I used the search function and a good amount of google searches, but wasn't able to get a straight answer on how a loop of the form below, is translated to a proper summation where the function derived from the summation is: $O(\log n)$. Example of the for loop: int j = 0; for (int i = 2; i <= n; i *= 2) { j = j...
On my lecture note it was written that "Finding a clique of size $k$ in a graph is NP". Later in an example for reduction the following was written: "Assume we know how to answer "Is there a clique of size $k$ in a graph", then each time we will hide one node of the graph an on the newly created graph we will check Is ...
Moved from cstheory.stackexchange upon request Winskel, in his book The formal semantics of programming languages, on page 58, writes: C[c0;c1] = C[c1] o C[c0] a composition of relations, the definition of which explains the order-reversal in c0 and c1 For me C[c0] is the relation of pairs (s,s') where starting from st...
I came across the following problem: Define languages $L_0$ and $L_1$ as follows : $L_0=\{⟨M,w,0⟩∣M\text{ halts on }w\}$ $L_1=\{⟨M,w,1⟩∣M\text{ does not halt on }w\}$ Here $⟨M,w,i⟩$ is a triplet, whose first component $M$ is an encoding of a Turing Machine, second component $w$ is a string, and third component $i$ is ...
We have an undirected simple connected graph with odd number of vertices. We also know the number $k$ which is actually the closest odd number greater than or equal to $\Delta$. (So if $\Delta$ is even, $k = \Delta +1$ else $k=\Delta$.) i.e $k$ is the least odd number that is greater than or equal to degrees of all ver...
I have a complete directed graph $G:=(V,E)$ with directed edge weights $c_{ij}$ for every distinct nodes $i$ and $j$. Goal: Find the topological order such that the smallest edge weight of the complete DAG that corresponds to the topological order is maximized. Example: Imagine we have 3 nodes and the topological order...
I am learning about Dijkstra's Algorithm and the A* Algorithm and I have manually worked through the graph attached here, which is supposed (I think) to demonstrate that the A* Algorithm is faster than the Dijkstra one. The sequence in which I chose the nodes is indicated by the circled numbers. I can see that the pro...
I am not very well-versed in the world of theorem proving, much less automated theorem proving, so please correct me if anything I say or assume in my question is wrong. Basically, my question is: are automated theorem provers themselves ever formally proven to work with another theorem prover, or is there just an unde...
I have implemented a genetic algorithm to find the evolutionary outcomes of a biological scenario. I simulate the evolution (i.e. optimization) of five traits in my model. I ran my code 100 times and it produced acceptable results, from biological stand-point. I want to highlight that, for biological reasons, my initia...
An exact cover problem is one of the NP-complete problems. Given a family $\mathbb{I}$ of subsets of a set $[n]=\{1,\dotsc,n\}$, whether there exists a subfamily $\mathbb{I}'\subseteq \mathbb{I}$ such that sets in $\mathbb{I}'$ are disjoint and $\cup\mathbb{I}' = \cup\mathbb{I} = [n]$. e.g., $\mathbb{I}=\{\{1,2,3\},\{3...
We can construct a fixed set of combinators with a computational power equivalent to lambda calculus. Can we do the same with typeclasses (ad-hoc polymorphism)? For example, construct a finite set of typeclasses from which we can build general ad-hoc polymorphic functions?
In a Priority Queue we first enqueue according to the priority given to the element? Or we enqueue just like a queue but dequeue high the highest priority element first? Or both ways are acceptable?
Given a planar graph $G=(V, E)$ I am looking for a max cut algorithm with the following conditions : some vertices are in one of the partition sets? Is the algo is still polynomial ? I mean a selected subset of vertices should be in one set of the parttions.
I am a computer science masters student, I come from a background of engineering and not CS. My problem is whenever I have a problem set, a programming task or an exam, I always try hard to understand the question and think for the right answers, but I usually either get stuck or have a wrong answer. When I seek help I...
Am really in need of some explanation, am working on a nlp cyberbullying detection tool which i will deploy to the web using django framework, however, am stuck on some idea, can someone explain to me....What is the main concept of using lexical,linguistic, semantic or syntactic approach in (NLP) and how is applied in ...
I'm reading Turing On Computable Number 1936, specifically the section pictured here: Does anyone see errata here? Should the second m-configuration "c" in the table, have the "final m-config" be gothic e instead of the gothic c used? If this were the case then 010101... could be printed. If not, I'm unsure how 010...
I have a uniformly randomly permuted list of length $n$. I walk through the list element-by-element, and delete an element if it's out-of-order (compared to the previous in-order elements of the list). What I'm left with is a shorter list that's guaranteed to be in-order. Example: The starred elements of this list woul...
My algorithm solves a custom string problem but it loops twice making it $O(n^2)$ time. I'm asking here as I'm a beginner in self-learning algorithms. Decision Problem: Given an input list $A$, can our target string $S$ be made from any of the elements of $A$? If just one element does not exist in $A$ (which exists in ...
I am currently working on an algorithm that will help to improve shaken blurry images. I know there are plenty of them, such as deconvolution, that is pretty useful though I don't really know how to "cook" such things. My current objective is to restore the shaken trajectory and then do some kind of deblurring. (blind...
I read this in my Operating System textbook. Does it mean that the logical addresses generated by compile-time binding scheme are the same as the logical addresses generated by load-time binding? Or does it mean that the logical addresses and the physical addresses generated are the same in both compile-time binding as...
There are $2$ "basic"/"fundamental" data structures due to the way memory works: array linked list Then there are ADT that we implement using those two, for example: stack, queue and more. When we arrive to priority queue we first need to implement and ADT called heap which can be implement using: array tree (which ...
I have to solve an assignment problem between $\{1,\dots, N\}$ agents and $\{1,\dots, M\}$ objects, which comes to maximize : \begin{equation} \sum_{ij}\beta_{ij}x_{ij} \end{equation} where $x_{ij}$ equals one if object $j$ is assigned to $i$, $0$ otherwise. The benefit of such an assignment is the non-negative value $...
I call a string of brackets 'correct' if every opening bracket has a corresponding closing bracket somewhere after it and every closing bracket has a corresponding opening bracket somewhere before it. For example (())()((()())) is a correct string and )()()( is an incorrect string. An operation consists of taking a...
I have the following question in a homework: Let $G = (V,E)$ be an undirected graph, and let $$A = \{ e \in E \mid \text{ s.t. exists an MSP $T$ containing } e\}.$$ We were asked to find $A$ in $O(m \log n)$ time. Any suggestions?
Suppose there are four points (n = 4) which are four dimensional (m = 4) . Lets say these points are : A(4,1,1,1) , B(3,2,1,1) , C(2,3,3,3) , D(1,4,4,4). What is the best data structure to compare all points among one another based on their values in corresponding dimensions ? Aim is to have minimum time complexity . (...
I have a large sparse unweighted undirected graph (20M vertices, 60M edges) and would like to find what I'm calling the "mean center" (the vertex w/ shortest mean distance to all other vertices. Does this already have a name?). I know of an $O(N^2)$ solution: Starting at every vertex: BFS to calculate the mean distance...
I would like to know if $O(n \log n)$ is an exponential speedup over $O(n^2)$?
I am a programmer. I have just deleted a huge amount of code which I painstakingly researched, thought about, coded, then improved and fixed as bugs popped up for a long time. All of that code, which took me a ridiculous amount of time, effort and general "mind work", has now been replaced by a very small number of lin...
There is an exceptionally simple way to embed simply typed lambda calculus with de Bruijn indices in a functional host language (discussed by Carette, Kiselyov & Shan, and by Kiselyov). The construction here, expressed in Haskell, is from Kiselyov's paper: z :: (a, b) -> a z (x, _) = x s :: (a -> b) -> (c, a) -> b s v...
Recently I have studied Kirchhoff's spanning tree algorithm to count the number of spanning trees of a graph, which has the following steps: Build an adjacency matrix Replace the diagonal entries with the degrees of the corresponding nodes Replace all the other ones excluding the one's included in the diagonal by $-1...
I want an algorithm to decide whether a theorem holds in propositional Intuitionistic logic ($IL$). We know $IL$ is $PSPACE$-complete, so we should be able to reduce $IL$ to $QBF$. In Literature i only found reductions the other way around, so im assuming this is not the way to go for writing an algorithm deciding $I...
Given a set $S \subseteq \{0,1\}^*$, the algorithm $A$ is a generator for $S$ if given $n$ random bits $x \in \{0,1\}^n$, $A$ generates an element of $S$ of size $n$, and $A$ can generate at least $\frac{2}{3}$ members of $S$ of size $n$ (for all $n$). $A$ does not have to be uniform. Is there a set $S$ such that t...
I am trying to understand worst case time complexity of quick-sort for various pivots. Here is what I came across: When array is already sorted in either ascending order or descending order and we select either leftmost or rightmost element as pivot, then it results in worst case $O(n^2)$ time complexity. When array i...
I am trying to understand what is the PTAS, FPTAS and what is the difference between them. I found this analysis: PTAS definition vs. FPTAS but I cannot understand what do we mean by saying: "....time complexity is polynomial in the input size and also polynomial in 1/ϵ" ?? Ok n has to do with the linear O(n) worst ca...
We do check for the mantisas overflow in floating point addition e.g. If we are adding $8.02 \times 10^3 + 9.01 \times 10^3 =17.03 \times 10^3$ i.e we get an overflow, so we shift the number right and increase the value of exponent. But does it occurs during floating point multiplication? According to my logic, it shou...