instruction
stringlengths
35
29.1k
We need to find mth smallest possible distance by considering all possible pairs. I solved this problem by considering all possible pairs and maintaining a max priority queue. If the max priority queue size is less than m I push the current distance into it. Otherwise, if the size of the priority queue is greater than ...
I have two sets of vectors: A and B. I want to find the vector Bi in set B that is maximally distant from the vectors in set A, either by average distance or closest distance. I know that I can accomplish this by comparing every vector Ai in A with every vector Bi in B, but that will be very costly. It is acceptable fo...
Suppose $A$ and $B$ are arrays of real numbers of length $n$, and $M$ is another real number. One algorithm for finding indices $i$ and $j$ such that $A[i] + B[j] = M$ is to comparison-sort $B$ and run binary search with argument $M - A[i]$ on it $n$ times, which gives an $O(n\log n)$ algorithm. The source I have claim...
This question is asking for clarification on what P=?NP is asking specifically. I've read the official problem description: here and it seems like P=?NP is primarily concerned with inputs that result in a 'yes' from the solver. For subset-sum, this would be inputs that do have a subset that sums to T. My question is th...
Say that your friend picks a word $(w_1, w_2,\dots,w_n)$ according to a known probability distribution $(p_1,p_2,\dots,p_n)$. You ask yes or no questions until you are certain which word has been chosen. For example, you can eliminate a subset $S$ with the question "Is the word in $S$?" The cost of the guessing strate...
I've got a basic implementation of a Pushdown Automaton which recursively checks the rules of a grammar in CNF to find whether a given input string is accepted or not, and it can also count the number of possible derivations of that string. My problems lie when the grammar has rules which could create infinite loops, e...
I am reading the "Reaching Agreement in the Presence of Faults", M. Pease et al and trying to understand their proof for the $n \geq 3m+1$ case. In the induction step $m \gt 0$ it says the following: ... Any other set satisfying these requirements, moreover, must contain a nonfaulty processor (since it must be of...
I have been reading up on 2D Turing machines on wolframscience and I am kind of confused about what exactly is the relationship between 2D Turing machines (like Paterson's worm and Langton's Ant) and Cellular Automata. I understand that they are both defined pretty differently but I keep seeing references between one a...
I faced this problem in a hiring challenge which is now over. I wrote a solution for the problem but at that time the judge gave me wrong answer. Afterwords I thought about the solution but couldn't find any problem with my logic. Maybe I made some implementation mistake during the contest (I'm not sure). But now I hav...
There are $n$ closed boxes and one and only one box of them contains a prize. The $i$-th box has probability $p_i$ of containing a prize. A player must pay $c_i$ coins to open the $i$-th box. The player must open boxes until the prize is found, then the game ends. Find the optimal box opening strategy that minimizes th...
Let's suppose we have a square grid board like the one shown in the picture below: I'm wondering how I can find the path with minimum number of "bending" points (like the ones shown in red) between two given squares ("Start" and "Finish"). The board has some impediments or broken squares on it (Black squares). I tried...
I'm pretty sure there's a textbook solution to this problem, but I haven't figured it out. I have fixed-size blocks of data arranged in a sequence: block 0, block 1, etc.. There are reader threads that read through the blocks sequentially. There are writer threads that append new data to the empty space in the last blo...
I am interested in finding a Linear Transformer which only uses ONLY matrix operations (more specifically matrix-matrix multiplications during training and matrix-vector multiplication in inference time). The linear transformer should avoid elementwise operations like the GeLU (Gaussian error Linear Unit) in SLiM (Sub-...
Consider the following algorithm: function randomQueries(A, n <- A.size) if n > 1 then p <- n - 1; x <- partition(A, p); randomQueries(A[0,1,...,x-1], x) randomQueries(A[x+1,...,n-1], n-1-x); for y = 1 to x do for z = x + 1 to n - 1 do query(A, y, z); else if n = 1 then query...
Let $G = (V, E)$ be a directed graph with negative edge weights and no cycles, and $L:V \to \mathbb [0, \infty[$ be a function defined over this graph. This graph represents all possible paths a particle can take to go from a starting node $s$ to a final node $t$. Every weight represents the amount of energy the partic...
Is there a polynomial-time algorithm for distribution of clauses of arbitrary symbols (i.e. similar to multiplication distributing over addition)? For simplicity, let's assume the distributive operation is concatenation and the symbols are letters in the English alphabet. For example, the clause (a b c) distributed wit...
I'm trying to work out how to make the working implementation of fitting the straight line among the set data points. I base my function: pub fn sum_squares<Q: CanBeLabel>(l1: &Line<Q>, accuracy: u32) -> Point { let mut dataset_size: f32 = 0.; let (mut y_mean, mut x_mean): (f32, f32) = (0., 0.); let (mut ...
In number theory, progress is sometimes guided by people stating a specific Diophantine equation that they don't know how to solve. Is there anything similar in the field of Boolean satisfiability? More specifically, is there an instance of $3$-SAT in less than $100$ variables that people have tried to solve (by exhibi...
The standard technique to show NP-completeness of $L$ seems to be to show that $L$ is in NP, and then to show that some NP-complete language can be reduced to it. What if one tried to show it the other way, i.e., if L $\leq $ 3SAT? Wouldn't that be one one step way of showing that the language $L$ is in NP-complete?
Given a boolean formula $F$ of length $n$ defined over a fixed number of variables (say 50), is it NP-complete to decide whether $F$ is satisfiable?
Given: a finite collection $V$ of bi-infinite linear sequences of two-dimensional integer lattice points, each sequence ${V_i}$ given by $\cdots,\vec{{V_i}_{-1}},\vec{{V_i}_0},\vec{{V_i}_1},\cdots$ where $\vec{{V_i}_j} = \vec{{V_i}_0} + j \times \vec{d_i}$ for $j \in \mathbb{Z}$. (A natural way to represent a sequence...
Let $f:\mathbb{N}^{p+1} \to \mathbb{N}$ a primitive recursive function and $g:\mathbb{N}^{p+1} \to \mathbb{N}$ the bounded sum defined by : $g(\bar{a},x)=\sum\limits_{i=0}^x f(\bar a , i)$. To show that $g$ is a primitive recursive function we want to show that $g$ is closed under the primitive recursion : $g(\bar a, ...
I just can't figure out the difference between these three classes of complexity, does anyone know the difference and can explain it in a simple, direct way without too many definitions involved? Thank you very much!
I was watching this video on statements. There is an example: $x + \frac12 = 2$ It's an open statement as the truth value could be T or F depending on the value of $x$. $∃x: x + \frac12 = 2$ and $x ∈ ℤ$ Now the statement is closed statement (proposition) as the truth value is F. But later the professor said: $x + ...
My class had a discussion prompt that stated "Many programming languages, especially older ones, provide no language support for concurrency. C and C++ are examples of such languages." I thought C had the fork() command, maybe it's talking about an older version? I was then curious whether there were more languages tha...
Consider an acylicic directed weighted graph in which the nodes represent cities and the weights represent the amount of fuel a car spends when going through that edge. At each city $u$ the car refuels an amount equal to $F(u)$ of fuel. The car cannot traverse an edge if it doesn't have enough fuel to do so. Consider ...
Consider the following bfs pseudo code that calculates distances of all nodes from $s$ in graph $G=(V,E)$. I know that if $G$ was undirected and unweighted, then the above bfs would calculate correct distances. However, I'm not sure if it would still work if $G$ is directed and unweighted. Basically, what I'm asking i...
There are infinitely many different $PDAs$ for the same $CFL$ exist, therefore we can't check equality for $CFL.$ But also there are infinitely many different $DFA$ exists for same regular language. So why equality of regular is decidable but not for $CFL?$
I had a doubt in the proof by contradiction technique. Under this technique, we assume the negation of what we want to prove as true, then show that assuming so generates a contradiction. Since a consistent system cannot have a contradiction, so our assumption must be false and the original statement must be true. The ...
Let's say you have a maximum integer flow function in a network with 7 directed edges, meaning the flow cannot be increased anymore. The capacity of each edge is then increased by one. The capacity of all edges is always an integer, and so is the flow. Is there an algorithm that can find a maximum flow in this new netw...
Given a graph $G=(V,E)$, I'm looking for a way to orient its edges in a way that will bound its out degree. For example, I can bound the graph's out-degree by $\approx 2\cdot a(G)$, where $a(G)$ is $G$'s arboricity by simply assigning all vertices that have at most $2\cdot a$ unassigned neighbours to a set. Then, marki...
I'm trying to create an algorithm that finds the percentage of similarity between two subjects with sets of survey questions. Example: Q1: Do you prefer physically demanding tasks? A1: Nope Maybe Yes --> Subject_1 Choose Maybe / Subject_2 choose Yes Q1: Do you prefer the outdoors? A1: Nope Maybe Yes --> Subject_1 Cho...
I'm trying to devise a $O(|V| + |E|)$ algorithm to calculate number of shortest paths between $s$ and $f$ on a undirected, unweighted graph. Can someone please check my pseudo-code? Also, isn't $O(|V| + |E|) + O(|V| + |E|)$ = $O(|V| + |E|)$?
For example exist linked list with thousands (maybe million) elements or very deep tree which some branches are very long and have only one child, but exists other short branches with many children. How process this lists and trees changing very deep recursion to iteration? I have struct Node { Node* next; }; but al...
Given a suitable lattice and a monotonic function $F$, we can compute the bisimilarity of a labeled transition system (its greatest bisimulation) by computing the greatest fixed point of $F$ using Knaster–Tarski. I was wondering if the least fixed point of $F$ has any meaning to us or if it's worth computing. It is cle...
Two main disadvantages of Huffman encoding is that it makes two passes over data: First pass: Find out sequences frequencies $f(\cdot)$ of letters $c \in C$ in the document $D$. Then constructing Huffman optimal tree before transmitting the tree to the receiver. Second pass: encode and transmit the letters themselves ...
The mentioned problem: Cluster Editing Problem. I need to code this problem but i can't understand the algorithm behind it, even when i try to search for resources about graphs into the web; can anyone helps me to face the problem?
Found this question about Shannon's expansion. While I am trying to follow its logic, found one super convenience simplification used. Can we do this in general while dealing with boolean algebra? or only in Shannon's expansion? Can we just turn b+d into 1 while we have (+)⋅1 previously in the equation? Also + into 1 w...
We know that every $CFL$ has infinite configuration space. Due to this equality problem is undecidable. But why finiteness property is decidable inspite having infinite configuration space?
the scheme of iteration ? Here is the scheme of iteration : for $g : \mathbb{N}^p\to \mathbb{N}$ and $h:\mathbb{N}^{p+1}\to \mathbb{N}$ two primitive recursive functions we associate $f: \mathbb{N}^{p+1}\to \mathbb{N}$ defined by : $f(\bar a, 0)=g(\bar a)\\ f(\bar a, x+1)=h(\bar a, f(\bar a, x)).$ Here is my attempt :...
I read that Rice theorem applicable only for language property not for machine property. But today I have read from stack exchange and one site they are applying Rice theorem on machine also. My question is could we for both or language only?
As we all know it is $NPH$ to check whether $G=(V,E)$ is $k$-colorable or not. It is also hard to find the chromatic number of $G$. But I'd like to ask what are some good (or best known) approximation for coloring a general graph? More formally, I am looking at a graph $G=(V,E)$ for which I do not know the chromatic nu...
The algorithm of Wigderson (see here) can color a graph that is known to be $3$-colorable in $O\left( \sqrt{\left| V \right|} \right)$ colors. This is done in $O\left( |V| + |E|\right)$ time. For those who are not familiar with the algorithm, I'll give a brief description of it (it can be used for any $k$-colorable gra...
I am given 2 sets of n 2D Points. I need to find the segment set S where each of the n segments has its start and end in the first and second set respectively. The requirement is that each point must be used only once and that the set S must be the one with the lowest number of collisions between each pair of segments....
I read that it is undecidable whether, given a CFG $G$, $L(G)$ is regular. And there exists no algorithm that, given a CFG $G$ such that $L(G)$ is regular, outputs a DFA that accepts $L(G)$. My question is, why is regularity decidable for DCFLs and undecidable for CFLs?
I am creating a class to store large integers in a residue number system. I want each "integer" to be 4-12GB in size and be comprised of 64-bit moduli. These moduli must be pairwise coprime to each other. However, in order to maximize the maximum integer I can store, I want the average moduli to be at its greatest. I c...
You know that Rice theorem is applicable to check decidability of RE language. Also we know that all regular, deterministic context free, context free, recursive languages are RE languages. $Q_1:$ So my question is that could I apply Rice theorem to check decidability of for example emptiness, membership etc of CFL lan...
I have a set of objects and a set of comparison results for some of them. I want an algorithm that returns the next comparison I should make to two objects towards having a way to know the full order of all objects. If the order of all objects can be already known I should get the objects ordered. Requirements: ask for...
I know from [1] that the lower bound for the maximum hitting time of simple random walk on a dynamic graph is $\Omega(2^n)$. Smoothed analysis has been applied to the maximum hitting time [3] and gives us a $k$-smoothed lower bound of $\Omega(n^{5/2}/\sqrt{k}\log{n})$; a significantly weaker lower bound. In [3] they gi...
My definitions of reliability and availability are as below respectively . reliability := property of failure interval . availability := property of occupancy rate . I want to show the differences between reliability and availability using some example but currently I've been failing to come up with it . I came up with...
urestricted -> turing machine context-sensitive -> linear bounded automaton (LBA) context-free -> pushdown automaton (PDA) regular -> finite state machine Hi, I am kind of confused about relation between LBA and PDA. Is the stack in pushdown automaton bounded (not using infinite space)? If not, how can a LBA ac...
Recently, I came across several parameters of graphs. So I know in general graphs, it might be hard to compare between them, but I'd like to try and see which upper/lower bounds can be made. Some parameters are: arboricity $a(G)$, maximal degree $\Delta(G)$, degeneracy $d(G)$, minimal degree $\delta(G)$, chromatic numb...
Recently I'm studying 3SAT problem, which is a NP-complete problem. I feel that it's easy to find a boolean formula which is satisfiable,but how about boolean formulas which are unsatisfiable, namely 3-co-SAT problem. Can you help me provide some examples of 3-co-SAT? The definition of 3SAT problem is supplemented here...
Membership problem of Recursive languages are decidable. My approach: Let $L$ be a recursive language and $M$ be the Turing Machine that accepts it. For string $w,$ if $w ∈ L,$ then $M$ halts in final state. If $w ∉ L,$ then $M$ halts in non-final state. (halts always!). That's why Recursive languages are decidable fo...
I'm stumped on how you would describe a language which is a* except for aa, so the following is acceptable: a aaa aaaa aaaaa ... It's for part of the below DFA
I have a collection of points $C := \{x_1, \ldots, x_{60 N}\}$ in 3D space. I am looking for a partition of $P$ of $C$ with the following properties: Each of $P$'s sets contains $60$ points, i.e., $P = \{p_1, \ldots, p_N\}$ where $p_i = \{x_{j_1}, \ldots x_{j_{60}}\}$. The set of centroids $\{c_1, \ldots, c_N\}$ where...
Background: I'm trying to solve this leetcode problem: regular-expression-matching. My approach is to implement a LL(1) parser generator, might be overkilling for this problem but it's just a brain exercise. I only have entry level knowledge of parser theory, so excuse me if this is a silly question that I ask. So, the...
I have a set of variables $\{x_i\}$ that I want to optimize according to some objective function. However, I would like that $$(x_i-x_j)^2 \geq d^2\ \ \ \mathrm{for\ all}\ \ \ i,j$$ Which is a lower bound quadratic constraint, turning the problem non-convex. Is there anyway to formulate this constraint to be convex, fo...
I have seen proofs of this particular problem in a few articles/papers (which lead to a ZKP 2 nuclear warheads are similar), but I find a problem in the proof with the marbles - surely the proof doesn't work because the experiment cannot be repeated. Proof outline: The prover claims a pair of cups each contain $n$ mar...
Yesterday I came up with a divide-and-conquer algorithm about all subarrays of length k of an array of length n. Outline: function solve(array, k): if array shorter than k: return default value left = solve(left half of array, k) right = solve(right half of array, k) middle_crossing = combine(left hal...
What are some ways with which we can improve the speed of dynamic RAMs?
Given a set of strings, and a pattern - we want to compute the subset of those strings that have that pattern as a subsequence (not substring). Everything I've read of suffix trees refer to computing substring, not subsequences. Are suffix trees appropriate for matching subsequences as well? Or are there better datastr...
I'm having trouble understanding why RB tree insertion is called more effective in all sources. It's said that AVL trees require "more rotations" than RB trees, but from what I've learned I can't see it. AVL trees always require one or two rotations, after which the affected subtree gets rebalanced and therefore the wh...
Consider as an example the following setting. A set of universities want to keep track of the joint list of students. Ideally, each university will have a "consistent" copy of this list, and whenever some student joins/leaves any of the universities, all the lists get updated accordingly. Alternatively, we may consid...
Suppose we have matrices $A_0,⋯,A_{n−1}$ (you can say $n $ matrices). Matrix $A_i$ is with dimension $d_i\times d_{i+1}$. If we would like to find all possible permutations to find the best parnthesization possible, that would take $4^n$ time complexity, any idea here please? For example, $B$ is $3x100$, C is $100 \tim...
Let $S= \{ b_{11}, b_{12}, b_{21}, b_{22}, b_{31}, b_{32},\dots, b_{n1}, b_{n2} \}$ be a set of $2n$ balls grouped in $n$ pairs, and $T = \{ B_1, B_2, \dots, B_m\}$ be a set of $m$ bins with capacities $\overline B_{1}, \overline B_{2}, \dots, \overline B_{m}$, respectively. Considering that each ball is stored in exac...
If you take Brainfuck and modify '<' to move the tape head to the beginning of the tape, would this modified Brainfuck still be Turing complete? It feels like it should be, but I can't wrap my head around how you'd emulate a Turing machine using (or proper Brainfuck for that matter). It feels like you'd need to come up...
In integer-only computation, a fraction like 5/2 is rounded down to 2. Is this any extra work at the ALU level, or, is the way it does division, at the level of logical gates, automatically outputting the rounded down result as standard?
I read from this question that counter automata is a push down automata with only one symbol allowed on the stack (plus a fixed bottom symbol). My question is counter machine means counter coexist with stack? I mean "DFA $+ 1$ counter" is same thing with "DFA $+1$ stack" . For example to generate this language $\{a^n ...
Say I have two sets of intervals sorted by time $I_1=[(x_1, y_1),... (x_n, y_n)]$ and $I_2 = [(a_1, b_1)... (a_m, b_m)]$. where $x, y, a, b$ are times in seconds. None of the intervals within $I_1$ intersect, i.e. $x_1 < y_1 < x_2 < y_2 < x_3....$ and same holds for $I_2$ $a_1 < b_1 < a_2 < b_2 < a_3....$ There is howe...
Clark et al. proved that the clique problem is polynomial-time solvable in unit disk graphs. Does anyone know if this result holds still if the disks are allowed to be different sizes? Or do such "non-unit disk graphs" in fact constitute all graphs, and thus the clique problem is NP-hard again? (I've been able to draw ...
If you have a Boolean function $f: \{0,1\}^n \rightarrow \{0,1\}$ on $n$ variables, you can represent this function as a $2^n$ vector indexed by the input space such that $ f_x = f(x)$. For concreteness I assume that $f$ is ordered as 00, 01, 10, 11, etc. Is there an easy way to tell if $f$ is has full degree? For most...
The universal Turing machine is the standard theoretical model of a stored-program computer. While in one sense as general as possible (Turing completeness), it doesn't explicitly contain many of the more advanced features of real-world/practical stored-program computers and their operating systems that have been devel...
Suppose L is a regular language over the alphabet $\Sigma$. I need to prove that $$ L'=\{x_0\cdots x_n:x_0x_0x_1x_1\cdots x_nx_n\in L, \ \ x_i\in \Sigma\}$$ I thought I could take a DFA which computes L, and take each accepting state, together with the state before it along an edge labeled 0, and the state before that ...
I would like a hint for this homework question. The problem is to come up with a divide and conquer solution for finding the maximum sequence of 1s in a given a binary matrix of order $n$. The sequences can only happen horizontally or vertically. I know the naive solution for this that consists of going through the row...
I need an algorithm that can take an uncompressed audio file and determine the frequencies of the sounds represented by the audio file. (Let's say there are at most 6 sounds as an example)
Given complete metric weighted graph $G=(V,E)$ with $n$ vertices. Are there an algorithm that partition $G$ into to disjoint part $(C_1,C_2)$ that sum of heaviest edge $e\in C_1$ and heaviest edge $e'\in C_2$ minimized? I seek for a paper that include an algorithm for above problem that run it's algorithm in $O(n^2)$,...
I'm making an application of MobileNetV2 and according to their article: We train our models using TensorFlow. We use the standard RMSPropOptimizer with both decay and momentum set to 0.9. We use batch normalization after every layer, and the standard weight decay is set to 0.00004. Following MobileNetV1 setup we use ...
Context-sensitive languages have context-sensitive grammars, and context-free languages have context-free grammars. Using context-free grammars, we can decide the finiteness and emptiness of context-free languages. Why can't we decide these properties of context-sensitive languages in the same manner, using context-sen...
I would like to know the best way to approach the time complexity analysis of the following algorithm. I have come up with 2 approaches so far. We have a std::map<int,vector<int>> (Balanced Binary Search Tree). Each of the std::vector<int> will be called a route. Algorithm: 1. while(true) 2. We pick the first two route...
Here is the grammar given on the wikipedia: $$ S \rightarrow T \;|\; U \\ T \rightarrow VaT \;|\; VaV \;|\; TaV \\ U \rightarrow VbU \;|\; VbV \;|\; UbV \\ V \rightarrow aVbV \;|\; bVaV \;|\; \epsilon $$ I can understand how $V$ generates strings with equal number of a's and b's. I want to prove that $T$ g...
We know that RE language is the collection of unrestricted grammar which is known as type-0 grammar that's why emptiness, finiteness of every RE languages is undecidable. My question is how I check decidability "the Turing machine makes move left or not" on particular input string. I have found some internet contents ...
Given a context-free grammar $G$ for a language $L$, where $L$ contains strings of length greater than 2, show that there exists some context-free grammar $G'$ which generates $L$ such that every rule of $G'$ has the form $$A\to x_1 x_2$$ where $x_i$ is either a terminal or non-terminal and $A$ is a terminal. I know ...
Why timeout in TCP is not a predefined fixed value? I know there is a set value of 15 for a timeout value but I was asked why timeout in TCP is not a predefined fixed value which I couldn't find an explantion for.
A. routing B. flow-control C. congestion control D. All of the above My guess is flow-control only because routing and congestion is part of the network layer. The network layer is the third later and it provides data routing paths for network communications. I'm still not sure if I am right though.
I am looking for a list of algorithms that depends on sorting / relative ranking / argsorting, not for a list of sorting algorithms. I want to study and illustrate the importance of fast sorting in other algorithms. I am looking for something rather exhaustive (or at least covering my - not so - niche field: data scien...
I have been asked to write an algorithm which determine whether a DAG is semi-connected. (Recall that a DAG is semi-connected if for any pair of vertices $x,y$, there is either a path from $x$ to $y$ or a path from $y$ to $x$.) My idea that that a DAG is semi-connected iff it has a unique topological sort. Therefore, I...
In graphs with odd cycles, the maximum weight of a fractional matching may be higher than that of a standard matching. For example, in a cycle of length 3, where all edges have weight 1, the maximum-weight matching contains a single edge so its weight is 1, but the maximum-weight fractional matching contains 50% of eac...
Suppose $L_1$ is reduces to $L_2$ in polynomial time, $L_1\leq_p^\mathsf{}L_2.$ we know that if $L_2$ is RE then $L_1$ is also RE and $L_2$ is REC then $L_1$ is also REC. And also I know that if $L_1$ is REC then $L_2$ is RE and REC is false. Because by taking counterexample $L_1=\emptyset$ and $L_2=$halting problem....
I'm asked to write an algorithm which determine all points which appear in a "edge-simple" path connecting node A and node B, i-e a path which doesn't go 2 times in the same edge, but it can go multiple times through a same node, including node A and node B. In this simple example, with node A=0 and node B=1, all point...
What are some nice/natural examples of languages not contained in $P/\mathit{poly}$, preferably decidable ones? I'm interested in unconditional results rather than examples such as the Karp–Lipton theorem, which states that SAT is not in $P/\mathit{poly}$ unless the polynomial hierarchy collapses.
t <- n while t>1 do t <- log_2(t) I tried to do it this way: $f^\text{(1)}(t)=\log_2(t) \\ f^\text{(2)}(t)=\log_2\log_2(t) = \log_2^{(2)}(t) \\f^\text{(3)}(t) = \log_2^{(3)}(t) \\ f^\text{(j-1)}(t) = \log_2^{(j-1)}(t) \\ f^\text{(j)}(t) = \log_2\log_2^{(j-1)}(t) = log_2^{(j)}(t) $ I consider $f^{(j)}(t...
please help me with this one. (a formal answer would be much appreciated) ∀L1, L2 ⊆ Σ: (L1 · L2)^c = L1^c · L2^c when · represents concatination and ^c the complement language. do not know if languages are regular. Thank you
In several proofs of the expected lookup length in an open addressing hash table, an assumption is made (which is said to follow from the "simple uniform hashing assumption": Given a hash table with n slots and m keys in it, the probability that any particular slot is occupied is m/n. I'm having difficulty creating a...
Suppose we have the following equation: $$k_{i + 1} = (k_i + 2i + 1) \bmod{n}, \quad k_0=k, \quad i\ge 0$$ Show how we can we replace the mod with one comparison and occasional subtraction. Attempt: I understood elsewhere that occasional here doesn't mean one subtraction. So, to replace modulo, the only way that I un...
Depending on where I look, some places (https://courses.engr.illinois.edu/cs473/sp2009/notes/19-maxflowalgs.pdf) describe EK algorithm as choosing the st path with largest bottleneck value, while others (wikipedia) describe it as the shortest path from $s$ to $t$. I'm not sure if they are the same, and I haven't been a...
Imagine we are running a program on a modern operating system, such as Linux or Windows. After running for some time, the program's time slice is up. A different program (process) starts to run again. That is, we have had a context switch. During a context switch, does the MMU have to be updated? Maybe what I am really...
I'm stuck on this proof for the theorem eqblist_true. So far what I have is: Theorem eqblist_true : forall l1 l2, eqblist l1 l2 = true -> l1 = l2. Proof. intros l1. induction l1 as [| l1']. - intros l2 H. simpl in H. destruct l2 as [| l2']. + reflexivity. + discriminate H. - simpl. intros l2...
How would you get an optimal schedule to solve matrix chain problem where you only need to obtain the diagonal? (assuming the resulting matrix is square) First computing the matrix product and then extracting the diagonal can be suboptimal. Consider diagonal of outer product of two vectors uv'. We could get the diagona...
Given that $A$ is $NPC$ problem. And I need to check "if $D$ belongs to $NP$ and $D\leq_p^\mathsf{}A$ then $D$ is $NPC$" is true or not? My approach: Since $D\leq_p^\mathsf{}A$, therefore $A$ is at least as hard as $D$, and given $A$ is $NPC$, consequently $D$ could be like easy problem $P, NP. $ And to prove $D$ is ...