instruction
stringlengths
35
29.1k
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...
By an algorithm $A(p, t)$ attempting to decide whether the program $p$ halts or not by running the program for $t$ seconds (the timeout) and trying to prove that it doesn't halt at the same time, can it decide more and more programs as the time gets bigger, so that any program would result in the algorithm in showing u...
I didn't find an exact description for this, but I know that any integer type is a simple bit pattern, it seems to me that the simple bit pattern should have a more exact description as I understand simple bit pattern are synonym for primitives
In section 3.7.1, of the book titled: Compiler design in C, by Allen I. Holub (made available freely online, by the author here, & the page #19 of errata, here), have on page #176, the mention of grammar, for a right-recursive list: stmt_list -> stmt stmt_list | stmt stmt -> A | B| C while on the previous page, the le...
I'm looking at this diagram from Ben Eater's "8 bit computer" tutorial What's the need to use separate 8 wires for only data input, and another 8 wires only for data output? Why not use only 8 wires for both input and output to the bus?
There's a sentence in the current version of the Wikipedia page for Shor's algorithm which states: we can use efficient classical algorithms to check if $N$ is a prime power. No reference is provided to support it. Is this true? I've tried to look around for such an algorithm but didn't find much. There is this website...
I have a list of lists T. I stress test my database software by randomly adding and removing sublists and elements of sublists to/from T and from/to my database. (After this I compare T with the database, because they must be identical, because they underwent the same sequence of insertions/deletions.) I want the rando...
I am preparing for an exam in computability and still learning about the idea of reductions. I found an interesting problem to start with and am curious if my approach is correct: Let H0 be the halting problem starting on an empty tape, and let A be a decision problem defined as A ∶= {x ∈ N ∣ x < 10}. Show or disprove:...
As far as I know, the halting problem means we can't create a program that checks whether another program is stuck or halt based on given input. This means, the program expects two inputs and one boolean output. For example in a Python language, there's program called is_halt.py expecting one input integer. Let's say t...
An undirected graph $G=(V,E)$ is "evenly connected" if for every $v\in V$ there's a (not neceserally simple!) path to all the other vertices, with even number of edges. Let $G=(V,E)$ be an undirected graph where $3\leq |V|, 2\leq |E|$. We want the minimal number of edges we need to add to $G$ in order to make the graph...
There's a very similarly sounding question with an answer already, but my setup is very, very different. You are given $k$ half spaces in dimension $d$, defined by a point and a direction. You want to find all vertices in the polytope if it is bounded, otherwise, you want to close it (i.e. make it bounded), then find a...
I'm making a web application that can generate unique unsigned Int32 post IDs for posts. Normally I would just make it auto-increment from 0. But I don't want the user to "guess" what's the next ID will be from their own post ID. So I would like the sequence to be random. Let's say the very first post has the ID of 968...
I am currently reading the Crafting Interpreter book and I have a question about the Resolving and Binding chapter The author gave this example to illustrate the problem with the implementation at that point in the book. var a = "global"; { fun showA() { print a; } showA(); var a = "block"; showA(); } T...
I have been studying the polynomial hierarchy recently, and I came across an intriguing claim that I would like to explore further: Assuming co-$NP\subseteq NP\text{/}P$, the claim states that it implies $\Sigma_3^P=\Pi_3^P$, which, in turn, leads to the conclusion that $PH=\Pi_3^P=\Sigma_3^P$. I find this claim fascin...
I had been reading about File systems recently and came across the File Allocation Table in FAT systems. As per my understanding the File Allocation Table contains entries of the various files stored in the partition. This includes things starting cluster, ending cluster, file name etc (I still didn't understand exactl...
Consider the following variation on the Interval Scheduling Problem You have a processor that can operate 24 hours a day, every day. People submit requests to run daily jobs on the processor. Each such job comes with a start time and an end time; if the job is accepted to run on the processor, it must run continuously,...
regular ANS collects all the data into one big integer and provides optimal compression. In cases where all the symbol probabilities are powers of two, it is just as good as huffman coding (because huffman coding is also optimal in this case). Streaming ANS lets us avoid the need to use a BigInteger or other expensive ...
I want to implement a delaunay triangulator by using incremental building, which is purported to be $O(n \log(n))$ I am a little puzzled about 2 things. Ever resource I read on the matter says: Make 3 points that are large enough to contain all other points. For each point, find the face that contains it, split that f...
I'm looking for the most efficient way of solving an Levenshtein edit distance problem. We are given as input: A set of strings S of size n <= 8, with average length m <= 50 A target string t of length l <= 50 Our task is to 'align' t with S i.e: Find the subset s* of S, where concat(s*) has the minimum Levenshtei...
I am a research scholar in the field of algorithms and complexity theory. The problem that I am currently working is the $[1,j]$-domination problem. Given a graph $G = (V, E)$, with $n = |V|$, the problem asks to compute a minimum dominating set $D$, such that all the vertices outside the solution set $D$ have at most ...
Currently I'm exploring LALR(1) lookahead generation algorithms to implement. I've implemented Aho and Ullman one from their textbook, but recently stumbled upon "A new analysis of LALR formalisms" paper by Park, Choe, Chang. There they propose an efficient algorithm (commonly referred to as PCC) and provide proofs, pe...
Assume we have a set of $s$ vertices, say $\{w_1,\ldots,w_s\}$. Assume every vertex $w_i$ has at most $q$ neighbours coloured either red or blue, for some positive integer $q\ge 1$. I would like to check how many neighbours of each colour $w_i$ for each $i\in \{1,\ldots,s\}$ has. What is the complexity of doing it? Sin...
I've been playing Bananagrams recently, and have begun to wonder about the math behind it from a computational perspective. I've tried to formalize the problem as a decision problem below. Loosely formal definition: Given a finite set (alphabet) $A$ of letters, a finite set (dictionary) $D \subset$(Set of all finite ...
One classic fair division allocation problem is to allocate indivisible goods among agents with respect to envy freeness (no agent envies another agent). In my settings, all the goods are divisible (we can split the goods), but we restrict the number of shared goods to one. So only one good can be split, but the split ...
I've been doings some research into distributed solutions for a large system of linear equations (reading papers such as Wang et al.'s "Solving a system of linear equations: From centralized to distributed algorithms"). Before implementing a solution myself I wanted to see if there are already any free or paid implemen...
LeetCode problem 1386. Cinema Seat Allocation requires finding the number of 4-person seating groups available (subject to certain constraints) after individual seat reservations have been made. The problem is tagged by LeetCode as Greedy. The constraints are that there are only 3 permissible 4-person groupings per row...
Could someone clarify what strings are accepted by the described DFA? Draw a DFA for the set of all strings with two consecutive 0’s followed by two consecutive 1’s over Ʃ= {0,1}
Assume I generate a random binary tree with a bounded height with $n$ nodes. For a given key we measure the length of its path (the maximum can be $n-1$). So my Question is what is the distribution of the path length? The tree is constructed by recursively partitioning the given n points until all points are isolated o...
What I need is similar to garbage collection but a bit different, consider the following code: int* large_arr = new int [1000000]; ... int b = large_arr[0]; int c = large_arr[1] * large_arr[2]; //after here large_arr is never used int d = b + c; ... So whether it's possible for compilers to detect after the comment li...
Consider sorting on $n$ distinct elements, where all $n!$ permutations are possible. I think a decision tree for comparison sort can can be uniquely characterized as $T(a,n!)$ where $a$ is the comparison sort algorithm and $n!$ is the number of leaves. I believe there's a bijection between number of leaves and the numb...