instruction
stringlengths
35
29.1k
Let $H=\{h|h:X\to Y\}$, $|X|=n$, $|Y|=m$. $H$ is a universal hash family if Def 1. For any $x_1,\ x_2\in X$, $x_1\neq x_2$, $\left|\left\{h\in H\middle| h(x_1)=h(x_2)\right\}\right|\leq |H|/m$. (or what if $=|H|/m$ ?) Def 2. For any $x_1,\ x_2\in X$, $x_1\neq x_2$ and for any $y_1, y_2\in Y$, $$ \Pr\limits_{h\in_u H}\l...
Is time complexity of log(n+logn) is equal to theta log(n)? Can I take only the dominants from inside of a log?
Given a large dataset $D$ and multiple sets of filters that can be applied to $D$, e.g. $setA = \{filterOnColorRed\}$ $setB = \{filterOnAgeGreaterThan20\}$ $setC = \{filterOnColorRed, filterOnAgeGreaterThan20\}$ $setD = \{filterOnColorRed, filterOnAgeGreaterThan20, filterOnSizeIsLarge\}$ where each filter is expensiv...
I am looking to provide a formula saying "A graph with $n$ vertices has an independent set $X$ of size at least $n/2$" in existentional second order logic. (This is exercise 1.2. from Libkin's Elements of Finite Model Theory (see here for online pdf, page 10 of the book (or 23 in the pdf)). I can express that $X$ is an...
Are there known algorithms to find a line that intersects a given set of segments? In: A finite set of segments. Out: A line that cross all these segments or explicit answer that there is no such line. I've tried wiki and general algorithms books but found none.
An $(\alpha,\beta)$-ruling set is a set $S$ such that any two nodes in $S$ are at distance at least $\alpha$ from each other, and, for any node $v \notin S$, there exists a node $u \in S$ such that the distance between $u$ and $v$ is at most $\beta$. Let $G$ be graph which is nearly regular, with all degrees in $[k,2k]...
Take a set of $n$ points in the plane. You want to sort them by increasing abscissa. But you also want to sort them by abscissa after several arbitrary rotations, say $k$, in increasing angles. The obvious brute-force solution takes time $O(kn\log n)$. Is there a method with a better complexity ? If one considers a fu...
I have a problem where I need to find all subsets of a set that satisfy some validity function. The function has the property that if a subset is invalid, so are all its supersets, and if a subset is valid, so are all its sub-subsets. This can clearly take exponential time if, for instance, all subsets are valid. Howev...
I am learning about computational models, I wonder why Turing chose his model of Turing machines (the strip with the head and Read / Move left or right / Change state). I am suspecting his physical machine Enigma was having a stripe and behaved similarly. Is this correct? The circuit gates model seems close to what an ...
In the dragon book, section 9.2.6, why is the $OUT[B]$ initialized to $U$ except for $OUT[ENTRY]$. Wouldn't using the $OUT[B] = \emptyset \quad \forall B$ be a more conservative solution? The book gives this example: Let $IN[B_2] = OUT[B_1] \cap OUT[B_2]$ $OUT[B_2] = G \cup (IN[B_2] - K)$ and $I^j, O^j$ be the $j$th a...
I'm trying to understand how the system's call stack works internally when a recursive function is called. Specifically, I'm looking at a function that computes the maximum depth of a binary tree using a postorder traversal. I do know there is a stack solution out there, but I would one that mimics the internal call as...
How do I Verify that $n\log n=\Theta(10n\log10n)$ I think I need to prove that there exists $c_1,c_2>0$ such that $c_1.g(n)\le f(n)\le c_2.g(n)$ Step 1 $$ \log n\le \log 10n\implies f(n)=n\log n\le 10n\log 10n=g(n)\\ f(n)\le c_2.g(n)\implies f=O(g) $$ Step 2 $$ n\log n\ge\frac{1}{10\log 10}\big[10n\log 10n\big]=\frac...
How the story begins? I was learning about Red Black Trees on my own. When one opens the Wikipedia article, it can be read: (Conclusion) If a node N has exactly one child, it must be a red child, because if it were black, its NIL descendants would sit at a different black depth than N's NIL child, violating requiremen...
Question: What are the current main challenges in TCP congestion control algorithms? Are there any foundational trade offs that algorithms need to make? E.g. minimizing router buffer sizes while quickly reacting to available bandwidth on noisy links? Context: I was reading some of the old discussions from 20 years ago ...
I can solve the following problem by Jeff Erickson in $O(n^3)$(and maybe in $O(n^2logn)$) time but how is the $O(n^{3/2} log(n))$ time solution possible? Let $D[1 .. n]$ be an array of digits, each an integer between $0$ and $9$. A digital subsequence of $D$ is a sequence of positive integers composed in the usual way...
I'm writing a graph traversal function to be used in a garbage collector. To avoid stack overflow, I used a finite state machine. Roughly, it descends into child nodes recursively to mark objects, and return to root (to descent down again) whenever a branch is exshausted. However, I realized that if there's loop in the...
I have a doubt related to pumping lemma in CFL for which I dont find an answer, so I think is very easy because no one wonder about. The lemma says: My doubt is: Is there any restriction related to strings u (the most left) and y (the most right), I mean can they be empty?. In case they can, I cannot proof that a^nb^n...
My textbook gives the equation for the power dissipation $$ P=CV^2 f $$ but after reading it a couple times, I can't get very clear on exactly what each of these is measuring. It describes $P$ as the "power dissipation", which I take to mean something like the heat lost to the environment as the current passes through...
Both MAX-CUT and MAX-3-CUT are known to be NP-complete. This post shows a reduction from MAX-CUT to MAX-3-CUT. I am curious if there is a way to reduce MAX-3-CUT to MAX-CUT? MAX-CUT: Given an undirected graph $G=(V,E)$, a weight function $w:E\to\mathbb{N}$, and $k\in\mathbb{N}$, determine if there exists a partition $(...
I have recently reviewed the new article by DeepMind (Google) in Nature named "Faster sorting algorithms discovered using deep reinforcement learning". They claim that branchless algorithms, such as sort4, maintain full correlation between the algorithm length and its latency (Table B.5 in the supplementary material). ...
I'm having a lot of troubles understanding a preparation exercise about oriented graphs: Consider the following game played on a directed graph G = (V, E) with n nodes and m edges. A pawn is initially placed on node s. The pawn can be moved from its current position u to a node v if there exists a directed edge (u, v)...
I am looking for a variant of the knapsack problem in which the items are nodes in an undirected graph, and the knapsack must be filled with a connected subgraph. Formally: The input is an undirected graph $G=(V,E)$, where each node $v\in V$ has both a size and a value; and a knapsack capacity $C$. The goal is to find...
There are $n$ people and $m$ jobs. We would like to assign at most one job to each person. For each person,job pair, there is a positive value determining the fitness of this person to that job. The goal is to find an assignment that maximizes the total value. So far, it is exactly the problem of finding a maximum-weig...
Suppose we have sets $X$ and $Y$, $|X|=m$, $|Y|=n$. $H$ is a universal family of hash functions from $X$ to $Y$. Let $S\subsetneq X$ be a proper subset of $X$. Does there exist some "partial" universal hash family that is universal on $S$ to $Y$, but not necessarily universal on $X$ to $Y$? The circuit complexity of th...
All of the discussion is in the context of this paper. I think that the whole procedure that the paper describes is not decidable, because if we can have an algorithm for it, then we can solve halting problem. I begin with the definition of termination, which has not been expressed in the paper. First thing that comes ...
Given: A planar undirected connected graph $G$ in which degree of every vertex is $2$ or more. Fact: A planar graph can have multiple planar embeddings. Question: Give an efficient algorithm to find the set $S$ of face cycles corresponding to any one of the planar embeddings. We do not care about from which specific em...
Consider the following algorithm: We are given a planar graph $G$. We initialise a set of vertices $S$ to an empty set. We randomly pick a vertex $v$ in $G$ and insert it in $S$. Now we keep including in $S$ vertices from the neighbourhood of $S$ such that the vertex we include is adjacent to exactly one vertex in $S$....
Find the equivalence classes of a nerode theorem and use equivalence classes to construct a reduced DFA for the following language: $^+(+)^*$ The answer: $,^+,^+^∗+^+^+,(+)Σ^∗+⋅(+)Σ^∗$ I figured that the minimal base for the language is $a^+$ and for the $^+^∗+^+^+$ its just multiplying the expression with $(+)$ but ...
I have read that a decrease in response time does not necessarily entail an increase in throughput, but I'm struggling to understand the exact way that this can happen. What I'm imagining is a server receiving requests from several different connected devices. Say computer A sends a request and the server starts work...
When dealing with a Recursive Backtracking Algorithm what are the ways to speed it up and what computational hardware is involved? I'm assuming from ignorance that everything is done by the CPU so the only thing that comes to mind to make it faster would be early exits, multithreading or quantum computing. Is that it? ...
Is there any algorithms like Reed Solomon that work for a stream of unknown data? The stream is finite but size is unknown until the stream ends. I found some information about sliding window reed-solomon but that's pretty much it.
Good day. Some time ago I found a page on (en.) wikipedia about Heap's algorithm for permutations. Here it is. Original algorithm can be written as next (copy from (en.) wikipedia): procedure generate(k : integer, A : array of any): if k = 1 then output(A) else for i := 0; i < k; i += 1 do ...
In what follows, $r \in \mathbb{N}$ is not necessarily prime. $\mathbb{Z}_r$ is shorthand for $\mathbb{Z}/r\mathbb{Z}$. Given a set of $h$ hyperplanes $A \vec x = b \mod r$, we can check whether the union of the hyperplanes equals the entirety of $\mathbb{Z}_r^n$ in $O(r^n \text{poly}(r,n,h))$ time by just plugging in ...
Can Rural Postman Problem with arbitrary start and end be reduced to Rural Postman Problem with single depot node? The rural postman problem is: Given a weighted MultiDiGraph $G=(V,E)$, a subset of edges $A$ must be traversed. The path must start and end at the depot node. Find the shortest of all such paths. I'm won...
I am learning about Fibonacci heaps from the following set of notes: http://staff.ustc.edu.cn/~csli/graduate/algorithms/book6/chap21.htm. There are 2 things that are confusing me. Firstly, in the consolidate function, the author has created an array of size D(n), where D(n) is the maximum number children of a root of a...
In [1], it states that checking $f(..., x_i, ..., \bar{x}_j, ...) = f(..., \bar{x}_j, ..., x_i, ...)$ (variables $x_i$ and $x_j$ are E-symmetric) is equivalent to checking $f_{x_ix_j} = f_{\bar{x}_i\bar{x}_j}$. I am having trouble proving this statement. Using Boole's expansion theorem, we can write Boolean function $f...
I'm trying to figure out if it something that I can say for every 2 languages: is Reduction from RE\R to coRE\R always not possible, and why? (some thoughts about it: this reduction might be possible when for given language L it's both in RE and both in coRE (meaning it's in R, but when it's RE\R and coRE\R, it is not...
Is it true that for every Turing machine , there exists a circuit ensemble such that () = (), or is it true that for every circuit ensemble , there exists a Turing machine such that () = ()? Initially, I believed that the second statement was true because a Turing machine can simulate any circuit ensemble. However, u...
I heard the terms "theorem provers" and "proof assistants" tossed around before (which I assumed to be the same up until a couple seconds ago), and also of Coq, Idris, Agda, TLA+ (don't know which aforementioned camps they belong to), but are completely clueless where I should begin to verify a formal proof programmati...
Let $W$ be a linear subspace of the vector space $V = (\mathbb{Z}/2\mathbb{Z})^n$. Let $k = \dim(W)$. For $v \in V$, define the distance from $v$ to $W$ to be $d(v,W):=\min_{w\in W} d(v,w)$ where $d(v,w)$ is the Hamming distance. Given such a subspace $W$ (more precisely, receiving a basis of $k$ vectors as input), ho...
Let $P$ be the space of all possible planar graphs. Fact: A planar graph may have multiple duals based on its embedding. Let $D_p$ be the set of all possible duals of a planar graph $p\in P$ Let $S$ be the space given by union of $D_p$ for all $p \in P$ Is $S = P ?$
Problem originally from: https://train.nzoi.org.nz/problems/1311 Every light-bulb is initially off, and O(N^2) solutions are too slow. Emma is a massive nuisance at school by always meddling around with the light switches. Each day, she goes to toggle a selection of the school's N light switches, numbered from 1 to N. ...
As we can visualize and listen to a sorting algorithm sorting an array, does exist an algorithm that can generate any set of notes? More precisely, does exist a sorting algorithm so that exists a program given a set of notes to give us an array so we can hear that set of notes by sorting that generated array with the a...
You are given the root of a binary search tree (BST) and an integer val. Find the node in the BST that the node's value equals val and return the subtree rooted with that node. If such a node does not exist, return null. I have came up with a recursive solution in python, but I also want to document down the mathematic...
I would like to minimize the term where J_l and h_l are random numbers and L=10. Can somebody help me to solve the problem?
I have a problem domain that has several kinds of symmetries. I will try to keep this as general as possible. Given an array of strings: ["4533", "1234", ...] The two symmetries that I have in the problem is that you can permute any two "columns", for example "123" is equivalent to "213" (all strings are the same lengt...
Let us consider a shortest path problem with weights $w_e$ for each edge $e$. It can be formulated as a (integer) linear program (ILP). \begin{align} \min \quad &\sum_{e \in E} w_e x_e \\ s.t. \quad & A_f x_e = b_f \\ & x_e \in \{0,1\} \end{align} Here, $A_f, b_f$ are the flow conservation constraints. It is...
Just like in This thread that was posted here before, I came upon the same issue where I do not understand how are the relaxed maximum set packing problem and the minimum set cover problem are dual to each other. More precisely, how and why the optimal solution to the primal and dual LP problems should have the same va...
Given 2D arrays (number of rows between 0 and 10, number of columns between 0 and 10, elements are integers between 0 and 31) Two arrays $A,B$ are equivalent $A\sim B$ if $A$ can be transformed into $B$ via permutations of rows columns alphabet e.g. $\begin{pmatrix} 1&2&3\\ 2&2&3 \end{pmatrix} \sim \begin{pmatrix} 1&...
With a binary tree, the 3 approaches for the tree below are listed. A / \ B C Inorder => Left, Root, Right. - B, A, C Preorder => Root, Left, Right. - A, B, C Post order=> Left, Right, Root. - B, C, A I drew this up to get a better understanding because I thought of permutations with 3 el...
I have a 2D array grid where each cell has a number in it, i would need a alghorithm that returns me the value of that cell depending on the X, Y position (0, 0 is bottom left) This is the grid in question, it can be infinite in size and "grows" in such a way that it always adds first the right outer edge, starting fr...
Consider the following automaton. How does one find a DFA with an equivalent language using an algorithm? In particular, I was requested to use the algorithm described in the answer to this question. The problem arises from the fact that $a, b$ both map to $q_{1}$. Taken then the epsilon closure of $q_{0}$, denoted he...
Sorry if this is a stupid question. But it really intrigued me. Same resources at different algorithms are telling different ways to test these stuffs. Here's an algorithm and how I'd test for its 3 things. Process Larry: do{ while(turn!="Larry"); critical section turn="Jim"; r...
The Triangle Finding problem (TF) in Graph Theory was shown by Itai and Rodeh in 1977 [1] to be solvable as fast$^1$ as Boolean Matrix Multiplication (BMM, Matrix Multiplication over $\{0, 1\}$ with AND for $\times$ and OR for $+$). It seems to be common knowledge that BMM itself is solvable as fast as ordinary Matrix ...
Is there an algorithm where I provide a list of non-overlapping squares, for example: sq1 = [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)] sq2 = [(1, 0), (1, 1), (2, 1), (2, 0), (1, 0)] sq3 = [(1, 1), (1, 2), (2, 2), (2, 1), (1, 1)] and it will return some sort of "collinear convex hull" where the results will be?: res = [...
I was working on an algorithm to find prime numbers, and I needed to allocate memory for each prime number that I found so far. I will do a search up to N and need to allocate all memory in advance. I found the following : https://t5k.org/howmany.html . This gave me some nice approximations for how many numbers I shou...
Given a $3SAT$ instance with $V$ variables, where each variable occurs 4 times: twice as positive and twice as negative literal. This problem is $NP-Complete$. Now, given an additional constraint that this $3SAT$ instance is 'densely connected' as follows: For any integer $k$, if we select any $2^k-1$ clauses, the numb...
I recently discovered linear programming and it seemed perfect for a CS problem I wanted to solve a few months ago. This task involved solving a large quantity of inequalities at once. For example, one such system could be X1,X2,X3,X4 >= 0 X1 >= X3 + 3.0 or X1 < X3 - 7.2 X2 >= X4 + 5 X2 >= X3 + 3.0 or X2 < X3 - 5.3 X2 ...
I have a problem where part of it requires answering the question: does graph $G=(V,E)$ contain a clique of size at least $k$? Obviously, answering this question is a NP-Complete problem. I am no trying to find a polynomial time algorithm. I am trying to find an empirically fast algorithm that works well for moderately...
I'm working on an algorithm which is permitted to use a training set of approximately 250,000 dictionary words. I have built and providing here with a basic, working algorithm. This algorithm will match the provided masked string (e.g. a _ _ l e) to all possible words in the dictionary, tabulate the frequency of letter...
I am currently working on proving that the bounded halting problem is $EXP$-Complete. The bounded halting problem is defined by the language $L$ as follows: $$L = \{\langle M,x,t \rangle : \text{determenstic TM }M \text{ halts on }x \text{ after at most }t \text{ steps}\}$$ I have successfully shown that this language ...
I've been working on a fun esolang that operates under the idea that it only has program memory (an infinite, sequential list of registers that instructions and instruction arguments are loaded into). Any data needed for computation is loaded into a special Identity instruction - essentially, data and program share the...
Suppose we have two sets $A$ and $B$. The sets share some number of elements between them, but within each set, any item appears at most once. We want to determine how many elements they share in common. There are many algorithms to estimate this: MinHash, HyperLogLog, etc. However, all of these algorithms, and others ...
A directed tree (also called an arborescence) of $G$ is a directed subgraph of $G$ in which there exists a vertex $v$ such that there is a unique path from $v$ to every other vertex in the graph. Please help with an $O(|V| + |E|)$ algorithm that finds a directed spanning tree in $G$ or notifies if there is none.
Unable to find out how the C-language lexical analyzer would tokenize the declaration of a static array. Say, int i[3]= {1,2,3}; The lexical analyzer would need to differentiate between just an integer identifier i, and a static array of size 3. Am confused how the lexical analyzer would tokenize. Tried Holub's book, a...
Very often I see solutions to optimization problems that describe an algorithm but do not prove why the algorithm leads to an optimal answer. For example, the following problem showed up in an online competition a couple of days ago: Let quantity be an array of positive integers of size n. We would like to generate gro...
I'm looking for resources (books, papers, tutorials) on designing domain-specific query languages. I'm mostly interested in the design of syntax and grammar, rather than the implementation. Any UX-focused resources on designing general-purpose programming languages and text-based UIs would also be of some help. I tried...
I'm interested in what the typical solution is for priority resolution in interrupt controllers. I assume a hardware logic circuit is used, and not software. For interrupt controllers with fixed priority (by line ID), there is documentation easily available, such as https://en.wikipedia.org/wiki/Priority_encoder and ht...
I would like to set up some type of automation/suggestion tool for buying items on a limited spending budget. To try to somewhat formalise the problem, one could suggest to reduce this to a 0/1 knapsack problem with item i having price $p_i$ and value $v_i$ and then finding a set of items that maximise the total value,...
I understand that password storage generally uses hashing for security due to it being irreversible and that the stored hash is just compared to the hash of the password inputed by a user attempting to log in. As hashes are fixed length, does that mean that even if not specified when creating the password, all login sy...
On a finite 4-connected grid graph, given the source point and destination, it is allowed to consecutively move in one of the four orientions (up, down, left or right) to form a path. We get 1 bonus for each grid point which is NOT on the path but meanwhile has at least one neighbor on the path (bonus counting stops wh...
I am dealing with two values $a$ and $b$ such that they grow at the same asymptotic rate, i.e., $O(\frac{1}{\sqrt{N}})$. I want to achieve a reasonable bound for the difference $a - b$. When I go into the fundamentals in terms of $c_1, c_2$, I run into multiple issues. The difference be $(c_1 - c_2)\frac{1}{\sqrt{N}}$....
My question: What $P \not= NP$ or $P = NP$ could imply about arbitrary Turing machines and arbitrary computations? I assume that a partial and incomplete, but objective answer to this question exists (e.g. based on the literature, most popular research directions). Take a single arbitrary program/computation. What cou...
I'm interested in what the best way is to design a circuit that takes multiple values as input, and then outputs which value is the lowest. If multiple values are the lowest, it outputs "true" for each of them. Does anyone know an ideal design? For example, are there any classical "text-book examples" of one (or if som...
First time posting here. If we have the logical statement ($A$ and $B$) $\rightarrow$ $C$ ($1$), we know that it is equivalent to ($A$ and $B$) $\rightarrow$ ($C$ and $A$) ($2$). Therefore if we wanted to prove the $\iff$ case for the first statement, we would need to prove $C$ $\rightarrow$ ($A$ and $B$). All good he...
I have been trying to find model weights for the above mentioned models, especially ViT-G/14 but have been unable to find it. The models are mentioned here https://paperswithcode.com/sota/image-classification-on-imagenet and there is a repository from google linked: https://github.com/google-research/big_vision, so I a...
I'm trying to create a machine learning program to predict the winner of UFC fights. I want to train my AI with data from previous matches, but I have encountered a problem. I wonder if the algorithm will really work because, on the website where I can retrieve the data of the fighters and their fights, the information...
Based on the Busy Beaver rules (2 letter alphabet, 2-way unbounded tape, program must halt, etc) I was wondering if the Busy Beaver for each n is also the program that does the most steps, or if there are other programs that do more steps but produce less output. Any references appreciated.
Suppose $G$ is a CFG. $G = (N, T, P, S)$, $Var(G)$ as the cardinality of $N$ $Var(L) $= min {$Var(G)$ | G is a context-free grammar and $L(G) = L$}. I have a problem in understanding a part of proof of the following lemma. lemma: Let $i_{1} , i_2 , . . . , i_{2n}$ be $2n$ pairwise different positive integers and $L = ...
I was given the following problem. Problem. Give a regular expression over $\{a, b\}$ whose language is the set of all words with an even number of $a$s, but without consecutive $a$s. For example, $bbaba$ is in the language, but $bbaab$ is not. My approach was to build an automaton with four states: $A$: even number...
I've been trying to solve a variation of this problem https://stackoverflow.com/questions/62389658/best-time-to-buy-and-sell-stocks-when-allowing-consecutive-buys-or-sells You are given an input array of non-negative integers. You are allowed to either buy 1 share or sell any number of shares that you own, or not make ...
Recently learning some core register modifications and made a loop-program that calculates the gcd. Any way to improve/shorten this version I came up with? Input for x and y go into x1 and x2 and output will be in x3. Example gcd(x1, x2) = x3 If x1 = 12, x2 = 15, then x3 = 3 Okay,now my code: X3 := x1; X4 := x2; X5 := ...
Basically I am asking if we know necessary and sufficient conditions for a problem to be solvable in, for example, $n^2$ time. Or if not, if there are any theorems on whether or not a broad class of problems can be solved in $n^2$.
I am now considering the impossibility of black-box reductions between error-correcting codes and universal hashing without multiplicative overhead in depth. I could hardly find any classical papers on the limits of black-box reductions of boolean circuits. Are there any such literature that is worth referring to?
In the slides' based animation given for backtracking, here (with code here, in the web-page ); have few doubts, in the code restated below, and the execution as shown in the call #5. #include <stdio.h> char *next; int calls = 0; int eat(char c) { calls++; if (*next == c) { next++; return 1; } return ...
This is Petersons's solution for critical section problem. I want to test mutual exclusion, progress and bounded waiting for it. Of course, it satisfied all three. Process0 while(true) { intendToEnter0=true; turn=1; while(intendToEnter1==T && turn==1); critical section intendToEnter0=false; non-critical section } Pr...
From time to time I see systems that don't allow passwords longer than 8 chars: isn't that a security risk? What am I missing, here, that might have lead to such decision?
Given: L := {w elementof {0,1}* : w=(010 | 10)(10 | t'), with t' elementof L} What words can we build with these rules? 01010, 1010, what else? Does the t' allow 010010?
I'm currently reading a paper for a literature review related to NLP and its research employs a dilated LSTM model. What is the difference between this and a regular LSTM, or more specifically what does the dilation do? I read a couple of papers explaining dilated RNN but it doesn't resonate with me. (this one in parti...
In my reference Page 22, Algorithms by Sanjoy Dasgupta, Christos H. Papadimitriou, and Umesh V. Vazirani, it says that given $x$ and $y$ are two numbers of $n$ bits long, then the sum of $x$ and $y$ is $n+1$ bits long, and assuming that each individual bit of this sum gets computed in a fixed amount of time, then the ...
According to the book " Operating Systems Concepts " , 9th edition, page 207, we have the following statement : Obviously, a nonpreemptive kernel is essentially free from race conditions on kernel data structures, as only one process is active in the kernel at a time. My question is, According to the statement, If we...
As the title says, is there a formal grammar characterization of the class of one-way stack languages?
Consider the following leader election algorithm election of a synchronous ring with a known network size $n$ (simultaneous wakeup and uni-directional communication): The leader is the node with the minimal ID The algorithm works in phase - each phase is of length $n$ in the $i$th phase, only the node with $ID=i$ is a...
Looking at the image from Wikipedia page for tree traversal what is the name for a traversal that follows the dashed line exactly with repeating visits to obtain: F, B, A, B, D, C, D, E, D, B, F, G, I, H, I, G, F; Also is there a well known algorithm for this task?
Given an instance of $3SAT$ the objective is to reduce it directly to $2P2N-3SAT$ without the reduction having any 'trivial' clauses. The trivial clauses can be where the same variable in a clause is used twice as follows: $x+\overline{x}+y=1$ or $x+x+y=1$. Both these clauses are trivial since the first is trivially TR...
I'm unsure if this satisfies the definition of vertex cover, the graph is unweighted and undirected: if not, an explanation would be super enlighting.
I've been reading the Peter Selinger's article "Control Categories and Duality: On the Categorical Semantics of the Lambda-Mu Calculus". I'm wondering about the categorical interpretation of the reduction rules. In particular, I'm trying to demonstrate that the left and right sides of $$[\alpha']\mu \alpha^A. M = M[\al...
I want to prove the following problem is NP-complete: 4-Spaced-Set: Assume you have a undirected graph $G=(V,E)$, and a positive integer $k$. Let's say a set of vertices $A \subseteq V$ is $4$-spaced if the distance between any two distinct vertices in $A$ is at least $4$. There is also a vertex weight function $w:V\to...
The $k$-vertex complete graph, $K_k$, is a $k$-tree. A $k$-tree with $n+1$ vertices $(n \geq k)$ is constructed from a $k$-tree on $n$ vertices by adding a vertex adjacent to all vertices of one of its $K_k$ subgraphs, and only to those vertices. Is there an algorithm to recognize whether a graph is a k-tree? What is i...
I was going through the book Operating Systems by Galvin. First they explain Semaphores acting like a mutex. While talking about semaphores as mutex, they mention that the wait operation of semaphores are always atomic in nature. This is how a simple snippet of wait would look. wait() { while(s<=0); s-=1; } wh...