instruction
stringlengths
35
29.1k
I found this from this PDF (https://web.stanford.edu/class/archive/cs/cs161/cs161.1168/lecture9.pdf)
I have a pretty complex problem and I am using a rather complex ILP to solve it. In a special case of the problem the ILP is reduced to the following "simple" ILP. Additionally, I know that for this special case there exist polynomial time algorithms. We have two sets of variables $V$ and $E$. $E$ can be split into thr...
My problem is this: I have a list of $n$ items $N$ (think of them as the natural numbers $1,\dots,n$) and $m$ subsets of $N$ $S_1,\dots,S_m$ which may overlap. The objective is to find a partition of the $m$ subsets $(P_1,\dots,P_k)$ for any $1\leq k\leq m$ maximising the following quantity $$ \sum_{i=1}^k\left|\bigcap...
It is quite easy to prove that f(n) + g(n) ∈ Ω(h(n)), but I am having trouble with proving/disproving that f(n) + g(n) ∈ O(h(n)). Someone suggested that this question answers mine, which it doesn't. As I've written above, proving that f(n) + g(n) ∈ Ω(h(n)) is easy. I am having trouble disproving that f(n) + g(n) ∈ O(h(...
I am looking for a map-like data structure with the following properties: it uses subsets of some set S as keys. The size of S is potentially unbounded, but does not change during the runtime the values associated with the keys are generic objects - poiters/references. Their properties are not important for the data s...
Let $\mathcal{F}$ be a family of pairs of the form $(A,b)$, where $A$ is an integer matrix and $b$ is an integer vector with the same number of rows. For every integer $k$, define $L(\mathcal{F}, k)$ to be the following family of decision problems. INPUT: a pair $(A,b)\in \mathcal{F}$. OUTPUT: "True" if there exists a...
I have a total order represented as a Hasse diagram (basically a linked list of ordered elements) and a concurrency oracle. The concurrency orracle is a function, that tells me which pairs of elements of the total order, are concurrent - should not be ordered. My goal is to use the information provided by the oracle to...
I'm generating biomes for my game and I would like to store them in a single RGB image like the one below. A color hue can then be mapped to an ID through a table lookup. The problem I face is that I would like the transition areas between the biomes to give an exact percentage of each biome's representation at any par...
I'm getting to a problem while studying my computability and complexity exam. If two languages A and B, such that A=B does that implies that coA=coB? And in general if two language are describe by different TM such that they accept a certain input. One reject everything else, while the other doesn't define anything (lo...
I feel this is a basic question but have been stuck at this for days. Consider an undirected graph with positive weights on its edges. The goal is to find is to get the shortest path between any two nodes in the graph, but considering that if there are more than one shortest path we return the path with the least numbe...
The operation I'm interested in is a slight twist on your standard search-and-replace operation, in that instead of a single pair of arguments (replaceme and withme), it takes a keyed set of N [before, after] pairs as an argument, and for each pair in the set, replaces all instances of <before> in the string with <afte...
Modern CDCL SAT solvers often can return partial assignments where missing literals mean that the value of that variable is not important for the satisfaction of the formula (i.e. it is a don't care). What I can't understand is which guarantee do I have that such don't cares are identified. So, are state-of-the-art sol...
We know that there does not exist an FPTAS for the bin packing problem because it is a strongly NP-HARD problem, as the 3-partitioning problem which is strongly np-hard, can be reduced to the bin packing problem. Moreover, by corollary 8.6 of Vazirani's approximation algorithms book, there is no FPTAS for strongly NP-h...
The title's a little provocative, sorry. In the categorical abstract machines (CAMs), technically there are no "right folds"; the only way to consume a list is from the "left" or "top" of the list. Less abstractly, a list like [1;2;3] (OCaml) or (list 1 2 3) (Scheme) can only be consumed by a CAM on a cons-by-cons basi...
I'm interested in the theory of calculating the position of an element when the face of a cube is moved - like in a Rubik's Cup. That is, for example, I rotate the face of the cube - how can I mathematically write down: all the displacements of its neighbors relative to each other the entire cube as a whole relative...
Firstly, I've tried assuming $L$ is regular and find a contradiction with help of the pumping lemma's 3 conditions, I was not able to get to a contradiction. I've tried thinking of a word $z\in \{0,1\}^*$ to attach to $wv^i$ and $wv^j$ for some $i\neq j$, and to combine that with the pumping lemma's $xy^2z\in L, k\geq...
I was experimenting with the concept of threading in java, we have a method setPriority, using which we can set thread priority. In official documentation it is given as below, But while seeing in actual execution, I observed something else, threads were executed normally as before without priority, on researching I f...
Let $L$ be a language over $\Sigma=$ {$a,b,c$} We define $\forall w\in \Sigma ^{*}$ the function $T$ s.t. $T(w)$ is the word we recieve after removing all instances of $a$ in $w$. Let $T(L)=${$ T(w) : w\in L$}, we need to show that if $L$ is regular, than so is $T(L)$. I've came to mind of an approach, which consists o...
On Wikipedia the error rate for the minhash algorithm vs baseline jaccard similarity is stated as 1/sqrt(1/hashes). But, how should one interpret this number in a practical scenario? It seems to me that this must mean avg(abs(minhash_similarity - jaccard_similarity)) rather than classification error, because classifica...
To simplify it, it seems that we can do $(L+M^*)^* = (L+M)^*$, but I also need to prove it.$(L+M)^* ⊆ (L+M^*)^*$ seems straight forward. However, $(L+M^*)^* ⊆ (L+M)^*$ is what I couldn't figure out. Should I use $ (L^*M^*)^*$ instead of $( L+M)^*$? If I use it and do induction on k, $ u ∈ (L+M^*)^*$ and u = (v1+m1)...(...
What is the complexity of the following (Python) code, that builds the list L of all subsets of size $k$ of a given set? # arr: input array # k : size of subsets # tmp : current subset # idx : current index in tmp # i : current array element # L : list of all subsets of size k def subsets(arr, k, idx, tmp, i, L = []):...
I am looking for a formula or program to help place people in classes based on their preferences. The elements of the problem are: There are 30 class choices a student can pick from. There are 400 students that are asked to rank their top ten class preferences. Each class (specialty subject, but a class by year or age,...
How should datatypes be organised in a computer programme? Is it better to utilise arrays or linked lists? I'm not sure what the difference is, but I seem to recall hearing that arrays are quicker. Or perhaps it was connected lists? So, which one should I go with?
So i'm taking this class automata and complexity at georgia tech and we were given practice material for our exam. one of the question is to give context free grammar for these two languages and the answers are: L1 L2 I can understand these and verify that these are indeed correct once I know the solution, but I'm ...
I do not understand the "execution graph" (I think that's what it's called) of the following Non-Deterministic Finite Automata, given on pg 48-49 of Sipser's Intro to TCS (3rd edition): And here is the execution graph: Why after seeing a $1$ does state $q_1$ stem into three branches? And why after seeing a $1$ does $...
The SAT problem is often explained in terms of truth tables. Given some random boolean circuit, calculate its truth table; does there exist an output of $1$ in the truth table? But how about going the other way? A function problem that inputs a truth table, and asks you to construct a boolean circuit that computes that...
Let $n$ and $r$ be positive integers. For i = 1,2,...,n, let $f_i$ be a univariate real-valued function defined in the integer domain and let $f_i(x_i)$ be $-\infty$ for negative integer $x_i$. Any non-negative integer solution $(x1,...,x_n)$ that satisfies $\sum_{i=1}^n x_i = r$ is called a feasible solution. In addit...
I have heard DNA being referred to as "code", this is because it is an instruction set which dictates the bodies' properties. However, DNA (as far as I have learned), has no conditional jumps or normal jumps. After reading the article DNA computing on Wikipedia briefly, I cannot find whether computations with DNA is Tu...
This approach has been on my mind for quite some time. I did come up with it myself, I searched some methods for determining prime numbers but never came across anything similar to this. import math n = int(input()) def is_prime(n): x=n i= 2 while(x>i): if n%i==0: return False x ...
Here is my LC-3 Assembly code. It is designed to add up the 10 values in x3100 through x3109 and store them in x310A. It correctly adds the values, storing the total in R0, however I cannot seem to get it to properly store that value in x310A. .ORIG x3000 AND R0, R0, #0 ; use R0 to store total (start at...
After having searched for a while, and after having read this https://stackoverflow.com/questions/1592649/examples-of-algorithms-which-has-o1-on-log-n-and-olog-n-complexities I was just wondering: is there some example of algorithm whose time complexity is ?$$O(n^{\log(n)})$$ Sorry for the arid question, I would just l...
Question: There are N soldiers standing in a straight line with ID 1 to N: [1,2,3,4,5] You are given array of IDs of length K in the order they are called : [3,1,2,1] When a ID is called the soldiers with that ID will attack the enemy and he will do the same damage as number of soldiers infront of him and will stand in...
Is there any algorithm that can efficiently construct a generalized suffix tree or array (or something similar) for a set of strings represented by a prefix tree (trie)? In particular, I'm wondering: How time-efficient an algorithm for this can be How space-efficient the resulting data structure can be What algorith...
Question is to simplify (LM*)* and I couldn't figure out a way to simplify it. Since (L+M)* = M*.(L.M*)*, I guess we can say that it cannot be simplified more. So how do we prove that they are the same and expression $(LM^*)^*$ cannot be simplified more
Given a set $S$, a value function $v(s)$ and a cost function $c(s)$ for all $s \in S$, and integers $B$ and $K$, the classic formulation of the Knapsack problem asks if there is a subset $S' \subseteq S$ in which $\sum_{s \in S'} v(s) \geq K$ and $\sum_{s \in S'} c(s) \leq B$. Is there a variation/special case of the K...
How is the number of collisions affected by the order of insertion of elements in a hash table using double hashing? I've tried uing different hash function for double hashing with different set of values. The position of the elements in the hash table seem to change but the number of collsion remains the same so far.
See Guy Steele's slides for what I refer to by "Computer Science Metanotation", specifically the bits about BNF. I often make use of the BNF syntax observed there, as a substitute for algebraic data types in functional programming languages. Alas, it loses quite drastically in appeal as soon as "fields" of function typ...
Suppose there is an array having at most 10 elements between 1 to 10^18. Suppose the array has elements B1,B2,.Bn. We can choose sequence A1,A2,A3,..An such that 0<=Ai<=Bi. Count How many sequences satisfy A1|A2|A3|..|An=A1+A2+A3+..An, where | is bitwise OR.
I was reading Deterministic Black Box PIT Testing for Generalized Depth 3 Arithmetic Circuits - Karnin and Shpilka In the Theorem 3.4 they told $rank(C|_V)\geq rank(C)$ We have $C|_V$ which is simple (i.e. $sim(C|_V)=C|_V$) and minimal and $C|_V\equiv 0$. Since $C\in\mathcal{F}$ and $\mathcal{F}$ is closed with respe...
In the "First Draft" JvN described an adder circuit to do binary addition, which was a much faster way of doing computer addition than using decimal lookup tables as the ENIAC had done. JvN's main reference was McCulloch and Pitts' neuron model (although Eckert and Mauchly claimed it was their idea). However, CS had de...
I have two optimization problems $A$ and $B$, and I recently managed to show that there exist functions $f$ and $g$ that are computable in polynomial time, such that for any instance $x$ of $A$ there holds $$OPT_A(x) + g(x) = OPT_B(f(x)).$$ I know that $A$ is NP-hard, which implies that $B$ must be NP-hard as well. How...
I have experimented with a grammar that I could turn into a strict left-to-right finite state automaton driven algorithm (bottom up, table driven). The FSA could be complex, that's not a problem. It doesn't need to deal with infinite recursive structures. I then moved the grammar into BNF, and built a standard SLR pars...
TLDR; Looking for Explanation of Cook-Levin theorem palatable to CS first years who are theory averse I'm a prof. teaching first year algorithms+programming and want to give my students a taste of deeper CS theory. In the very last week of class, I want to cover (in two lectures) the key idea behind Turing Machines NP-...
It seems useful to characterize terminating programs. While trying to formulate that as a well-defined question I was wondering about the following problem: Is there a maximal decidable set of terminating programs? A set is maximal if it is not the subset of another such set. A program may be a Turing Machine or an equ...
Working on logic design in class, and I'm trying to figure out how to write a specific logic function [and by write, I mean something along the lines of (x NOR y) OR (a NOR b), for example] It asks to assume 2 variables, X and Y, both of which consist of 3 bits (x2,x1,x0, and y2,y1,y0). I need to write a logic function...
Layers: We shall denote in the following the layer number by the upper script $\ell$. We have $\ell=0$ for the input layer, $\ell=1$ for the first hidden layer, and $\ell=L$ for the output layer. The number of neurons in the layer $\ell$ is denoted by $d^{(\ell)}$. In particular, $d^{(0)}$ is the number of inputs and $...
If you have an elimination rule for tuples which introduce the left and right pair into the type checking context, what do you do if the type of one of the elements is quantified and has been Skolemized. Isn't it impossible to prevent the Skolem type from escaping its scope here? For example the sequent: sk...
The problem MATCHED is defined as follows: given an infinite set S of strings of arbitrary length over the alphabet {0, 1}, determine if there exists a character of length n over the alphabet {0, 1} such that for every string s ∈ S, s and w does not match. My approach: TO prove MATCHED is in NP is easy. For NP Hard, I ...
I was asking ChatGPT local history questions, because I knew many of the answers and could test the robot. But lots of details were wrong and while it can write citations, it won't disclose its training data i.e., I can't see its blind spots.
I just had an algorithms exam and had the following problem: Supposed there are $n$ workers and $n$ objects. Each worker has a strength, $s_i$ and each object has a weight $w_i$. Each worker needs to be assigned to an object, and they can only be assigned to a specific object $w_i$ if $s_i \ge w_i$. There are also $k$ ...
Where are these number patterns, Octal and Hex, being used? I read this but I want to know where they are used in programming.
Let n be an integer. How can I write finite automata for the language L? L = {W∈{$0,1,2$}*| The $n_{th}$ from last letter in w is $0$}. (Please suggest answers; not hints.) Attempt Using Regex, I could write it as $[012]*0[012](n - 1)$ - replacing n - 1 with the actual integer value. But I'm not sure of a good program...
I have been studying the SMA* algorithm and I am having trouble understanding the backup operation. Specifically, I don't understand why the f value of a child node should be the maximum of its own f value and its parent's f value, as described in various pseudocode implementations such as the one found on Wikipedia (h...
Let $f$ be a continuous real function on $[-1,1]$. The function is accessible via queries: for any $x$, the value of $f(x)$ can be computed in constant time. If $f(-1)<0$ and $f(1)>0$, then by the intermediate value theorem, $f$ has a zero --- an $x \in [-1,1]$ for which $f(x)=0$. Suppose we want to find a zero approxi...
While working with complexity classes, I've come along the definition of $DP$ (or $D^p$): $$DP = \{L_1 \cap L_2 \mid L_1 \in NP \text{ and } L_2 \in coNP\}$$ I am interested in a different (and much shorter form) of describing this exact operation on class-level, rather than language-level $$coNP\; ? \; NP = DP$$ Since...
so I'm trying to write an algorithm in C to play the game of Reversi. I've already written in basic minimax algorithm yet I am not very satisfied with it. I want to implement alpha-beta pruning to my code to run at a higher depth. However, my code is only given 1 second to run and generate a move and I'm worrying that ...
Advanced Topics in Types and Programming Languages gives this rule section 2.2 gives this rule for dependent function application: $$\frac{\Gamma \vdash t_1 : (\Pi x : S.T) \quad \Gamma \vdash t_2 : S}{\Gamma \vdash t_1 t_2 : [ x \mapsto t_2 ] }$$ In "Modules Matter Most" Bob Harper gives this rule for ML functor app...
Motivation I want to draw pictures using indexed colors. As I have limited space for colors per-palette, I want to choose palettes in an intelligent fashion, based on the pictures I want to draw. The goal is to choose a palette so that I can draw as many pictures from a set of pictures I want to draw as possible. Forma...
I recently read about pathfinding algorithms on grids. It seems two of the most popular are Lee's algorithm and Hadlock's algorithm. Other than the space optimizations that these algorithms employ, it seems to me like both these algorithms are basically just the same as BFS and A* search respectively. In Hadlock's algo...
Can we create Xorshift generator, as Marsaglia in "Xorshift RNGs" does, using 64-bit numbers, but with period 2^96 or 2^128? He proposed PRNG with period 2^96: t=(xˆ(x<<3))ˆ(yˆ(y>>19))ˆ(zˆ(z<<6));x=y;y=z;return(z=t); But this works on 32-bit ints, as I think. I can't generalize his work to create similar thing working...
Is Dijkstra's shortest-path graph algorithm used in cheapest airfare calculators like Expedia or CheapAir?
The problem is as follows: The input is an array $A$ of $n$ natural numbers such that: (1) if the maximum occurs in $A[p]$ for an index $p$, then $$A[1] \leq \ldots \leq A[p-1] \leq A[p]$$ and $$A[p] \geq A[p+1] \ldots \geq A[n];$$ (2) if $A[i]=A[j]=x$ then $A[k]=x$ for $i \leq k \leq j$. The goal is to find the maxi...
Consider a graph with $n$ nodes and $m = \mathcal{O}(n^2)$ edges. The maximum capacity among all edges is denoted by $C$. The running time is given by: $\mathcal{O}(nmC)$ If I consider the input size in bits, it can be stated as: $\mathcal{O}(n \log n + m \log n + m \log C)$ Denote $v:= \log n, b:= \log C $. Then it h...
I'm reading a book which says that to transform a number from decimal representation to binary representation you have to follow these steps: Take the integer part (the one before the point) of the number and transform it in binary like you normally do with integer numbers: that is the integer part of the binary repre...
I've got homework to design NFA to accept a set of strings over {a,b,c} in which each string of the language satisfies: "cac" is a substring and "cc" is not a substring and the length of the string is even. I tried to approach the problem by looking at the shortest strings of the language and building a template for th...
Given a bipartite graph, find a set of nodes on one side that has greater cardinality than the set of its neighbours on the other side. This is a conceptually simple problem, but I suspect it is actually quite difficult.
Assume we have a deterministic infinite automaton. $DIA = (Q, δ, q_0, F)$. Meaning there is no limit to the number of states. I want to prove or disprove that this module equals a normal DFA. Attempt I tried to disprove it using the language L = {$a^nb^n|0 < n ∈ N$}, but I am not sure if this is enough to disprove it....
Given a set of n points, and a number k decide whether there exist k straight lines such that all of the points are covered. Here a point is covered by a line if that point lies on that line. I can formulate an ILP for the same. The problem seems to be hard. I want to formally prove its NP-Completeness. Note that, for ...
I was going through the main idea of solution to this problem. I could not assimilate the idea of reversing the edges and then using that graph to check if node 1 is reachable from all others. How come reversing the graph not affect the original conditions and is applicable to be used for the intended purpose? Is this ...
I have very large sets $A,B$ of 4-tuples of integers, and I would like to find $(x_1,y_1,z_1,w_1)\in A,(x_2,y_2,z_2,w_2)\in B$ such that $$x_1x_2 + y_1y_2 + z_1z_2 + w_1w_2 = 0.$$ Of course the naive $|A||B|$-time algorithm is too slow for me. Is there a better algorithm? In 2D you can normalize all the vectors then fo...
I am watching MIT's Introduction to Data Structure and there is something I'm not understanding at the 14:48 mark Why does the machine word size, w have to be >= lg(n) where n is the length of a static array? As I understand a static array, [1,2,3] is stored consecutively in the RAM like: $$|*|*|1|2|3|*|*|*|$$ If each ...
Let's say I have a set of non-repeating arcs, e.g. (0,1), (3,0), (0,3), (1,2), (2,3), ("set" because they don't repeat). Here's an example of a graph for which this series of arcs would form a valid path: And a valid path would be (0,1), (1,2), (2,3), (3,0), (0,3). Note that the path might not be unique (and that's ...
The combinatorial number system shows that there is a bijection between the natural numbers less than $n \choose k$ and $n\choose k$ combinations. There is a greedy algorithm for unranking combinations, which one may calculate the worst-case run time for. I'm curious: is this the fastest algorithm in terms of asymptoti...
In the counting number of islands problem, I noticed that one of the solution from internet is as follows def visitIslandDFS(grid, i, j): if (i < 0 or i >= len(grid) or j < 0 or j >= len(grid[0])): return # return, if it is not a valid cell if (grid[i][j] == '0'): return # return, if it is a...
As far as I understand, when doing this operation, we first need to identify the subnormal value, normalise it, adjust the exponent, and then multiply the significands. Wouldn't it be advantageous to just multiply the significands and use a leading-zero counter on the result? It seems like removing some steps could spe...
I am new to optimization methods. What is the meaning of "crossover probability" in optimization methods? I was reading the following lines from an article that this question came into my mind: In unmodified differential evolution (DE) algorithm, crossover probability is constant and remains unchanged during the whole...
Chaitin’s version of Gödel’s theorem roughly states that there exists a constant c such that for each string of one’s and zeroes x, the sentence “the algorithmic information complexity (Kolmogorov complexity) of x is greater than c” is unprovable, even though there are an infinite number of x’s in which the sentence is...
Consider the following string: stryng = "{\"Jordi\", \"Jordy\", \"Jorde\", \"Jordie\", \"Jordee\", \"Joardi\", \"Joardy\", \"Joarde\", \"Joardie\", \"Joardee\"}" That string represents a mathematical set of strings. $\begin{Bmatrix} \mathtt{Jordi}, \mathtt{Jordy}, \mathtt{Jorde}, \mathtt{Jordie}, \mathtt{Jordee}, \mat...
Does anyone know of the data structure/algorithm for this use case? Given 300k words, -> find all words with some letters present (letters could be in any order)? For example find all words with letters a,a,d? (so for example "academics" and "captained" are some of the matches) I initially looked into GADDAG, but it's ...
Given two regular languages (fx given by it's accepting regular expression), is there an algorithm to determine if one is a subset of the other?
Prove that for $A, B \in \mathbb{Z}$, $A + B = (A \operatorname{\&} B) + (A \mid B) = (A \oplus B) + 2(A \operatorname{\&} B)$ where $\&$ is bitwise AND, $|$ is bitwise OR and $\oplus$ is bitwise XOR. (It is reasonable to assume that the bit representation of integers is two's complements.) The statement above appears ...
BDDs are a way of representing Boolean formulas. DPLL is an algorithm to determine satisfiability of Boolean formulas. My understanding is that the two are used for SAT solving. How are they combined?
How do we quantify the size of a regular expression? A problem in computer science which sometimes arises is converting a regular expression into a tree. What rules can we use to ensure that the tree will have a predictable number of nodes? I know what to do for simple character classes such as [0-9] and [A-Z]. Howeve...
We seek an algorithm. Inputs to the algorithm are a set of strings $A$ and the output of the algorithm $A$ is a regular expression $r$ such that: The size of regular expression $r$ is minimized. If $A^{\prime}$ is set of strings described by regular expression $r$, then $A \subseteq A^{\prime}$. In other words, the ...
Consider the following problem: You are given two integer arrays $A$ and $B$ of size $N$ and $M$, respectively. You are guaranteed that $1 <= A[i] <= M$ and $1 <= B[i] <= N$ for all $i$ (so each array's elements is at most the other array's size). The sizes of the arrays, $N$ and $M$, may be up to $100,000$. Construct ...
Let $C_1, ..., C_m \in \mathbb{R}^n$ Is there a polynomial algorithm in $n,m$ which finds the Minimum Enclosing Ball (MEB) for these points? My research I see mentions of algorithms like Megido, Waltz etc. which are known to solve the problem in linear time in $m$, the number of points, but these seem to be exponential...
From Chapter 35 of Introduction to Algorithms by Cormen et al. EXACT-SUBSET-SUM is an exponential-time algorithm in general, although it is a polynomial-time algorithm in the special cases in which $t$ is polynomial in $|S|$ or all the numbers in $S$ are bounded by a polynomial in $|S|$. I fail to see the reason here...
In chapter 8 of the book "Introduction to Algorithms" by Cormen, Leiserson, Rivest, and Stein, lemma 8.4 is proved. (my question is after the proof of the lemma) Given $n$ $b$-bit numbers and any positive integer $r≤b$, RADIX-SORT correctly sorts these numbers in $Θ((b/r)(n+2^r))$ time if the stable sort it uses takes...
Recently I came across a problem I don't get may hands on: Given p binary positions. Let s be the number of "set-bits" (1 < s < p * 2^(p-1) - 1). I need the maximal set of assigments that alltogether set s bits. Example: p = 3, s = 8. ==> A "maximal" set: {(0,0,1), (0,1,0), (1,1,0), (0,1,1), (1,0,1)} At the whole 8 bit...
So I have 2 sorted arrays which will have the same length and what I need to do is sort the union array (the union of the two sorted arrays) and then find two median values, I need to do this in O(log n). I was able to come up with finding the median in log(n) but that is without sorting the arrays, I could use one of ...
Suppose we have a problem, $A$, and a machine $T_A$ that solves $A$. Now, let's say we have a problem $B$ that is solvable with a polynomial number of calls to $T_A$, and we call $T_B$ the machine that solves $B$ by calling $T_A$. But $T_B$ solves $B$ with probability $\frac{2}{3}$. Does $B$ still reduce to $A$ in this...
Assume the pipeline is initially empty and the processor is given 8 instructions to execute. However, the 4th instruction is an instruction whose operands depend on the result of the previous instruction. The remaining instructions are independent of each other. Given the instructions are not re-ordered, how long does ...
I have a digraph D on n vertices formed in the following manner: I start with k ordered (not sorted) lists of integers, with each integer from 1-n in at least one list. Integers do not show up more than once in a given list. I create a node for each integer, with an arc from node x to y if x appears before y in at lea...
Given a set of weighted permutations of numbers, an operation can be performed to combine multiple permutations that share numbers into a single rolled up permutation. What is the optimal algorithm to bucket the values into the minimal number of combined permutations? Examples permutation (weight) 1 2 4 (1) 1 2 5 (1) ...
With the Circuit-SAT problem, I often see the "split" gate (I don't know the official name of it). This gate has a truth table of: $$ \begin{array}{|c |c c|} 0 & 0 & 0\\ 1 & 1 & 1\\ \end{array} $$ And it has a symbol of this: This gate allows us to use variable names more than once when we translate circuits to CNF. I...
I do recall having found a book on software design patterns with a foreword by Christopher Alexander. Now, as is well known Alexander is credited as the creator of the concept of design patterns and design languages. In this particular text, he also described how he first came to know his work was being used in compute...
A round of Salsa20 is done as follows: b ^= (a + d) <<< 7; c ^= (b + a) <<< 9; d ^= (c + b) <<< 13; a ^= (d + c) <<< 18; The Salsa20 variant called ChaCha20 has its round function like this: a += b; d ^= a; d <<<= 16; c += d; b ^= c; b <<<= 12; a += b; d ^= a; d <<<= 8; c += d; b ^= c; b <<<= 7; ChaCha20 has 8 mo...
Given a bipartite graph $G=(V,E)$ and an integer $l$, how many edge subsets ($E'\subseteq E$) of size $l$ are there such that the degree of each vertex in the resulting subgraph $G'=(V,E')$ is odd? I have not been able to come up with anything smarter than explicitly enumerating all possible subsets and checking whethe...
NP-complete problems are the "hardest problems" in NP. This means that all other problems in NP reduce (in polytime) to these problems. A consequence of this is if we were to find some polynomial time algorithm to solve one of these problems, we could prove $P = NP$. And if we could prove that no polynomial time algori...
I am trying to understand which combinatorial problem best fits the one I have. I am mostly asking from the perspective of being pointed towards relevant literature. I will explain the problem with an example. Consider the set $S = \lbrace{a^1, a^2, a^3, b^1, b^2, b^3, b^4, c^1, d^1, d^2, d^3, d^4 \rbrace}$. So note th...