instruction
stringlengths
35
29.1k
If $P = NP$ it's easy to show by induction that the $PH$ collapses to $P$. But would that have any other implications for the relation between $PSPACE$ and $PH$? We already know that $PH \subseteq PSPACE$ and this continues to hold true in the case of the $PH$ collapsing, but would $P = NP$ imply anything else for the ...
Let $QBF_k$ be the problem of determining the satisfiability of a formula of the form $Φ = Q_1x_1Q_2x_2 . . . Q_kx_k φ(x_1, . . . , x_n)$. where each $Q_i$ is one of the quantifiers $∀$ or $∃$. So, $Φ$ contains $k$ quantified variables $x_1, . . . , x_k$ and free variables $x_{k+1}, . . . , x_n$. The problem $QBF_k$ is...
Given the algorithm MYSTERY-ALG(n >= 0) 1 if n < 3 then 2 return 1 3 else 4 return MYSTERY-ALG(n/2) + MYSTERY-ALG((n/2) + 1) I defined a recurrence $ T(n) = \begin{cases} 1 & 0 \leq n < 3 \\ T(\frac{n}{2}) + T(\frac{n}{2} + 1) & \text{otherwise} \end{cases} $ which I guessed to be $O(n)$; I've ...
i figured out this is what i want to know: in Cook's theorem it is shown that SAT is NP-hard. he shows it by showing that sat is at least as difficult like the word problem for nondet. Polynomial Time Machines. I want to know how i would proof that 2-sat is P-hard while showing that 2-sat is at least as difficult like ...
in the cook-levin theorem a nondet. Turingmachine is translated into a formula of the form: $\phi$ = $\phi$$_{1}$ $\land$ $\phi$$_{2}$ $\land$ $\phi$$_{3}$ $\land$ $\phi$$_{4}$. I want to know what difference in the formula there is if i would do the same for a DET. Turingmachine and why these differences may occure. T...
I am trying to understand count-to-infinity avoidance techniques, and came across this topology. Now, suppose the interface eth1 on R1 has gone bad, and assuming that split horizon, triggered updates and poison reverse are all enabled, what is the effect of hold-­down timeout on convergence? Will it help to avoid the ...
word problem: given a language L through a deterministic turing machine, is the word w in the language L? the problem should be decidable, since if there is a deterministic turing machine i can simply turn that into a dfa take the word w go through the dfa step by step and see if i end in an accepting state? I now want...
In the universal relation $UR_n$ problem [1] of communication complexity, there are two players Alice and Bob. Alice gets a string $x \in \{0,1\}^n$, Bob gets a string $y \in \{0,1\}^n$ with the promise that $x \ne y$. The players exchange messages and the last player to receive a message must output an index $i \in [n...
I am wondering as to how to efficiently encode the following subcircuit for a binary satisfiability solver (cnf, and optionally xor clauses, if this helps): eq2 = sum(a, b, c, d, e, f, g, h) == 2 eq3 = sum(a, b, c, d, e, f, g, h) == 3 (All variables binary. That is, eq2 should be set if and only if exactly two...
I'm reading CLRS and there is something I don't understand regarding counting the number of parenthesization, in the Matrix-chain multiplication chapter, the book says: Denote the number of alternative parenthesizations of a sequence of $n$ matrices by $P(n)$. When $n$ = 1, we have just one matrix and therefore only o...
If we have a BST but want to keep it balanced, how much more expensive does adding an element to it become? Clearly adding an element (without maintaining balance) is of time complexity O(log(n)), as we traverse the tree down to the point where we should add the element, but if we want to maintain a balanced tree such ...
I'm trying to understand the implementation of the algoritm here. Please see GammaLowerRegularized(a, x) function. I understand 1st part of the function for x <= 1 || x <= a. The authors use Kummer's confluent hypergeometric function M(1,a,x), because it converges under the specified conditions. But don't understand th...
I was learning about decidability when I thought of this question: If P is partially decidable, is ¬P decidable, partially decidable or undecidable? I think it is Undecidable since if ¬P holds then P doesn't hold, and the characteristic function of P is undefined when P doesn't hold so we can't come up with a character...
Complete graph with n vertices. Walk from vertex u to vertex v of length k. I don't understand how the number of walks between the two of length k is $n^{k-1}$ I've tried this formula on an example where n =5 and k = 2 and I can't even find 5 walks. Any help understanding this formula and example would be greatly appre...
I want to construct a context-free grammar for this language: \begin{align*} L = \{uc^nd^nv\mid \ u,v \in \{a,b\}^* \text{ and the number of a's and b's in } uv \text{ are equal}\} \end{align*} I know how to contruct a grammar for a language that has words with an equal number of a's and b's: \begin{align*} &S\to aSb \...
Given that $\#\notin \Sigma$ and $L\subseteq \Sigma^*\#\Sigma^*$, prove that if $L$ is context-free language then $L' = \{w_2\#w_1 \mid w_1\#w_2\in L\}$ is context-free. I'm trying to prove this in this way: because $L$ is context-free then $G$ is context-free grammar for $L$, then $L(G)=L$. by showing that the revers...
I have a large list (around 200k) of element pairs (e.g. A-B, A-C, B-C, ...). How can I find the largest subset of elements amongst which none are paired? Example of pairs: A-B A-C A-F B-C C-D E-F F-G Here the largest subset would be of size 4, and one of the subsets with size 4 would be: {A,D,E,G}.
In static routing where the network parameters dont change, we can use Djikstra's or Bellman-Ford's algorithm to find the shortest path to send data from source to destination.However in dynamic routing how do we do that?
My lecture notes for complexity says that $\mathsf{ASPACE}(f (n)) = \mathsf{DTIME}(2^{O(f (n))})$ I can prove the forward direction ($\mathsf{ASPACE}(f (n)) \subseteq \mathsf{DTIME}(2^{O(f (n))})$) by building a computation tree of the alternating Turing machine and rejecting after $\ge 2^{f(n)}$ time steps and then me...
I am trying to create a PDA with at most 7 states that accepts the following language over the alphabet $\Sigma = \{a,b\}$: $$ \{a^{2k}b^{3k} \mid k \geq 0\} $$ The tricky part is that multiple push allowed but multiple pop is not allowed. I was able to find the easy solution when multi push/pop is allowed. I am looki...
If we can make memory infinite, why don't we just give Deterministic Finite Automata an infinite amount of states? Why is it useful to define Turing machines and pushdown automata? Bonus question: Can we think of the universe as a big ass DFA? (Standart Model, interaction of particles, etc.) Sorry for the long list of ...
Suppose $f$ is a $\mathbb N$-valued partial function over a subset of $\mathbb N$. If $f$ is computable by a universal register machine program, is the constant partial function $$ g:\text{image}(f)\to\mathbb N $$ defined by $g(x)=1$ for $x\in\text{image}(f)$ and undefined elsewhere also computable by a universal regis...
I want to know what will change if we keep on using {0,1} for our Fourier analysis of boolean functions? What are the things, which can not be performed with {0,1} and can be done with {+1, -1}?
We have this algorithm which is supposed to find max matchings. = ∅; //the matching is initialized to zero for ( = {, } ∈ ) { //for each edge in the graph if ( x and y vertices are free) //check if M U e is a matching = ∪ ; } Give an example where this algorithm does not calculate a max m...
I was curious to see whether or not there was a common algorithm for mapping two unrelated data sets. So for example let's say I wanted to give you a spirit animal based on your name, birthday, zodiac sign, height, and weight. How would someone go about creating an algorithm based on that? Another example is something ...
Assume that the probability that a woman is above 80 years old is 3 times that of a man. How much information (in bits) do you get if you are given that a 80 year old person is a male? How should I approach such a question? I have learned about entropy and how to measure it but do not see any way to apply this knowledg...
Let's start with the well-known minimum hitting set problem (known to be NP-hard): given some collection of sets: $U = \{S_1, S_2, S_3\} = \{\{1, 2, 5, 9\}, \{1,2,7\}, \{42, 13, 23, 1, 2\}\}$ for example, we wish to find some minimum cardinality set $H$ composed of elements from the union of all elements of $U$ of such...
$N$ towns are given, which we can get to by passing through the northern and southern gates. If you enter a town through a gate, you have to use another gate to leave the town. The merchant would like to plan his journey in such a way that starting from any town, he visits all towns exactly once and returns to the star...
I have a bipartite graph $G=(U=\{U_1, U_2,\cdots\}, V=\{V_1, V_2,\cdots\} , E)$ such that edges don't "skip" the $V$ vertices. Meaning, if edge $(U_i, V_j)$ doesn't exist, neither will edges $(U_i, V_k)$ for all $k>j$. All vertices connected to $U_1$ are at the "first" $V_i$s, and all vertices connected to the last $U_...
The following question was sent to me by a friend and I didn't really ask him about its source so I couldn't provide the source of it. I solved the question and I need to ensure my answer not just for him but also for myself since it's important to me too. Question: Prove or Disprove: if $L$ is a decidable language, so...
I was asked to show the equality $ RP(1 − 2^{-2^{n}}) = P $, which seems wrong to me (?). The $ \supseteq $ direction is obvious, and I want to show the other direction. My first intuition was to run the algorithm that gives a false negative with probability $ 1-2^{-2^{n}} $ for $ n $ iterations, which will get me real...
I've been stuck on the following assignment taken from Cognition and Intractability: A Guide to Classical and Parameterized Complexity Analysis: Imagine that the following big-O expressions correspond to the worst-case running times of different algorithms, where $n$ denotes the input size and $p$, $q$ and $r$ are pot...
Alternating Finite Automata is a superset of NFA while being equal in expressive power to NFAs. It is defined by 6-tuple (Q∃, Q∀, Σ, δ, Q0, F) where all outgoing transitions from Q∃ are 'or'ed and that from Q∀ are 'and'ed. Is there an algorithm for converting AFA to ε-NFA, NFA or DFA? I tried searching in Google, but a...
I am developing a system which performs automated room allotment. We have finite number of rooms, each with varying capacity. Each booking request is also of varying size. The goal here is to minimize number of rooms used and minimize room capacity wasted. The only reason why we want to minimize number of rooms used is...
If we some how transform a Binary Search Tree into a form where no node other than root may have both right and left child and the nodes the right sub-tree of the root may only have right child, and vice versa, such a configuration of BST is inherently sorted with its root being approximately in the middle (in case of ...
Imagine that we are designing a system in which we have the action to brake or not brake. How can we write an LTL specification that guarantees that we cannot switch between braking and not braking within three time steps?
Consider a Boolean circuit using (2-input) logical-and, (2-input) logical-or and logical-not as basic components. The depth of the Boolean circuit is the length of the longest path from the input to the output. I wonder if Boolean circuits with a depth Polylog in the number of inputs are sufficient to express any Boole...
As far as I understand pipelining is a way to excecute a instruction every clock cycle. It is a process performed on single cores. My question is how does the control unit handle this, at some point the control unit will have to store results from a completed instruction while simultaneously decode or fetch a new instr...
What is the definition for the length of a regular expression? This question might sound simple, yet I cannot find a definition. Do I only count letters from the alphabet? Do * and $\cup$ count? For example: let r = $(ab)^*\cup$ $a$. What is $|r|$?
Given a graph with $V$ vertices and $k$, find a set $K$ of $k$ vertices of $G$. Let $c(v)$ be the distance (in BFS-like) of the vertex $v \in V$ to the closest vertex $u \in K$. How to choose the set $K$ such that the maximum $c(v) \forall v \in V$ is minimized? This is like a dominating set, but each vertex covers a r...
The problem concerns finding shortest paths in graph from a single source to a single destination. So in a general non-degenerate case of a weighted graph, Dijkstra's algorithm runs in O(E+VlogV). A* runs in expected time O(E), because It uses additional information to find the path faster. Now let's simplify the probl...
Say I have a set of documents $D = \{d_1, d_2, \dots, d_n\}$ in some natural language. Each document $d_i$ consists of a subset of words from a word pool $W = \{w_1, w_2, \dots, w_k\}$. For example, $\text{words}(d_1) = \{w_1, w_5, w_{7}\}$. $\text{words}(d_1)$ is an ordered multiset, but that isn't too important to th...
I saw this question on a test-prep site Given a CFG and a string, what is the relation between the number of leftmost derivations, the number of rightmost derivations and the number of parse trees? and the accepted answer was this For any unambiguous grammar, LMD and RMD is same and we have only 1 parse tree. Ther...
I’ve had this question for several years now but have next to no programming experience, nor good connections to anybody who does. So I decided to see if stack exchange had an answer. The idea is to make a program that takes some linguistic, grammatically correct set of words (such as a sentence or phrase), substitutes...
I got an assignment to create a new data structure, with the following rules: Init - O(1). Insert x - O(log$_2$n). Delete x - O(log$_2$n). Search for x- O(log$_2$n). Find max difference between two values in the DS - O(1). Find min difference between two values in the DS - O(1). I've outlined the basics of the struct...
I have started to play around with HTTP3 which relies on QUIC for transport. I have noticed that I very often have a finite number of Web Transport sessions stream data continuously along side burst-y HTTP3 REST calls. At the QUIC level, all of these streams are going over the same connection and are demultiplexed via ...
If I copy a picture and paste it into Microsoft Word, would there be the difference if I embedded the same picture into another Word file ? Are they both object embedding?(As the object is saved in the document?)
Precondition: true int i = 0; while (i < a.length && a[i] != x) { i++; } Postcondition: (∀ j : 0 ≤ j < i : a[j] ≠ x) ⋀ (i = a.length ∨ a[i] = x) } As I read it, the program has no precondition to be established, thus the precondition is always true? Is it like an indicator: "This program has no precondition"?
I was viewing the solutions of other Leetcode users for the classic "post-order traversal of a binary tree" question, when to my surprise, I found a ton of users simply finding the reverse preorder traversal (because it is considerably easier to implement iteratively), and then reversing the output. To my further surpr...
In Conflict-free Replicated Data Types: An Overview and other CRDT-related publications by Preguiça's group, a dot symbol often appears without definition. What does it indicate, how standard is it as notation, and what field's literature does it come from? For example: $$\{ v \mid \mathrm{wr}(v) \in O \land \nexists \...
I came across one Big Theta expression: Here I am thinking this expression to be valid. But please correct me as the answer doesn't goes in the same way. As per definition of Big Theta.. any function f(n) execution time must lie between c1g(n) (f(n) is greater than this function) and c2g(n)(f(n) is smaller than this ...
Let's say there is a single objective optimization problem SP (e.g. a linear program) and an optimization algorithm SA for it (e.g. simplex). Then applying SA to SP yields an optimal solution s=SA(SP). Now let's assume there is a multi objective optimization problem MP (e.g. a linear program with two linear objectives)...
I have a list of 256-bit binary data to store. Any algorithm for doing lossless compression on it in a way I can retrieve an entry by its index without decompressing the whole data (if possible). The decompressed data will also be stored as binary. I will also need to code this algorithm ground-up in a domain-specific ...
$A_{TM}= \{ \langle M,w\rangle \mid M$ is a TM that accepts $w\}$ $E_{TM}= \{ \langle M\rangle \mid L(M) = \emptyset \}$ The standard proof for the undecidability of $E_{TM}$ is given in this question, right?. Doesn't this automatically create a mapping reduction $f$ from $A_{TM}$ to $E_{TM}$ ? Whenever $w \in A_{TM...
i am relatively new here, so if this was asked before, feel free to redirect me. I am searching for an answer in form of a (iterative or recursive) Formula or even better, an algorithm to list them all. But if you know the name of what i am searching for or have some strategy how i could approach this or tips for liter...
What is the tightest lower and upper bound for the expected maximum value of k IID Binomial(n, p) random variables I tried to derive it : $$Pr[max \leq C] = (\sum_{i = 0}^C {n \choose i}p^i(1 - p)^i)^k$$ $$E[max] = \sum_{C = 1}^n C(pr[max \leq C] - pr[max \leq C - 1]) = \sum_{C = 1}^n c((\sum_{i = 0}^C {n \choose i}p^i...
I have an undirected, unweighted graph $G=(V,E)$, and a function $f:V\to [0,1]$ where $[0,1]$ denotes the interval of real numbers from $0$ to $1$ inclusive. Given an input threshold $t\in [0,1]$, I need an algorithm which returns all maximum sized connected sub-graphs $H\subseteq G$, such that every node $u\in H$ has ...
I read an example of using cosine distance in RGB space, and it pointed out that (eg.) dark red and light red have a cosine distance (CD) of zero because CD only gives you the angle between vectors and doesn't consider length. Fair enough. I wondered if a way to fix this was by making it a four dimensional problem by a...
let's suppose we've got a simple Recurrence Relation: $$ T(n) = \begin{cases} 1 & n=1 \\ T(n-1) + \Theta(n) & \text{otherwise} \end{cases} $$ At lesson we've resolved it, but I tried two other ways of resolution, and I would like to ask you if they're right and which, among all, is the most formal way t...
Suppose given number $k$ and undirected unweighted graph $G=(V,E)$, also given two vertices $s$ and $t$. Can we find $k$ shortest paths between $s$ and $t$ in $O(n+m)$ without term $k$? I read this link but I can't findout the answer of my question. I think this problem can't solve in polytime.
Let $L$ be the set of all languages that satisfy the pumping lemma, including non-regular languages that satisfy it. Is the set $L$ closed under concatenation? I couldn’t prove it or find a counterexample.
Supposed someone came up with a compression algorithm that doesn't iterate through bytes or anything to compress data, does that proves P=NP? That is, an algorithm that doesn't rely on patterns/redundancy occurrence in data to work, but instead on some clever mathematical operations. Such algorithm will be able to comp...
The $y$-fast trie is a data structure for storing a sorted collection of $n$ integers from the range $[0, M)$. It builds on the $x$-fast trie, which also stores elements in this range. The space usage of an $x$-fast trie is $O(n \log M)$ words. To reduce the space usage to $O(n)$ words, the $y$-fast trie applies a leve...
I have received the below question for presentation. It was random assignment, its not my field. What is this specifically in Computer Architecture? how CPU and GPU architecture, memory bandwidth/interfaces, and storage interfaces, all combine to contribute to overall computing performance? How and where can I get th...
I want to know the time complexity of specifically calculating ${n \choose k}$ where it is defined as $$ {n \choose k} = \frac{n!}{k!(n-k)!}. $$ If the factorial function is recursive $O(n)$: def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) then the time complexity would be...
Problem statement- Given a sorted array, print out the pair of elements of the array that have a sum of K, where K is a whole number. The solution to the above problem goes like this: With using the Two Pointers pattern, and Pointer 1 pointing to the beginning of the array and Pointer 2 pointing to the end of the arra...
Let $G = (V, E)$ be an undirected, connected and weighted graph. Let also $(e_{1},\ldots , e_{|E|})$ be some sort of the edges of $G$. Let $w, w' \colon E\rightarrow \mathbb{R}$ such that: $$w(e_{1})<w(e_{2})< \dots < w(e_{|E|})$$ $$w'(e_{1})<w'(e_{2})< \dots < w'(e_{|E|})$$ Prove that the two MST's resulting from the...
Given array of numbers $A[1..n]$. We search for element $x$ with linear search. Also we know that, element $x$ occurs in $A$ and probability of $x$ be in second half of the array is $3$ times of probability $x$ be in first half. What is the time complexity of linear search in average case? Because of $x$ is in $A$, le...
I am trying to build an algorithm to compute the partition of a set into singletons or pairs for a set of cardinality 16. I am doing it in MATLAB and came up with codes that either run forever or require more memory than available. Do you know any time and space efficient algorithm? I have added my function below. func...
I've been given the question in the title: Create a data structure that can insert a string S in O(|S|), string may belong to group A or B (or both). The structure should be able to return a string in it that the amount of lexicographic smaller string from A in the structure equals the amount of lexicographic larger st...
Given the following family of hash functions: $$ \mathbb{H} = \{h_c(x) = (12x + c) \bmod m \mid c \in \mathbb{N} \}, $$ where $m$ is the key size. Prove that $\mathbb{H}$ is not a universal family of hash functions. So I got the following idea: If $m = 12 $ then $H$ is not an universal family of hash functions. ...
We have a cake of length $n$ and we have two arrays $A$ and $B$ of size $n$. The two arrays have order like below. $A[0]<A[1]<\dots <A[n]$, $B[0]>B[1]>\dots >B[n]$. We define a envyless location as a cut in the cake where it satisfies $A[i]=B[i]$. For example, $A=[1,2,3,4,5,6,7]$ and $B=[7,6,5,4,3,2,1]$, $A[3]=B[3]=4$,...
I am really confused about this. I am trying to prove that the worst case of heap sort is Ω(nlogn) but i don't even know how to start.
Supose we have $n$ customers with interval that represent their range. For example, $[1,8], [2,5], [4,6], [1,9]$ for each customer. For a customer to have range coverage, a tower must be present within their range. For example, for customer $[1,8]$ to have coverage, a tower must be within range $[1,8]$. I need to make ...
Given an array of numbers with length $n=3^k$, we try to find an element that occurs more than $\frac{n}{3}$ times. So work as follow: We divide the array into 3 parts of equal length. Find recursively a candidate $x$ in each partition and do a scan on array to find number of occurrence of each candidate and then retu...
Suppose given two arrays $A$ and $B$ with length $n$. Array $A$ is sorted and $B$ is unsorted. Is there any lower bound for computing $A\cup B$?
I read this link and I have similar question. Suppose given two Arrays $A$ that is sorted array with length $n$ and $B$ unsorted array with length $n$. We want to find union of two arrays (i.e. we try to compute $A\cup B$) with comparison computation model. Can we claim that the lower bound of this problem is $\Omega(n...
Consider the following proof from Papadimitriou's "On the Complexity of Integer Programming": Corollary 1. There is a pseudopolynomial algorithm for solving m x n integer programs, with fixed m. Proof. We can solve the m x n integer program Ax = b by dynamic programming, proceeding in stages. At the jth stage we compu...
Savitch's Theorem states that $NSPACE\left( f \left( n \right)\right) \subseteq DSPACE\left( \left( f \left(n \right) \right)^2 \right)$ for any $f\left(n \right) \in \Omega \left( \log{n} \right)$. The proof I am familiar with states the following: we are given a non-deterministic turing machine $N$ for our language $...
The subset sum problem is: given a list of $n$ positive integers, and a positive number $T$, find a sub-list with largest sum that is at most $T$. The problem can be found in time polynomial in $n$ and $T$ by dynamic programming: for each integer between $1$ and $T$, record whether or not there is a subset with this su...
Using IEEE 754 algorithm i assume, that it can be implemented in a branchless way. But how does CPU determine special cases (Reserved Exponent values): Exponent Significand is 11111111 000000000... Inf 11111111 000001000... NaN 00000000 000000000... 0 00000000 000001000... Subnormal Without any tricks...
A chain-complete partial order (equivalently, a pointed dcpo) is a set $D$ with a partial order $\leq$ such that all chains of $D$ have a supremum. The least upper bound ($\bigsqcup$) of the empty chain is the least element $\bot$ of the CCPO. A function $f\colon M \to N$ is monotone if for all $a, b \in M$, the follow...
In university, I was taught the computational model hierarchy given in the following figure: https://devopedia.org/images/article/210/7090.1571152901.jpg Essentially, Pushdown Automata (PDA) can solve more problems (i.e. recognize more languages) than Finite State Machines (FSM), Turing machines (TM) can solve more pro...
In Agda, if I disable axiom $\mathbb{K}$ I'm not able to prove $$ \forall\{A : \textbf{Set}\}\{a\ b : A\}\{p\ q : a \equiv b\} \to p \equiv q, $$ which I guess is normal since the system does not truncate equalities. However, I'm still able to prove transitivity $$ \forall \{A : \textbf{Set}\}\{a\ b\ c : A\} \to (b \eq...
AVL trees are height balanced binary search trees. As a consequence of this balance, the height of an AVL tree is logaritmic in its number of nodes. Then, searching and updating AVL-trees can be efficiently done. The fact that AVL-trees have logaritmic height can be shown by analyzing "minimal" AVL-trees, where for eac...
First time posting on here; if this question is too rough I would appreciate if you could point me to a stackexchange forum where this question may be a better fit. Generative adversarial networks (GANs), introduced here by Ian Goodfellow, are a setup to train a neural generator $G_\phi$ which is supposed to learn to g...
I am writing a blockchain as a side project in Go and I am struggling to find good a theoretical treatise on the subject. The information online is either too basic or too specific. Thanks
Here is a dominance frontiers algorithm, mentioned on Wikipedia: for each node b dominance_frontier(b) := {} for each node b if the number of immediate predecessors of b ≥ 2 for each p in immediate predecessors of b runner := p while runner ≠ idom(b) dominance_fro...
I'm having trouble understanding lamport timestamps in practice and how they guarantee causal ordering. Definitions Lamport defines the "happens before" relationship in his paper. He states that an event a happens before an event b (denoted as a -> b) under the following conditions: (1) If a and b are events in the sa...
Let $P_1P_2...P_k$ be a page sequence that gives $n$ page faults with the optimal page replacement algorithm. Does the page sequence $P_kP_{k-1}...P_1$ give the same number of page faults. This can be proved quite easily in the case of LRU, and disproved for FIFO. Does it hold for Optimal Replacement?
I am given an undirected, weighted graph $G$, on its base I have to create a spanning tree with such a property that the difference between the largest edge weight and the smallest edge weight is the smallest possible. I know how to find a minimal spanning tree, e.g. using Prim's algorithm or Kruskal's algorithm, but I...
Given a BST $T$, $x$ is a random node in it and $y$ is the right child of $x$. How does the PostOrder traversal of BST $T$ change after we rotate the tree left on node $x$? In which cases does the traversal not change? My Attempt: I've decided to draw a sketch of the sub-tree of $T$ rooted in $x$: x ...
Everyone knows that merge sort will continuously divide the array into halves until they are small enough to (like 2 elements per block or so) be able to be sorted quickly, hence its time complexity being (n*log n). n part being the merge and log n being the splitting part of the algorithm. But how would the algorithm ...
Is it possible to enumerate through all the Turing Machines that solve the same given problem? For example, we know that there exists a Turing Machine that finds a satisfying assignment given a 3SAT formula. Therefore there are infinitely many 3SAT assignment finder Turing Machines. Could we enumerate all of them? Intu...
This MIPS code is given: loopA: lw $t0, 0($s1) # $ array element addu $t0, $t0, $s3 # add scalar in s3 sw $t0, 0($s1) # store result addi $s1, $-4 # decrement pointer bne $s1, $zero, loopA # branch if s1!=0 loopB: lw $t0, 0($s2) # $ ar...
What is the time complexity of finding the kth smallest element of all the elements in two order statistics binary search trees? An order statistics tree is a binary search tree where the size of a subtree at each node is stored at that node. Taking the root of the first tree and trying to find the largest element not ...
I have a hierarchical graph structure on a vertical timeline with nodes that have a fixed y coordinate. I am now looking for: an algorithm (suggestions, any related papers, anything at all) to optimize the x of each node to reduce edge crossings (and generally increase graph readability). One idea that I have been ex...
Double-SAT = {: has at least two satisfying truth assignments}. Hint: reduce from SAT. Start with a formula and modify it to get a formula so that is satisfibale if and only if has at least two satisfying truth assignments. If is not satisfiable, then also needs to be unsatisfiable. How do I the problem lies in...
So I've boiled a certain problem I have down to the point where I have two images of (approximately) the same scale. One which contains a closed curve, and one which is a partial curve. I want to determine what rotation and translation (and possibly scale, though for now that is not required) will best map the partia...
One definition for $P$ is the set of all languages that have a deterministic turing machine $M$ s.t. if $x\in A$ the machine accepts in polynomial time and otherwise it rejects, also in polynomial time. There is no loops, so $P\subseteq R$. One definition for $NP$ is having a certificate and a deterministic turing mach...