instruction
stringlengths
35
29.1k
Given $L$ a non-regular language and $F$ a finite language I need to prove, or disprove, that $L^+ \cap F$ is a regular language. I tried to prove this using induction on the number of words in $L^+ \cap F$, as from $F$ finite nature I get that the intersection is also finite, hence: $n = 0$, There no words in $L^+ \c...
Consider the language $\{ w=uv : 2|u|=3|v|, u,v \in \{a,b\}^+ \}$. How to compare the lengths of the words? How to know where is the end of $u$ and the beginning of $v$? What algorithm is used for comparing lengths of words in a pushdown automaton?
I understand that to approximate a solution to the weighted vertex cover, we need to relax the integer linear program to a linear program which can be solved in polynomial time, but why do we round from 1/2 when converting it back to an ILP? Why aren't the bounds say, round down to 0 from 1/3 if a given vertex has valu...
I wanted to say that the language is the set of strings that end with "101" but unfortunately it does not work. Take for example "110101", which is not accept by the dfa.
I am trying to construct a DFA with $\Sigma=\{0,1\}$ that accepts the language $\{ x \in \Sigma^* \mid x \notin \mathcal{L}(0^*1^*) \}$. To do this I first tried constructing a DFA that accepts $x \in \mathcal{L}(0^*1^*)$ and then found the complement of that DFA by switching the accept states and non accept states. Bu...
Every function $f\colon \{ 0, 1 \}^n \to \{ 0, 1 \}$ can be computed by a circuit over the standard unbounded fan-in basis $\mathcal{B}_1 = \{ \neg, (\vee^n)_{n \in \mathbb{N}}, (\wedge^n)_{n \in \mathbb{N}} \}$ of depth $3$ and size $\mathcal{O}(2^n)$ via the disjunctive or conjunctive normal form. Now, we can transfo...
The min-path problem is mostly motivated by a graph with cities as vertices and roads between them as edges. Each edge has a weight which could be the length of the road or the time it takes to cross it in your car ($t_e$ for edge $e$). This problem has an optimal substructure (sub-paths within an optimal path are also...
Suppose $$L=\{1^i0^j1^k\mid i+2j=k\}$$ How can I construct a context-free grammar for $L$? This is homework. Here is my attempt for the case when $L$ is defined with $i+2j=3k$ instead. \begin{align*} S&\to aaaSc| bbbBcc| abBc| aabBc|\lambda\\ B&\to bbbBcc| \lambda \end{align*} But it's not true because it accep...
i'm a student and i've been searching the language description of this automaton. The states are as follows: Q = {q1, q2, q3,q4} The alphabet is as follows: Σ = {0,1} The start state is q1 The accepting state is q4 After some research i though i had something. Every string ending in 101 is accepted, but then i tried 10...
I have an undirected graph $(V, E)$ with constast edge connectivity $\lambda$. Each edge is sampled independently with probability $min\{1,\frac{c \ln n}{\lambda}\}$ for some $c > 0$. I need to prove that I can pick smallest sufficiently large $c$ so that the graph $(V, E')$, constructed from the sampled edges is conne...
For any vertex v reachable from s, BFS computes a shortest path from s to v (no path from s to v has fewer edges). In order to prove the above proposition, The author of the book has stated that we first need to Prove by induction : The queue always consists of zero or more vertices of distance k from the source, fol...
I am looking to specify something in Isabelle of the form that there exists a $j$ such that $lb < j < ub$, where $lb$ and $ub$ are lower and upper bounds. For a single condition, we can say, for example, $\exists j < ub . P(j)$ in Isabelle. How to specify both conditions on j? Is it right to say both conditions in the ...
Consider the problem of checking whether a quantified Boolean formula of the form $∃X_1 . . . ∃X_n ∀Y_1 . . . ∀Y_m \phi$, for $\phi$ in $3DNF$ over $X_1, . . . , X_n, Y_1, . . . , Y_m$, is true. I'm trying to show that it's in $NP^{NP}$ My attempt (probably not correct, it's a guess): Consider the following problem: $∀...
I need to sort an array of n real numbers that was randomly generated in this way: I have a given set of k closed intervals: [a1,b1],[a2,b2],...,[ak,bk] whose beginning and end are natural numbers. These intervals may overlap. Each i-th interval is assigned a number ci, specifying the probability of drawing it. After d...
I was given a new definition for a language of an automaton. A word is part of the automaton language if and only if the automaton finished on an accepting state and it was in an accepting state at least once before Note: it doesn't have to be the same accepting state. Now given a deterministic finite automaton $A$ t...
I am having trouble understanding what's going on. I have just been introduced to the open() and close() commands in Python. I have a code that is very similar to the code below: def function1(s): #creates a text file with the name s file = open(s + ".txt", "w+") file.writelines(['1\n', '2\n', '3\n']) Running th...
I have this strange problem where we have a set of positive numbers $M$, a fixed number $n$, and a function $f\colon M \rightarrow R^+$ mapping each number in $M$ to another positive number. We want to know if we can select non-repetitive numbers $a_1, \dots, a_n \in M$, such that the sum over the weighted prefix produ...
I am working on some automata questions and I have encountered this problem: Let L be a CFL. Is $\{1\}^∗ ⊆ L$ a decidable problem? Is $\{1\}^∗ = L$ a decidable problem? I literally have no idea how to solve this, any ideas/hints? Thanks in advance!
a* = {λ, a, aa, aaa, aaaa.....} a.a* = a.{λ, a, aa, aaa, aaaa.....} = {a, aa, aaa, aaaa, aaaaa....} Then these two regular expressions above should not be equivalent. Please correct me if i am wrong.
Facility location and $k$-medians are closely related problems in CS. We are given a set of facilities (each with a weight), a set of clients to serve where a facility $i$ can serve a client $j$ with a cost of $c_{ij}$. In $k$-medians problem, the goal is to select a set of $k$ facilities that minimizes the total cost ...
Is the language, $a^nb^mc^k$, where $n\not=m$ and $m\not=k $ in CFL or not? When the condition is changed to $n\not=m ~\|~ m\not=k $, it can be shown that the language is the union of 2 CFLs. However when $n\not=m$ and $m\not=k $ that approach seems to not work.
as anticipated in the title, I can't understand the difference between API, system call and system call interface. Most of all, I can't understand if the system call interface is actually a "translator" between functions of an API and specific system call or if it is something else.
This is a question written by my instructor Z. Loria . Consider the following problem: Given a polynomial $p(x) = \sum_{i=0}^n a_ix^i$, where $a_i$ are integers, is there a natural number $n \in \mathbb{N}$ such that $p(n) = 0$? Show that this problem is decidable by presenting an algorithm in pseudocode that always e...
For the language $ L= \{a^kb^k | k \geq 0 \} $ How can i show there is no one-tape Turing Machine that can decide $L$ in less than $O(n\log n)$ time ?
How does the NFA function on $\epsilon$ input if there is only a single $\epsilon$ string in the language? I understand that $L^* = \bigcup_{i=0}^\infty L^i$ where $L^0 = \{()\} = \{\epsilon\}$ and $L$ is the language. The empty string $\epsilon$ is an input to a NFA with $\epsilon$ moves. I suspect an infinite number...
If $\mathcal{p}$ is a nontrivial property of formal languages, then $L_{\mathcal{p}} = \{ \langle M \rangle \mid L(M) \in \mathcal{p} \}$ is undecidable by Rice’s theorem. What if we describe languages with another method instead of Turing Machines? For example, if we define $L’_{\mathcal{p}} = \bigl\{ \langle \phi \ra...
We know that $f(n)$ is $\mathcal O(g(n))$ if $\exists c\ge0$ s.t. $$\lim_{n\to\infty}\dfrac{f(n)}{g(n)} = c.$$ Let $f(n)=n^{3/2}$ and $g(n)=n^{\log n}.$ When I am applying L'Hôpital's rule for $$\lim_{n\to\infty}\dfrac{f(n)}{g(n)}=\lim_{n\to\infty}\dfrac{1}{n^{{\log n}-3/2}} =0.$$ If I apply L'Hôpital's rule for $$\li...
Suppose I have a 32-bit integer $x$, I want to find $\{ x_i \}_{i \in 1\dots\ell}$ such that $x = e + \sum_{i=1}^\ell x_i \cdot 2^{32 - B\cdot i}$ where the error $e$ is as small as possible. The parameter $\ell$ is the level of the decomposition and $B$ is the base of the decomposition. Increasing $\ell$ and decreasin...
So I'm trying to solve this problem and I came up with a brute force solution. I was wondering how can i make it more efficient ? Problem: Suppose i have resources and integer that denotes at what time it was used in an array. Now we have a variable 'window' = 3. I need to find the resource which was accessed the most ...
How to transform a k-SAT CNF clause into a combination of 2-SAT and/or 3-SAT (1-SAT) clauses? $k>3$ Example 5-SAT: $$ Q = \neg A \lor B \lor C \lor D \lor E $$ $$ \; \; = (X0 \lor X2 \lor X3) \land (Y1 \lor Y2 \lor Y3) \land \; ... $$ Do I have to apply Tseytin transformation? How? Could you resolve my example, pleas...
Given a language $A \in RE$, is the following language also in $RE$? $$ L_{10}^{A} = \{ \langle M \rangle : \lvert A \cap L(M) \rvert \geq 10 \} $$ Where $L(M) = \{x \in \{0, 1 \}^* \mid M \text{ accepts } x \}$. (I've managed to prove that if $A \in R$ then $L_{10}^A \notin R$ necessarily with a reduction from $HALTIN...
I need help choosing a model for my data. I have 50 genes that I need to test for their expression levels. I was thinking of implementing either an SVM or a multilayer perceptron model where the output can be on a scale of 0-1 to show the expression level of each gene. The input data is from single-cell transcriptomic ...
This language is given. $L = \{\; x \# x^R \# x \mid x\in \{a,b\}^*\;\}$ I have to figure out a context sensitive grammar for it. I've tried several rules already but it's hard to make a copy of the first part and also get it in the last with the reversed part in the middle.
I would like your opinion on how to detect the T(n) (Running Time) for the following recursive algorithm. Charm is an algorithm for discovering frequent closed itemsets in a transaction database. A list of frequent closed itemsets are frequent items that appear several times in a set of transactions (tids) (e.g. bread...
Found this term for a supposed 'adder' in lambda calculus. λabcd.ac(bcd) Although I know about alpha-conversion and beta-reduction and all that stuff, I don't know how to apply it. All the examples I could find always put in real numbers (like "3" and "5") but strictly speaking, if we want to abide by the rules of lam...
With hard margin support vector machines (SVMs), it suffices to find the critical points of the Lagrangian $L = \frac{1}{2}||\theta||^2 - \sum_{n=1}^{N} \alpha_n (y^{(n)} (\vec{\theta}^T\vec{x}^{(n)} + \theta_0) - 1)$ over all $ \alpha_n$, where $\vec{\theta}^T\vec{x}^{(n)} + \theta_0 = 0$ is the seperating hyperplane,...
Since every continuous variable can be sliced into many discrete values, is there a particular class of problem that can only be solved by an analogue computer?
Hello i am new to machine learning, i am working on a multimodal dataset, basically memes dataset, The data consists of an image and an overlay text, i have no clue how to feed a model both of the information the text and image, for example what i understand for pytorch i can import and image dataset like pic number 1,...
There is a whole space interval [0,128] And several discrete sequences like: [0, 1, 4, 5, 32, 33, 36, 37, 64, 65, 68, 69, 96, 97, 100, 101] [32, 33, 36, 37, 48, 49, 52, 53, 96, 97, 100, 101, 112, 113, 116, 117] [12, 13, 28, 29, 44, 45, 60, 61, 76, 77, 92, 93, 108, 109, 124, 125] They look like this and can be describe...
Say I have a set of strings $S=\{s_1, s_2, ..., s_N\}$, and I want to partition $S$ into two sets $S_1$ and $S_2$ equally, i.e., $||S_1|-|S_2||\leq1$. Define the difference of a set as $$Diff(S_k)=\frac{\displaystyle{\sum_{s_i,s_j\in S_k} d(s_i,s_j)}}{\displaystyle{|S_k|\choose 2}}$$ where $d(s_i,s_j)$ is a custom dist...
Suppose we have an optimization problem $\mathcal{P}$ that we should cover all points with $k$ disjoint rectangles in the plane and we should optimize a distance function over each rectangles . Now, suppose there is a $\mathcal{P}'$ that just need cover all points in the plane with $k$ disjoint rectangles. Already pr...
I have some partial order $\preceq \,\,\subset A \times A$, I'd like a data structure with the following operations: $Insert(a, x, T)$: add $(a, x)$ to the collection $T$ $Find(x, T)$: find the element $(a, y)$ in $T$ such that $y \preceq x$ and $y$ is the largest such value (e.g. the greatest lower bound of $x$. If ...
I'm looking for a word to describe an algorithm that takes an ordered list as input, where the output depends on the content of the list but not the order. A sorting algorithm on integers would be an example of such an algorithm, because a sorting algorithm will always output the same output list for any input list tha...
Consider a CNF formula $F$ such that all the literals in every clause must be negative ( here is an example : $F$ = ($\bar{x_{1}}$ $\wedge$ $\bar{x_{2}}$) $\vee$ ($\bar{x_{3}}$ $\wedge$ $\bar{x_{4}}$ $\wedge$ $\bar{x_{5}}$) would be a valid formula where as $F$ = ($x_{1}$ $\vee$ $\bar{x_{3}}$ ) would not be a valid for...
I was given the following problem and told it has to be solved using diagonalization. However, I am confused as to why diagonalization would be the solution. Would the answer not be since L is infinite it has uncountably many subsets. Since there are only countably many decidable languages, some subset of L must be und...
I am interested in computation and I am lost on undecidability and reductions. I have the following two problems I am stuck on. Let us call 2 Turing machines related if there is an input $w$ on which both halt (after finitely many steps). Let $h(M )$ be the set of inputs on which the TM $M$ halts. Show that the problem...
We learned recently in a graduate statistic course about Blackwell-Rao of an unbiased estimator statistic T; other methods for parameter estimation includes Maximum Likelihood and Method of Moments and we studied their asymptotic behavior for consistent estimators. Q: Are there any recommendations of papers in the fiel...
The topic of 3-colouring is often talked about, but what happens if we limit the amount of times we can use one color? Take a graph $G=(V,E)$ with $k$ being the number of vertices, is it possible for a polynomial time algorithm to check if the graph $G$ admits a 3-colouring where the first color is only used at most $k...
I am working with undirected unweighted graphs, and I am searching for an algorithm that gives me a spanning tree minimizing the number of moves to visit every nodes. For example, given this graph : one spanning tree may be : but, starting at a, 11 moves are necessary to go through every nodes : ab, ba, ah, hg, gh, h...
I am working with graphs, let's say I have 4 nodes, named A, B, C, D, each node has to be connected a certain number of times to the other nodes. A: 3, B: 3, C: 2, D: 2 This means that A and B are connected three times and C and D two times. All the possibles pairs generated are the following: (A, B), (A, C), (A, D), (...
I read this blog post Fixing retries with token buckets and circuit breakers (by Marc Brooker), which goes through several retry strategies. For the "N retries" strategy (i.e. on failure, the client makes a maximum of N retries of the call), it explains that: [...] If the downstream failure rate is x%, the effective f...
So I was just studying about Indexed Priority Queues and I got confused about the increase key operation. So basically we have the option to increase a key for an element in log n time because we can look up the index using another array that maps keys to indexes. So let's say that 'A', 'B', 'C', 'D', 'E' are mapped wi...
The Buttows-Wheeler transform is a function that takes a string $S$ to a new string $S'$ and an index $I$. The new string $S'$ is always an anagram (rearrangement) of the input string $S$. However, if I pick a random string $S'$ and index $I$, the inverse Burrows-Wheeler transform usually fails. For example, if $S'$ is...
I've read some articles in this forum, e.g. there were professional claimed that a Turing machine does not accept a language but it recognizes it. I respect that but I found the phrase "a language is accepted by a machine" is actually used in the Peter Linz's book. So here I'd rather not touch the choice of words probl...
I was solving some exercises about CFL from past years' homework and faced this question. Question: Given the language $L=\{w \# x^R \ | \ x\ is\ a\ substring\ of\ w\}$, prove/refute if it's regular language. If you proved it's regular then provide NFA and a regular expression that describes it. Otherwise, provide CFG ...
I have an undirected graph where each edge $e=\{u,v\}$ has a positive weight $w_{uv}$ and each vertex $v$ has a positive capacity $c_v$. There are two special vertices: a source vertex $s$ and a destination vertex $d$. A vehicle has $n$ items where item $i$ has a load $\ell_{iv}$ when placed on vertex $v\notin\{s,d\}$....
The question was to construct a DFA which accepts the language $$\{ x \in \{0,1\}^* \mid x\text{ starts with a }0\text{ and has at most one }1\}$$ So I first constructed DFA for '$x$ starts with a $0$' and a DFA for 'has at most one $1$' then I tried getting the product automaton of these, but the quiz says the automat...
Reading through https://developer.apple.com/documentation/swift/array/1688499-sort, it states "Complexity: O(n log n), where n is the length of the collection," but I don't have an intuition for why this exactly this is.
I've faced a question in my homework, I was able to solve it but not as desired. Question: Given the language $L=\{0^n1^{n+1}\ |\ \exists k\in \mathbb{N} :\ 4n+2=6k \}$, Prove that it's a CFL (Note: it can be solved without using CFG or PDA). My Answer: I provided the CFG: $$S\rightarrow 0T11\\T\rightarrow 000T111\ |\ ...
I saw the word "redex" in the context of proramming language theory/semantics in 2018 and now when I was reading a neurosymbolic research paper (machine learning with neural nets + symbolic algorithms). The research paper said: Constructing $I\beta'$ (operator that inverts one step of beta-reductions/function applicat...
I'm looking for simple examples of nondeterministic log-space completeness reductions. In particular I seem unable to construct any nontrivial widget using 2-SAT clauses, which is known to be NL-complete.
I believe that if P = NP, then that would imply EXP = NEXP (because of the padding argument), and then EXP^P = NEXP^NP (we could replace EXP with NEXP since they are equal, and replace P with NP, since they are equal). Is there any error in this affirmation? I am not sure if there is anything that I am not considering ...
So I am doing an exercise in which there are $n$ people who are either knight or rogue, more than $\frac{n}{2}$ are knights. You are a princess and would like to marry a knight and do not want to accidentally marry a rogue. You can select any pair of the $n$ people to make them point out each other's identity. The knig...
I’ve read the Wikipedia article and know it’s basic function but I don’t understand what it physically is. Like, is an api a text file that the main program reads from and you are just putting your text in that file to be read or is it an other program that just puts what you type directly into the main program? I don’...
Let $G=(V,E)$ be a directed graph with possibly negative edge weights. Given a destination $t$. Suppose that we have already known $d_v$, the shortest path weight from $v$ to $t$. If I'd like to compute the shortest path weight from $v$ to another destination $t'$ instead (call it $d'_v$), how to use $d_v$ to calculate...
I was reading a book and there is a part in which they use this grammar $$ X \rightarrow xY $$ $$ Y \rightarrow yZ $$ $$ Z \rightarrow z$$ $$ Z \rightarrow \lambda $$ and other times they use this other one $$ X \rightarrow xyz $$ $$ X \rightarrow x $$ It mentions that both are equivalent but I don't understand why it ...
If A is in the class P, B is NP-complete, and C is not in the class NP. And A reduces to B and B reduces to C. Which statements are true? A is in the class NP. A reduces to C. If S is a candidate solution to an instance I for problem A, we can check in polynomial time if S is indeed a solution. C is NP-hard. I think ...
I'm studying Algorithms by Jeff Erickson. Consider this exercise from that textbook: Prove that the following algorithm, modeled after quicksort, uniformly permutes its input array, meaning each of the $n!$ possible output permutations is equally likely. [Hint: $ \binom{n}{k} =\frac{n!}{k!(n-k)!} $] $\quad\text{Quic...
I have 2 sets of atmost 25000 4-tuples. Currently, I am storing them as 2 lists of 4-tuples A and B. I have to perform the following computation for each of the combinations of A and B. min(B[j][0], B[j][2])<=A[i][0] and max(B[j][0], B[j][2])>=A[i][0] and B[j][1]>=min(A[i][1], A[i][3]) and B[j][1]<=max(A[i][1],A[i][3])...
I have a fully connected neural network that consists of 3 inputs + bias, 4 neuron hidden layer, and 2 layer output, I am using the sigmoid activation function on the hidden layer only and use the backpropagation algorithm. I am using the following training data: [ 0.50, 1.00, 0.75, 1], [ 1.00, 0.50, 0.75, 1], [ 1.00...
i have the following question which I'm having some hard time to solve: prove: if every two Languages $A$ and $B$ that have a polynomial reduction ($A$ to $B$) also have a log space reduction ($A$ to $B$), then $\mathsf{P}=\mathsf{L}$.
If every 2 languages $A,B$ that have Polynomial reduction $A<_pB$ have LOG SPACE reduction $A<_LB$, does $\mathsf{L}=\mathsf{P}$?
I recently thought of this problem, and I think it's very interesting. We are given an array of $N$ numbers, but we don't know the numbers themselves, only a possible integer range for each number. For instance, if $N = 3$, we could know that the first number is in the range $[1, 1000]$, the second number is in the ran...
From the point of view of writing pseudocode, I have never seen any algorithm making use of pointers except when writing algorithms about data-structure (like writing algorithms for linked list involve moving arrows which in essentially a pointers operation). So my hypothesis is that any use of pointers in pseudocode i...
I believe using big o notation that Bellman-Ford is to be expected to be faster on sparse graphs and dijkstra's should be expected to be faster on dense graphs, but in practice dijkstra's is always faster and Bellman-Ford is only used when negative weight cycles are present. Is that the case?
I am studying system design for distributed systems and in this page (https://github.com/donnemartin/system-design-primer), one of the following advantages was mentioned for federation for databases was: Smaller databases result in more data that can fit in memory, which in turn results in more cache hits due to impro...
Is there a way to compute the number of partitions such that each set in the partition has a cardinality lower or equal to two? If yes, is there also an efficient algorithm to compute these partitions?
I am wondering about the difference between an abstract data type (ADT) and a computation model. As I understand them: A computation model defines the basic unit of computation, that is, what can be done in a unit of time. The RAM model, for example, defines the basic data unit (the integer), their organization (the m...
I am interested in the complexity theoretic equivalences of prime number factorization. My interest stems from prime number factorization being one of the few candidates for NPI. I am especially interested to learn wether there are some not initially obvious reductions. Any possible reduction type (Karp, Turing, ...) w...
I am currently reading through the paper "Computer-Generated Residential Building Layouts" by Paul Merrell, Eric Schkufza and Vladlen Koltun. In this paper, they create and optimize floorplans by exploring the space of possible floorplans through a set of modifying operations. One of these operations is the sliding of ...
Let A and B be two sets of unordered 3D points. Set B is obtained by applying the same transformation to every point in set A. How do I match points from A to points of B? Is there a standard algorithm? To make things worse, the actual sets might have slightly different sizes, and the positions might be slightly shifte...
I'm trying to prove that L = {$0^n1^m0^n | m,n >= 1$} in NOT regular but I am struggling with the demostration process. I know the conditions are that: $|y| > 0$; $'y'$ can't be empty $|xy| <= p$(word/string length) for all $i$ > 0, $xy^iz$ must be in L Lets choose the string $s = 0^p10^p$. The first condition states...
What are the six mistakes that were made in the configuration of the following network? I could only find 3. Since the subnet on the left has 192.168.10.33 as HostMin and 192.168.10.38 as HostMax, Host A4 and Host A5 cannot be in this subnet. Subnet A should also have the IP 292.168.10.0 because it's a network addre...
Recently, I've written a draft article on the computational power of Petri-nets. An understanding of Petri-nets isn't really essential to answering this question, but I'll still note that the conclusions were that if Petri-nets were allowed to be infinitely large, then it is possible to simulate any Turing machine with...
Boolean satisfiability problem (SAT) is NP-complete by Cook–Levin theorem. (wiki) Horn-satisfiability – given a set of Horn clauses, is there a variable assignment which satisfies them? This is P's version of the boolean satisfiability problem. It is also P-complete. P-complete problems lie outside NC and so cannot be ...
S is a the set of binary strings in Shortlex order: [0,1,00,01,10,11,...] I want to encode / decode natural numbers with the following scheme: Encoding N: For natural number N return the binary string with index N in S: Code(N)=S[N] Decoding Code: Return the index of the binary string Code in S: Decode(11)=5 Can you pl...
This is a question by my professor Z. Luria in my Computability course. My first approach was to try and prove it by contradiction, assuming that EXIST is decidable and using the algorithm that decides EXIST to decide HALT which leads to contradiction - but I didn't managed to do so. Then I tried to prove by Reduction ...
I was going through some texts and shared PPT of my university and I found the term "traffic controller" in the Process management section under the functions of an Operating System. The PPT says, "OS maintains the track of the processor and the status of the process; the software that does this is called the traffic c...
model: gambler ruin theorem. A gambler has $i$ coins initially, in every step, he wins a coin with probability $p$, and loses a coin with probability $1-p$. The expected time that he loses all his coins or wins $n-i$ coins (thus he has $n$ coins totally) is as following: $$E(i)=-\frac{n}{1-2p}\frac{(\frac{1-p}{p})^i-1}...
I was re-reviewing a somewhat upvoted answer of mine where I attempt to explain the differences between pure, impure, deterministic, non-deterministic, and idempotent functions. In my answer I use .NET's or Java's List<T>.Add( T ) as an example of an impure deterministic function. I also use Random.Next() as an example...
I want to generate 2 sets from N elements. Sets must be unique in the combination of sets Numbers must not repeat across the 2 sets Sets can have any amount of numbers, but must not be empty Ordering doesn't matter Examples for 3, 4 and 5 for 1 2 3 (1) (2 3) (2) (1 3) (3) (1 2) for 1 2 3 4 (1) (2 3 4) (2) (1 3 4...
In CLRS' Introduction to Algorithms: (1) In 22.1 Representations of graphs The adjacency-list representation of a graph G = (V, E) consists of an array Adj of |V| lists, one for each vertex in V. For each u in V , the adjacency list Adj[u] contains all the vertices v such that there is an edge (u,v) in E. That is, Adj...
Intuitively, it seems that if a programming language is Turing-complete, then it must contain a program that's an infinite loop. I have formalized this below: Conjecture. There does not exist a set $S$ of Turing machines such that all three of these properties hold: $S$ is decidable. (That is, there exists a Turing m...
Context-Sensitive Grammar is defined as a 4 tuple G = (V, Σ, R, S) where: V is a finite set of elements known as variables. Σ is a finite set of elements known as terminals V ∩ Σ = Null (empty set) S is an element of V and is known as the start variable. R is a fine set of elements known as Production Rules. Each rule ...
I prepare for entrance exam and try to practice some hard problems. The following nice problem is problem 1(c) of this problem set. Suppose we are given a two-dimensional array $A[1...m][1...n]$ in which every row $A[i][]$ is sorted, and an integer $k$. Describe an algorithm to find the $k$-th smallest element in $A$ ...
I have n number of files on a ScrollView. Every time a file is added, x/y coordinates are stored in an array. The user is able to drag and drop the files anywhere they like. Overlapping files (e.g. distance between center less than 100 points) will form a stack, see screenshot. At the moment, my implementation is not g...
I am reading Introduction to the Theory of Computation by Michael Sipser and I am in chapter 5. It says here that the Post Correspondence Problem is undecidable, but thinking about it, given a collection, if someone permutes using the algorithm: try every single permutation of the collection: if it is a match retur...
On my backend I use a 3rd party service which provides currency exchange rates. I use this rate for the funds conversion within the customer’s accounts. As far as this rate affects customers’ money, I have to be sure that it’s legit. Let’s pretend a 3rd party service is experiencing a glitch and returns 100x times bigg...
I've stumbled across this problem on CSES https://cses.fi/345/task/E/ and was wondering is it somehow reducible to 2-SAT with given constraints? So, the problem states that you need to solve a 3-SAT given in a CNF form, albeit a special case, where: Each clause has exactly 3 distinct variables Each variable occurs at ...
I stumbled on the following computing issue and would like some help to solve it. Given a vector of size n and filled with 1's, give all the elements obtained by the sum of them. Ignore combinatorial options like [m, n] and [n, m] Example: n = 5, v = [1,1,1,1,1]: The possibilities are below: [2, 1, 1, 1], [2, 2, 1] [3,...