instruction
stringlengths
35
29.1k
I learned two approximation algorithms for the min Steiner tree: The first algorithm: 1- Compute the metric closure G' of G. 2- Compute a min spanning tree T' of G' 3- Construct the union U of the shortest paths in G which correspond to edges in T' 4- Output the Steiner tree T contained in U. The second algorithm: 1-Fi...
I have come across this video on skip lists: https://www.youtube.com/watch?v=UGaOXaXAM5M Clearly, the creation of skip-list from a sorted singly linked list is a randomized algorithm. But I am confused: is it a Las Vegas algorithm or a Monte Carlo algorithm? I feel it is a Monte Carlo algorithm since there is a possibl...
I am still a bit confused by how to convert into CNF even though I have the rules written down. How do I convert the following sentence into CNF? $(I \lor M) \Rightarrow H$ I know I need to get rid of the implication symbol and when its in the form $(I \Rightarrow H)$ or $(M \Rightarrow H)$ then I can see how to do it,...
Given an undirected graph with non-negative edge weights, and two vertices $s,t$ in the graph. I would like to find the minimal cut such that $s$ and $t$ are on different sides of the cut. For example I have a graph describing the network of roads connecting Berlin and Munich and I want to find the minimal cut such tha...
If we know the vertex cover number for a simple graph $G$ denoted by $\tau(G)$, is it possible to find the minimum vertex cover set for $G$‌ in quasi-polynomial time? As I found, we cannot find any quasi-polynomial time solution for NP-hard problems (or at least it is a strong conjecture) such as finding the minimum ve...
Given a graph $G$ where each node has a value $c$ and weight $w$, I want to select a connected subgraph $V^*$, such that, Sum of all values in $V^*$ crosses threshold $t$. Sum of all weights(say $w^*$) in $V^*$ is as low as possible. A practical example is finding smallest continuous area of a country that hosts at ...
Let $A$ be a matrix of size $K \times N$, $K \leq N$. Let $n_1...n_K$ denote a $K$-permutation of integers $1...N$ (understood as a unique assignment of a column to every row in the matrix). How to most efficiently calculate the sum, over all $K$-permutations, of products $A[1,n_1] * A[2,n_2] * ... * A[k,n_K]$? For exa...
Suppose we have a simple graph $G$. We know that finding the minimum vertex covering set for $G$ is in the NP-hard class. But, what about the complexity class of finding the size of the set, i.e., the vertex cover number denoted by $\tau(G)$. Is there any previous result about this research question?
Problem Statement: There are $n$ hours in a day and you have $w$ workers. For each worker $i$ you will be given $x_i$ (work experience), $s_i$ (shift start time) and $e_i$ (shift end time) on a separate line. Here $s_i$ and $e_i$ are both inclusive. At any given hour $t$ in a day, you have to determine who is the mos...
I am writing an application that will maintain heart rate within a specified range by adjusting the resistance on a turbo trainer. I could cobble together something that would gradually increase resistance until heart rate reached the right level but I imagine reaching the desired heart rate quickly, not overshooting a...
If RAM is a short term memory and SSD is a long term memory, why don't microarchitecture of computer nowadays use SSD or another long term memory for saving temporary data like hidden variable for programming? If it's about speed, then SSD can improve its speed, is it possible that SSD will become faster than RAM at so...
Exam question: Draw the Red Black Tree that results from inserting the following values in the given order: [10, 20, 30, 4, 5, 50] Draw the red connections with a dotted line and the black ones with a continuous line. What I understand about Red Black Trees: Every node is either red or black. The root and leaves ar...
I am trying to get my head around the Pumping Lemma to prove a language is non-regular. I am reading the Sipser text book and he gives the following example. Let B be the language $\{0^n 1^n | n \ge 0\}$ Let $s = 0^p 1^p$ I understand that the idea is you can split this string into xyz such that y can be pumped. It is ...
Is there any difference between saying $ L_1 = \{(a^n b^n)^m \mid n, m \ge 1\} $ with $ L_2 = \{a^n b^n \mid n \ge 1\}^+ $? I know that for $v = abab$ we have $v \in L_1$ and $v \in L_2$ my understanding is that there is no difference between them and for $w = abaaabbb$ we have $ w \in L_1$ and $w \in L_2$ . but I have...
Why is it that when I read about finding the shortest path for a DAG I usually just hear about topological sort? Why not use dynamic programming where the shortest path to a vertex is simply the minimum of all vertices that have a path to it?
I have started learning about quantum computing, and I have been told that you can forget about the physics and think of qubits as a natural generalization of the notion of bit. According to this view, one should think about a qubit as a generalization of a bit, where the states $0$ and $1$ are in superposition; there ...
I am curious on the use of the potential method for amortized analysis for a dynamic array which quadruples in size after it becomes full. I understand how the potential function is defined and used for such an array which doubles in size, but am having difficulty showing that the insert operation takes constant time i...
In the alpha-beta pruning version of the minimax algorithm, when one evaluates a state p with $\alpha$ and $\beta$ cutoff and gets a v value, i.e., v = alphabeta(p, $\alpha$, $\beta$) are these properties true? alphabeta(p, -$\infty$, $\beta$) = v when $\alpha$ < v alphabeta(p, $\alpha$, $\infty$) = v when v < $\beta$...
I'm trying to understand why: $$L_{\Sigma^*}=\{\langle M\rangle|L(M)=\Sigma^*\}\notin coRE$$ As I see it TM, $\langle M\rangle$, should accept all the inputs, and if one of the inputs rejected it's not $L(M)=\Sigma^*$ any more, so why it's not? $$L_{\Sigma^*}\in coRE$$ $*$ I familiar with the reductions $HP\le L_{\Sigm...
I want to prove that $L = \{a, b\}^* - \{(a^n b^n)^m \mid n, m \ge 1\}$ is a Context Free Language. so far, I tried to find a Context Free Grammar for $L$ or to use properties of Context Free Languages but have not been successful yet. Any guidance and explanation would be greatly appreciated.
I have some users in groups, like this (groups are letters, users are numbers): { a: [1, 2, 3], b: [4], c: [5], d: [6], e: [7, 8, 9, 10] } I receive a new description of the grouping of these users like this: [1, 2, 3, 4, 5, 6, 11], [7, 8, 9, 10] Now, I need to rearrange the users to minimize "changes", so ...
I am currently studying Chapter 8 of Krama and Hammer's textbook on Boolean Functions, and having a hard time understanding what it means for a function to be "k-monotone." I am currently working off the following definition of "K-monotone" in Chapter 8: A Boolean function $f$ on $\mathcal{B}^n$ is $k$-monotone ($1 ≤ ...
So if we assume that we have some strongly connected component G with n vertices. I would like to find the length of the longest path in that component. My idea is: In a strongly connected component we can get from one vertex to every other vertex. If we start at some vertex u then we can visit each of the remaining n-...
I am studying the maximum matching problem and I was trying to understand why the classical augmenting path algorithm does not work for the general graph (i.e. for non bipartite graph) and you must recur to the blossom algorithm. The explanations that I found (1. here, 2. and here) are based on the fact that the direct...
In QuickSort Algorithm, the pivot is chosen as the first element or a randomised element. However, if the range of data to be sorted is known, For example, from 1 to 100, and they are mostly equally distributed, then, the best choice for first pivot would be 50, even if it's not present in the array, then, for left su...
Often in CLRS, when proving recurrences via substitution, $\Theta(f(n))$ is replaced with $cf(n)$. For example, on page 91, the recurrence $$ T(n) = 3T(⌊n/4⌋) + \Theta(n^2) $$ is written like so in the proof $$ T(n) \le 3T(⌊n/4⌋) + cn^2. $$ But can't $\Theta(n^2)$ stand for, let's say, $cn^2 + n$? Would that not make s...
I am currently self studying approximation algorithms from The Design of Approximation Algorithms (Williamson and Schmoys; page 50 here), specifically the minimum-degree spanning trees (MDST) problem. Given a graph $G$, we need to find a spanning tree $T$ that minimizes the maximum degree of any vertex in $T$. I unders...
I am asked to write an C code Selection Sort algorithm and use loop invariant to show its correctness. We are given array A[1...n] of n integers. (Indexation 1 for clearance. In my code it starts at 0) int i, j, min_index, temp; for(i=0; i<n-1; i++) { min_index = i; for(j=i+1; j<n; j++) if(A[j] < A[min_...
What is the complexity of inverting a $n \times n$ diagonal matrix? From what I learn in algebra, the inverse of a diagonal matrix is obtained by replacing each element in the diagonal with its reciprocal. So is it correct to say that the complexity of inverting a diagonal matrix is $\mathcal{O}(n)$?
My specific problem is as follows: Given two list of texts (in the order of 5 to 50 items) Find best matching pairs with their corresponding matching score (weight) Where each item can only be matched once with another item (from the other list) While minimizing the calculation of the weights (Levenshtein edit distanc...
Given a bipartite graph $(X\cup Y, E)$ with edge weights, it is easy to find a matching in which the product of weights is maximum: replace each edge weight with its logarithm, and find a matching in which the sum of weights is maximum. Now, we would like to find a fractional matching which maximizes the product of val...
I tried to figure out the proof of insertion operation in AVL-tree is O(log n), but I do not know how. I also tried to find it somewhere on the Internet, but I could not find any good results. Do you guys have any ideas how do we proof that?
Given an undirected graph that is represented by its adjacency matrix, return whether or not is it possible to add no more than two edges to this graph in order to make all the degrees of nodes even. Keep in mind that in the resulting graph there should be at most one edge between any pair of nodes. For graph = [[false...
$$L =\left \{ \langle M \rangle \mid \exists x\in \Sigma^* \left(\left | x \right |\leq 10000 \wedge H(M, x\right) \right \}$$ Where $H(M, x)$ denotes whether Turing machine $M$ halts on input $x$. My guess is neither $R$ or $Re$ because I would have to run infinite TM's in order to find out if every TM halts on x or i...
Let's say there's a single process performed in the machine which utilizes all available processors (whether physical or logical processors). The process use 100% processor utilization most of the time on all processors. Which machine will perform better? Machine with 2 cores, 1 thread per core (2 physical processors)...
In the general case of an n bit booth multiplier, the maximum negative value is -2n-1. So with 4 bits we can represent -8 x -8 (M=1000, Q=1000). Now if we follow Booth's algorithm for multiplying n-bit numbers: count A Q Q-1 Operation 4 0000 1000 0 Initial Conditions 3 0000 0100 0 (00) Shift and decrement cou...
Based on CLRS Theorem 4.1, master theorem doesn't apply to $T(n) = 4T(n/2) + n^2 \log n$. However, I saw the 4th condition of master theorem on slides of Bourke. If $f(n)=\Theta(n^{\log_ba}\log^kn)$, then $T(n)=\Theta(n^{\log_ba}\log^{k+1}n)$. So $T(n)=3T(n/3)+n\log n$ can apply to case #2, see for example this questio...
I'm stuck with nested for loops that are dependent on the previous loop: for (i=1; i<=n; i++) for (j=1; j<=i; j++) x = x+1 the part that is confusing me is j<=i. I'm trying to figure out the asymptotic running time.
Suppose P $\neq$ NP. Prove or disprove if language is in P using a reduction or an algorithm: $$ \left\{ \left(G = (V,E), k, 0^{2^{|V|}} \right) \mid (G,k) \in VC \right\} $$ Suppose I have the this input $00000000$ I can construct a TM which calculates the number of vertices by applying log operation. So for this e...
I implemented a hierarchical linkage algorithm for a set of 5,000 points. Each point is defined with a longitude and a latitude. I read about this algorithm here. These are the steps: Compute distance matrix between all points (great-circle distance, not Euclidean) Find the pair of points with the minimum distance bet...
This is the formal definition of a minimum spanning tree taken from Algorithms by Dasgupta, Papadimitrious and U. Vazirani. Input: An undirected graph $G = (V,E)$; edge weights $w_e$. Output: A tree $T = (V,E')$, with $E' \subseteq E$, that minimizes $$ \operatorname{weight}(T) = \sum_{e \in E'} w_e. $$ My confusion...
So I have the following language: C = {<G,w>|G is a CFG in Chomsky normal form and w has more than one parse tree in G} How to prove that this language is in P (decidable in deterministic polynomial time)? I tried to come up with a polynomial-time algorithm and tried to show a reduction to a different language in P, bu...
This is a follow-up to a question that I recently posted here: Completing tasks on a graph. In that question, I posted the following: Consider a graph $G = (V, E)$, where $V = \{0, 1, 2, \ldots, n\}$. The graph $G$ is complete, which means we can traverse $(i, j)$ for all $i, j \in V$. At each vertex $v \in V$, there i...
I know this question may look stupid, but still.. Is the meaning of both "have no satisfiable assignment"?
I saw some proof but I didn't understood it, any simple one?
I don't know if this board would be an appropriate place for this question, but I have been trying to figure out how the divide-by-2 decimal to binary conversion trick works: in which you divide the number by 2, record its remainder and in the end write out the remainders in reverse to the get the final binary string. ...
In a 2007 article, Russ Cox (at presents, he leads the development of the Go programming language at Google) argues that regex engines in languages like Java, Perl, PHP, Python, Ruby are built on a different theoretical framework from implementations like awk or sed. Cox claims a difference in performance between 60s a...
I was reading Introduction to the Theory of Computation by Michael Sipser and I found the following paragraph quite interesting: During the first half of the twentieth century, mathematicians such as Kurt Godel, Alan Turing, and Alonzo Church discovered that certain basic problems ¨ cannot be solved by computers. One ...
I am trying to determine how many bits the TI-83 Plus uses to store floating point numbers. I am using the algorithm for approximating the machine epsilon given in "Numerical Mathematics and Computing" by Cheney and Kincaid. In TI-BASIC, it looks like this: : 1 -> E : While (1+E) > 1 : E/2 -> E : End : Disp 2*E The p...
I am interested in proving lower bounds for AM-like languages. The usual techniques for lower bounds in non-probabilistic machines don't work for probabilistic machines. Intuitively, when I think about showing lower bounds I usually think about showing for any algorithm $A$ some "bad input" that would contradict either...
Alpha-beta pruning is an optimization for minimax that reduces the number of nodes visited without changing the final result. However, both minimax and alpha-beta only return the optimal node value (not the optimal node itself), which means that in practice, a programmer must implement a method for identifying which of...
I am new to this forum as I want to explore data structures and algorithms in depth. I want to know from experts here what books or other resources would be best for someone like me who can be considered just above a beginner as far as data structures and algorithms is concerned.
I am working on a load balancer that schedules tasks that communicate over network. I want to test its performance, but I'm struggling to find test data for it. Currently I try to extract relevant data from google-cluster 2019 (https://github.com/google/cluster-data), microsoft azure (https://github.com/Azure/AzurePubl...
I understand that it's possible to build TM that check all the finite number of cases, so it's definitely in $R$, but I'm not sure why it's in $P$
I am working on a branch and bound problem and I was wondering if it is correct to prune the node with z = 21.667 and if so, how do we know that we will not get a better solution if we branch on this node?
I am studying about algorithm correctness and have enctountered this problem. function add(y,z) comment Return y + z, where y,z are natural numbers x :=0; c:=0; d:=1; while(y>0)v(z>0)v(c>0) do a := y mod 2; b := z mod 2; if a XOR b XOR c then x := x+d; c:= (a AND b) v (b AND c) v (a AND c); d :=2d; ...
I had this question in my exam. but my answer is wrong(I didn't receive explanations why...) $$f(\langle M\rangle,1^n)=\left \{ \texttt{the lexicographically smallest } x\in\left \{ 0,1 \right \}^n \cap L(M) \texttt{ if } n>100\texttt{ and }L(M)\cap \left \{ 0,1 \right \}^n \neq\varnothing \texttt{, otherwise undefined...
I saw a joke on twitter today that got me thinking on how to perform a time complexity analysis of this algorithm such as you can express that the worst case is dependent on the input value in addition to the input size. The joke algorithm was this sleep sort algorithm in javascript const arr = [20, 5, 100, 1, 90, 200,...
Problem: Suppose the running time of a certain algorithm is $O(n \ln n)$. We happens to the running time of the algorithm if $n$ doubles. Answer: Let $R_1$ be the running time of the algorithm when the input is of size $n$. Let $R_2$ be the running time of the algorithm when the input is of size $2n$. Let $R = R_2 / R_...
$f(x_1,...,x_m)=\min_{\emptyset\subset I\subseteq[m] }\left|\sum_{i\in I}x_i\right|, x_i\in \mathbb{Z}\setminus\{0\}$ How to prove $f\in \mathbf{POLY} \Leftrightarrow \mathbf{P}=\mathbf{NP}$? When $\mathbf{POLY}\overset{\Delta}{=}\{ f:\{0,1\}^*\rightarrow \{0,1, \}^* |$ exists polynomial TM which competes $f \}$
Right now I am stuck with the problem, how all shortest path trees can be created in O(n*m) given G = (V,E,c) with negative and positive costs without negative cycles and n =|V| m = |E| after execution of Floyd Warshall. We were asked to think about why this is not $O(n(n+m))$ and for which graphs we really would have ...
(this is a cross-post from mathoverflow) Assume I have an undirected edge-weighted complete graph $G$ of $N$ nodes (every node is connected to every other node, and each edge has an associated weight). Assume that each node has a unique identifier. Let's say I then have an input, $c$ of three edges (e.g $c=[4,7,6]$). D...
I am working through a problem in which I have to prove that a particular $f(n) = \Theta(g(n))$. I know that for this to be true there need to exist positive constants $c_1$, $c_2$, and $n_0$ such that for all $n \geq n_0$, $c_1g(n)\leq f(n) \leq c_2g(n)$. Simply put, the goal is to pick values for the constants such t...
The problem: There are $N$ houses for sale. The $i$-th house costs $A_i$ dollars to buy. You have a budget of $B$ dollars to spend. What is the maximum number of houses you can buy? There is an intuitive way to solve this problem in a greedy way: we must at first sort the house costs and then buy houses until we are ...
In Sipser's Introduction to the Theory of Computation, the provided proof for the union operation being closed for regular languages has a step for the transition function that I find a bit lacking. Assuming that $M_1=(Q_1, \Sigma, \delta_1, q_1, F_1)$ and $M_2=(Q_2, \Sigma, \delta_2, q_2, F_2)$ are two different FSMs...
Recently I thought of an algorithm for multiplication and decided to stop dreaming and start writing on paper my ideas, and even implement this to code (in this case - Python 3.9.1). I do not know if it resembles Karatsuba's algorithm, but I glanced at it and it seems to work very differently. The idea behind this mul...
In CLRS, exercise 4.4-5 the following question is asked: Use a recursion tree to determine a good asymptotic upper bound on the recurrence $$T(n) = T(n-1) + T(n/2) + n$$ In my recursion tree, the sum of level 0 is $$n$$ level 1 is $$(3/2)n - 2/2^1$$ level 2 $$(3/2)^2n-14/2^2$$ level 3 is $$(3/2)^3n - 74/2^3$$ and so ...
I am currently studying the roofline model. Wikipedia [2] shows the following example graph: The diagonal line shows $\beta * I$. But I do not understand why this line does not go through the zero point. If $I = 0$ so should $\beta * I = 0$. What am I misunderstanding here? [2] https://en.wikipedia.org/wiki/Roofline_m...
I was given this problem in class, and I have no idea how to solve it. The problem is: "Given a list of positive integers, divide the numbers into 2 groups such that the difference between the sum of each group is minimal, print that difference. The algorithm must be efficient." I guess by efficient they mean do not ...
I have been give a page table logical address of 0011 0110 1010 1010 and have been told that there are 512 entries into this page table in which the frame number is two times smaller that the page number. I have looked at previous posts but I am still not understanding what steps I must do in order to translate this lo...
I am looking for a technique or an algorithm that outputs a unique number/vector for each pixel of the image. I want to give the pixel a perspective so the neighboring pixels have more visibility and the farther away pixel have less visibility. Imagine if someone walks on the pixels, he sees different patterns, and I w...
I came across the chalk-and-string labyrinth analogy for depth-first search in Algorithms by Dasgupta et al. I have seen the code for the depth first search. Everybody knows that all you need to explore a labyrinth is a ball of string and a piece of chalk. The chalk prevents looping, by marking the junctions you have...
After looking at Can a computer determine whether a mathematical statement is true or not? for a while, I worry we may be into incompleteness/halting problem territory with this question, so an answer on that front, while disappointing, would also be acceptable I've been interested by ADT equations since I read the lin...
Suppose that we have two sums: a1+a2+...+an, b1+b2+...+bm We can perform only two binary operations on operands of these sums: lt (less than) eq (equal) These operations can return 3 possible results: true, false, unknown. Other operations like summation, subtraction and etc. are not allowed. The question is how to i...
Is it known that "For each problem in NP there is a randomized algorithm that solves it in polynomial time"? If not true then is there any proof of that. Or does it belongs to the unknown domain?
Is there a Turing machine such that, given a description $\langle M \rangle$ of a Turing machine $M$, an input $x$ and a string $y$, computes whether or not $y$ is the output of $M$ input $x$? My guess is that the answer is no because this might imply that the set of strings with Kolmogorov complexity greater than or e...
I just watched this explanation of zero-knowledge proofs with Avi Wigderson: https://www.youtube.com/watch?v=5ovdoxnfFV Key claims from the video: Every formal statement can be translated into a map in a way that preserves truth. If a statement is true, its map will be 3-colorable. If not, it isn't 3-colorable https:/...
I'm reading Computational Complexity by Arora and Barak and I had a doubt regarding a statement made about the equivalence of Turing machines: For every $f\colon \{0, 1\}^∗ → \{0, 1\}$ and time-constructible $T\colon \mathbb N → \mathbb N$, if $f$ is computable in time $T (n)$ by a Turing machine $M$ using alphabet $\...
This references the multiplication algorithm in Chapter 1 of Algorithms by Dasgupta et al. I am trying to understand how the code for multiplication à la française works from the multiplication by hand. This is the example given. This is the code given for it. I went ahead and did multiplication of $13 \times 11$ (od...
Given the Language $COMBI := \{\langle G,k \rangle | G$ has Clique $\geq k$ or Independent Set $\geq k\}$. Proof that Combi is NP-complete. I tried to reduce Clique <=p Combi. I had two different ideas: Let $f(\langle G,k\rangle) = \langle G,k\rangle$ so $\langle G,k\rangle \in$ CLIQUE $\Rightarrow f(\langle G,k\ra...
I'm not sure whether the distinction between decision and search problems has a deeper significance or if it is just concerns the immediate answer to the problem. Of course, if you have a finite solution space then you can easily turn a search problem into a decision problem by assigning a 'yes' to whichever output sat...
PCB structure exists inside kernel area. And in ready queue, which is Linked List, each Node of the queue is PCB. And this mean PCB Node has the next address of PCB in the queue, right?? Then My question is this.. Does PCB structure has pointer field that has address of next PCB structure?? According to Wikipedia, Jo...
I'm learning programming, Python 3 in particular, and I have a good book "Beginning Python - From Novice to Professional" by Magnus Lie Hetland, but the book doesn't explain algorithms at all, and I'm having truoble understanding some codes which include recursion since I'm new to 'CS-style' programming, I have moderat...
I'm reading The Algorithm Design Manual and I stumbled upon this problem. I can't really get my head around this, I don't even know how the number of multiplications could differ, what I mean is that there is no polynomial that would make this algorithm perform poorly. I also have no idea how this could get improved, e...
I know that SAT can be reduced to (3 vertex) Graph colouring, and there is a Zero-knowlegde protocol (ZKP) for graph colouring. However, I am interested in a ZKP that can be performed directly on a SAT instance, without graph colouring. Is there a known ZKP for SAT, and if not how would you suggest coming up with one?
Suppose that $A$ and $B$ are languages such that $A\leq_P B$ (many-to-one Karp reduction), and $B\in \mathbf{P/poly}$. How do we prove that $A\in\mathbf{P/poly}$? Using similar ideas like Cook-Levin (or $P\subseteq \mathbf{P/poly}$), I can show that given $x\in\{0,1\}^n$, there exists a (easily computable) poly-sized c...
def RecFunc(n): if n <= 3: return 1 return RecFunc( RecFunc(n/3) + RecFunc(n/2) + RecFunc(n/2) ) How should I start if it is nested inside? I know how to solve it without the outer RecFunc (with a recursive tree I assume) - But here there is an outer RecFunc and I don't know what to do! Thanks to Steven...
I wanted to test the feasibility of an idea that might be part of a small project, and I'm trying to set up a quick prototype using Python (with bindings to a C library). If any of this is sufficient for any interesting application, I might make this the main topic of my thesis. I was able to plot how much memory this ...
In the slides of a university lecture, the following phrase got my attention. Assuming 10GB network, it takes 2 hours to copy 1TB. My calculation was as follows. 10GB network = 10 gigabits per second network = 10 x 10^9 bits per second ------> (1) 1TB = 10^3 x 10^9 x 8 bits --------------> (2) Then the time to copy ...
Let $\chi_S: \mathbb{F}_2^n \to \{\pm 1\}, x \mapsto (-1)^{\sum_{i \in S}x_i}$ for every $S \subseteq [n]$ denote the parity functions from $\mathbb{F}_2^n$ to $\{\pm 1\}$. Then, of course, every $f: \mathbb{F}_2^n \to \{\pm 1\}$ can be written as a linear combination (over $\mathbb{R}$) of the parity functions. I have...
I've built a rudimentary SAT Solver from scratch, and wanted to do the same with SMT solvers as well. While I've found two toy SMT Solver implementations in Haskell and Ocaml, but no tutorials or examples, which is a stark contrast from all SAT Solver tutorials out there. Is there a resource for building a toy SMT Solv...
I was going over the proofs of the non-deterministic time hierarchy theorem (the one in Arora-Barak and the one by Fortnow and Santhanam). They are available here: http://theory.cs.princeton.edu/complexity/book.pdf : page 67 https://blog.computationalcomplexity.org/2011/04/new-proof-of-nondeterministic-time.html It see...
Given a grid graph $G=(V,E)$ which has only two different integer costs/weights of 1 and 2. Find Minimum Spanning Tree in $O(|V|+|E|)$. I tried the following: Changing Kruskal using a counting Sort in $O(|E|)$. But can I say that this results in O(|E|+|V|)? Since Kruskal would normally be ${\displaystyle O(T_{sort}(|E...
As I understand it, A* is a general form of Djikstra where the selection of the next node to visit can be based on something other than the actual distance. For example, with Djikstra, you'd use a priority queue ordered ascending by distance and shift off the head of the queue to decide where to visit next. But with A*...
The reverse of a string, introduced informally above, can be defined more precisely by the recursive rules $$a^R=a,$$ $$(wa)^R=aw^R,$$ for all $a \in \Sigma$, $w \in \Sigma^*$. Use this to prove that $$(uv)^R = v^Ru^R,$$ for all $u, v \in \Sigma^+$. This is exercise 3 (page 28) from "An Introduction to Formal Languag...
I have the following pseudo code for a insertion sort algorithm INSERTION-SORT 1 for j = 2 to A.length 2 key = A[j] 3 // Insert A[j] into the sorted sequence A[1..j-1] 4 i = j -1 5 while i > 0 and A[i] > key 6 A[i+1] = A[i] 7 i = i -1 8 A[i+1] = key I am trying to convert it into execut...
Could someone tell why "G1 and G3 are ambiguous" and how to see whether a string has at least two different left-most derivations in general?
I am thinking about JavaScript here, or any language that supports async IO or that sort of thing (coroutines? though don't have much experience with those). I have looked at some of the resources below in trying to figure out how the stack works when you have async, but I don't understand it yet and don't quite follow...
I am looking for a solution for the following problem: Find the size of a subset of top $N$ elements, where the minimum element is at least $N$, in linear time. Consider the following sequence: $$ 3, 1, 6, 1, 5 $$ The answer here is $3$, with $6, 5, 3$ being in the set found. The value of $N$ is not a given - we're l...
I have a bit of problem in the question below, mainly in the case of incrementing the input size (it doesn't seem solvable to me, like, do we just write $f(n)/f(n+1)$ or...), and also the logarithm ones because I'm not really comfortable with those. I'd appreciate it a lot if you could take the time to explain them to ...