instruction
stringlengths
35
29.1k
I have been on this problem for very long time, Lets assume we have a shopping list eg:{milk,bread,coke,orange,apple,..} and the shop only sells pack of thing and not individual things eg: [{milk, bread}, {bread,orange} , {orange,apple} ...]. Given the cost of each package. Is there any algorithm to minimize the cost s...
Is there any proof or reference or intuition for the following theorem related to AAD: Any function f of n variables f(x1,...,xn) can be differentiated with respect to every variable xi at a computational cost that does not exceed 4 times the complexity of one computation of f. Thank you
If K = {<<M>> | L(M) has at least 1 word}, then does K belong to the class of recursive enumerable (RE) languages or its complement? I'm a bit confused, because if it is RE, then we'd have a TM W that semidecides it, but even for some language, L(M), that does halt for at least a word, we don't know which word it is an...
I have a matrix with three possible elements: A, B and C. The size of the matrix could be a maximum of 15x16. $$ \begin{bmatrix} A & A & C & A\\ A & C & B & C\\ A & C & B & C\\ A & A & C & A \end{bmatrix} $$ I need create a second matrix with the same size but different types. I need to cover all Cs with a "group", but...
The question is to convert the following regular expression to an NFA: $\emptyset^*$. I know that the symbol phi in Theory Of Computation means an empty set. But what does phi^* mean?
I read this article, mentioning that either here, or StackOverflow would be the best places to ask generic machine learning questions, however, if the question isn't programming specific with a minimal reproducible example, the mod's at S.O. can't wait to shut you down pretty quick, so figured I'd try here first. I'm d...
$A$ is an array of length $n$ $B$ is an $n\times n$ matrix \ I want to return an array C of size n such that: $$C_{i} = \sum_{j=1}^{n} \max(0, a_i - b_{ij}) $$ In pseudocode it could be like below for i = 1 to n: C[i] = 0 for j = 1 to n: C[i] += max(0, a[i] - b[i,j]) this runs on O(n^2) but it is pos...
$A$ is a $m*n$ matrix $B$ is an $n*n$ matrix I want to return matrix C of size m*n such that: $C_{ij} = \sum_{k=1}^{n} max(0, a_{ij} - b_{jk}) $ In pseudocode it could be like below for i = 1 to m: for j = 1 to n: C[i,j] = 0 for k = 1 to n: C[i,j] += max(0, a[i,j] - b[j,k]) this runs on $O...
The node weighted Steiner Tree Problem as found in this compendium: $\textbf{Instance}: \text{Graph } G = (V, E)\text{, set of terminals } S \subseteq V \text{ and a node weight function } w:V \to \mathbb{R}^+$ $\textbf{Solution}: \text{A tree } T = (V_T,E_T) \text{ in } G \text{, such that } S\subseteq V_T \subseteq V...
Given a DFA with m number of input alphabet and n number of states. What is time complexity to check DFA accepts infinite language (i.e infinite length of strings)?
I have run $k$-means on a large set of high-dimensional data, and now I want to find the distance from a point $x$ to the Voronoi cell associated with one of the $k$ centroids. (In a previous version of the question, I called this cell a "cluster", but that terminology might be confusing since one might think of a clu...
I have been struggling with this contest problem for awhile now which is found at this link: https://people.eecs.berkeley.edu/~hilfingr/programming-contest/pacific-northwest/2009/b.pdf Short summary of problem: Given an n×m board (3 ≤ n≤6, 5≤m≤50) move a Blenjeel sand worm (of length n) from the left column to the rig...
Here is the puzzle I was asked in an interview There's a List of Employee objects. Update all the objects in the list to be eligibleForHike if at least one employee exists whose salary is less than x; otherwise update all of them in-eligibleForHike in a single iteration/loop Requirements/Restrictions: Streams should n...
I'm preparing some material for students about greedy algorithms, and there is one point that confuses me: how Dijkstra's algorithm fits into the greedy framework. I would like to say that we have some optimization problem $\min_{S \in D} f(S)$. E.g.: For MST, $S$ is a spanning tree and $f(S) = \sum_{e \in S} w(e)$ Fo...
I'm wondering about the optimal complexity - or at the very least, some way of achieving non-terrible complexity - of a particular stack variant, that I'm calling a 'nonrepetitive stack'. A nonrepetitive stack is like an ordinary stack, except that a push that would result in a repeated subsequence fails, not updating ...
As is well-known (and easy to prove), carrying out a sieve of Eratosthenes on the first $N$ integers takes a number of word operations in the order of $N \sum_{p\leq \sqrt{N}} 1/p \sim N \log \log N$, whether one uses it for finding the primes up to $N$ or for factoring the numbers up to $N$. It is also well-known that...
I am thinking about the problem of storing traces of games like Chess and Othello in an information-theoretic minimal number of bits. My idea was to think of a game as an ordered tree of possible moves that could be taken. Let's say in one game there are 20 moves available initially, then 8 on the second turn, then 5 o...
According to the computer organization and design RISC-V 2nd edition 2020, section 1.5, the following table states that ISA affects clock rate. Hardware or software component Affects what? How? Algorith instruction count, CPI The algorithm determines the number of source program instructions executed and hence ...
I have a grammar which is mostly LL(1), save for the fact that some tokens may be promoted to larger integer types. For example, let take the following grammar S ::= terminal1 S1 S1 ::= integer_16 S2 | integer_32 S3 where S2 and S3 can share a common prefix but we assume the above grammar can be rewritten as LL(1), sa...
I am running into a problem in which I have names with different romanization methods, and I need to correctly compare them to see which names match. An example is romanized Korean variants: Seong vs Sung vs Song are all romanized variants of the same Korean character. A Levenshtein ratio would say that these are all d...
Also known as CMU 15-455, Spring 2017, Homework 2.4. Before I ask the main questions, let me first give a sketch of my idea. First, recall the definition of big-$O$ and time complexity class $TIME(t(n))$. Definition: Let $f$ and $g$ be functions $f$, $g$: $\mathbb{N}$ $\rightarrow$ $\mathbb{R}^+$. Say that $f(n)$ = $O...
Suppose $l=[a[0],a[1],a[2],,a[n]]$ be a list of numbers. I need to calculate $$ \sum a[j]a[k]a[j']a[k'] $$ such that $j+k=j'+k'$ .Obviously we can implement it in $O(n^4)$ time complexity by the exhaustive search method.Can we do it better?It is pertinent to mention the number of tuples satisfying $j+k=j'+k'$ are app...
The Coin Change problem is stated as: Given an integer array coins[ ] of size N representing different denominations of currency and an integer sum, find the number of ways you can make sum by using different combinations from coins[ ]. Note: Assume that you have an infinite supply of each type of coin. So for exampl...
I have a dataset of billions of points (stars) scattered on a two dimensional plane (sky), each with its corresponding (brightness) value. How can I efficiently find locations for a fixed size rectangle (corresponding to a telescope field of view) for which the point values sum up to a minimum?
I am doing some research for a paper that I am writing and one of the papers that I have come across that has some interesting results talks about an "almost tight bound". I am not a computer scientist and I feel like I understand the actual math of the bounding. However, I don't know what it means by "almost tight". I...
Background I'm looking to replicate (as closely as possible) the graphs depicted in this question (in MetaPost). Overview The green edges and large green nodes in the following image depict a graph (the grid and small nodes are irrelevant): The graph's properties include: Connected Uniformly random (or nearly so) Mul...
Given the programming language C#, how would I be able to write the BNF and EBNF grammar syntax of its while loop? After trying to search and understand more, I got this as my BNF grammar for while loops < while-statement > :: = < do-statement >< while-statement > | < do-statement > though I don't think it's quite righ...
I have to find the context-free grammar of this language: $ L=\{a^nb^m, n\neq 2m\} $ So I did: $ S \to a \mid aYb \mid \epsilon$ $Y \to aSb \mid X \mid \epsilon$ $X \to bX \mid \epsilon $ is it correct?
I couldn't search much about a problem I have. There is a 1D array of zeros and ones. The objective is to pack all ones with the least number of containers. Each container is variable in length but has a maximum length limit. Items in array cannot be moved. For example, if the max length limit is 5, I would pack ones l...
I was looking into complexity theory and disappointed by the fact that a problem as simple as sorting an array isn't in the class $P$. This is because the class is defined only for decision problems (ones that have a binary answer). I know that any optimization problem can be turned into a decision problem by imposing ...
I encountered many articles on max-flow problem that do not go beyond simple graphs in which two nodes are either connected with a single directed edge OR two nodes are connected with a single undirected edge, therefore making the capacity symmetric. When two nodes are connected with more than one edge, they use "trick...
If we find a problem we know for sure is in NP but not in NP-complete or P, we'll have proved P!=NP. One approach then is to identify problems in NP (but not P) we haven't been able to show to be NP-complete so far and try to prove they aren't in that set. Any examples of such problems? Preferably one problem per answe...
Let's say number of elements are a power of 4. Now if we break the array in parts of 1/4 and 3/4, how do we calculate the time complexity in this case?
R C Lacher's definition: A binary tree is complete iff the only vertices with less than two children are in the bottom two layers. Paul E. Black's definition: A binary tree in which every level (depth), except possibly the deepest, is completely filled. At depth n, the height of the tree, all nodes must be as far le...
Sometimes we need some prime number with certain minimum size for modular algorithm. For practical purposes we can precompute (using fast randomized algorithms) table of some primes for range which makes sense in application. However I'm interested how fast theoretically (in terms of time complexity on $n$) we can find...
From Wikipedia on $\mathrm{NP}$-completenes: "a [decision] problem is NP-complete if it is both in NP and NP-hard." [link] I think we can paraphrase this as the first statement: An $\mathrm{NP}$-hard (decision) problem $\Pi$ is $\mathrm{NP}$-complete if and only if $\Pi \in \mathrm{NP}$. $\#\mathrm P$-complete (count...
if a BFS is applied on a graph is it necessary that the resultant BFS tree contains all the edges that are in the original graph ?
I have a constraint system which I seek to find solutions for. The constraints consist of lesser/equal inequalities which have a difference of two minimum expressions on their right side, for example: $x_1 \leq min((x_2),(x_5 + x_6)) - min((x_3),(x_7 + x_8 + x_9))$ $x_2 \leq min((x_3 + x_4), (x_7)) - min((x_5 + x_8), (...
This is the first concept in The Little Typer to give me quite a bit of trouble, and it appears I am not alone (1 2), so perhaps it would be beneficial to ask here. Hopefully this can be connected with more general concepts to expand the audience for this question beyond people reading the book. The textbook The Little...
Well, I know that I'm going to ask too much. So, I really want to ask you a totally (powerful (!)) free completely off-line code to generate prompt-based images like midjourney. I want to run with my graphics card and memory without any restrictions of time or number of images and completely private. My question is: do...
Our professor has solved an example for us. They taught us it's incorrect to use a quantifier (exists or forall) with a variable that's already bound on the left side of the pipe (|, meaning "such that"). They've done that in their example solution. Can quantifiers be used on variables bound on the left side of the pip...
Given a list of integers NUMS and an integer k (buckets), we must allocate every integer from NUMS to some bucket such that maximum of sum of integers across all buckets is minimised. A simple algorithm which first sorts NUMS and then allocates integer to smallest bucket so far doesn't work. Eg. 5,5,4,4,4 for k=2. Outp...
Not sure if this is the right StackExchange site, but back in college (20 years ago) I took a Digital Systems Design class where we learned how to reverse engineer a boolean function to meet the requirements set forth in a logic table. If I recall correctly, the logic table looked something like this: Input A I...
This is a quote from the book, "The Three-Body Problem" (page 112 in the paperback): He remembered taking a class in information theory as a third-year student in college. The professor had put up two pictures: One was the famous Song Dynasty painting Along the River During the Qinming Festival , full of fine, rich de...
Given a sequence $a_1,\ldots,a_n$, we want to compute $$\prod_{\ell=1}^{n-1} \prod_{r=\ell+1}^n (\max(a_\ell,\ldots,a_r) - \min(a_\ell,\ldots,a_r)).$$ For example, given $1, 2, 4$, the result should be $6$, which is $(2-1)\cdot (4-1)\cdot (4-2)$. I know how to solve this in $O(n^2)$ by computing the inner product in ti...
Suppose that we have a set of paths that all of them strat from the source "I" and end to the destination "O". The paths might have shared nodes. We are allowed to change the sequence of nodes on paths. Now, I would like to create a DAG such that the number of merging edges (converging paths) are minimized. The number ...
Given $x \leq y$, find a sum $y_1+y_2+...+y_n$ where $y_i \leq x$ and $y_{i-1} \geq y_i$ for $1 \leq i \leq n$ and $y_n$ is maximised. For example, given $x = 5$ and $y=17$, an optimal solution would be $17=5+4+4+4$
Given is a prime signature $S$ and an integer $x$. The task is to count how many integers $n$ exist such that $n \leq x$, and if $n = p_1^{k_1}p_2^{k_2}p_3^{k_3}p_4^{k_4}...$ then $S = (k_1,k_2,k_3,...)$. Let $C(S,x)$ be that count. For example, if $S = (3,1,1)$ and $x=1000$ then there are $21$ such integers, being $$1...
I have a large list of strings with associated values. I need to do a fast lookup into the list by the string prefix, but also by the string's ordinal within the list. For example, string,value,ordinal -------------------- alice, 10, 0 bob, 99, 1 carol, 32, 2 search_by_prefix("bo") -> [("bob", 99),] search_by_ordina...
I have a randomized recursive algorithm which expected running time is $T(n)$. In particular, the recursion looks like this: $$ T(n) \leq \mathcal cn + R ,$$ where $R$ is a recursive term that depends on $T(n-i)$ for some values of $i$, and $c$ is some constant. I want to add a procedure to this algorithm that samples ...
Let $P(X,Y)$ and $Q(X,Y)$ be two bivariate polynomials of degree at most $n$. Using $O(n^2)$ FFTs, we can compute the product $PQ$ in time $O(n^3\log n)$. Q: Is there a faster algorithm to compute $PQ$?
moorse_string[] = {".-", // 0 = A ('A' = ASCII code 65; 'a' = ASCII code 97) "-...", // 1 = B "-.-.", // 2 = C "-..", // 3 = D ".", // 4 = E "..-.", // 5 = F ...
Is it possible to create a some programming language compiler that will perform the composition of primitive functions with optimization? In fact, the maximum possible optimization in the context of function composition. In this case, primitive means that the code consists only of while, if, break, continue statements,...
IIUC, category theory only applies to immutable objects, and mutability is modelled within that using e.g. functors, monads. Is that true? If so, why doesn't category theory include immutability? Has no-one got round to adding that, or is it impossible? I'm asking because I've never seen category theory applied to, or ...
I'm working on this task: Prove that the following problem can be solved in time $2^{k} \cdot \Vert \varphi \Vert^{\mathcal{O}(1)}$: given a boolean formula $\Vert \varphi \Vert$ in CNF, decide whether there exists an assignment that satisfies at most $k$ clauses of $\varphi$. but with very little success so far. I'v...
I'm trying to come up with a context free grammar for the following language: $${\{0^i1^j0^k1^l0^m | i, j, k, l, m \ge 0, i \le k \text{ or } j = m \text{ (or both)}\}}$$ I'm able to come up with rules for the $i ≤ k$ case and I think the $j = m$ case but the both case is killing me.
I recently had the idea that it would be neat if it were possible to make a SAT solver play combinatorial games. To start, I'm trying a relatively simple case of solving single-stack Misère Nim through integer programming: there's a fixed limit $L$ with a set of moves $N$, where a move is added to the state each turn. ...
Every context-sensitive language $\subseteq \Sigma^* = \{a,b\}^*$ can be expressed using an essentially non-contracting grammar. With just one non-terminal symbol, we can't express all context-sensitive languages. Does there exist a minimum $k$, such that all context-sensitive languages can be expressed as a non-contra...
I'm currently learning about Data Structures and Abstractions and one particular problem has been very confusing to me, and that is the concept of Circular ArrayDeque. In particular, how can we add or remove elements at the first and last of a circular Arraydeque? I've learnt a few things so far and listed them down be...
I have an async process that receives a message then post the content to another service and acknowledges the message. To improve on the efficiency I want to batch the messages together, but can't request more than 1 message at a time from the external service. Therefore I want to create a buffer in code to batch up th...
Define the following function to be the count of integers not greater than $L$ that are coprime to $n$:$$C(n,L)=\sum_{k=1 \atop {GCD(n,k)=1}}^L1$$ Then I am interested in the following sum: $$S(x)=\sum_{d=1}^xd\cdot C(d,\Big\lfloor\frac xd \Big\rfloor)$$ $C$ can be calculated relatively fast given the prime factorizati...
With dependent types, types can be statements that are true or false and constructing a value with that type constitutes a proof of that statement. This proof/value construction is itself a program that can be run (which I think encapsulates the Curry-Howard Equivalence idea), but often these programs are not very "use...
I'm scheduling a large invitational tournament with the following conditions The event takes place over 8 weeks Teams arrive and depart on different dates/times, so each day of the event will have a different number of teams available to play Teams will play only once per day Teams have specific criteria they ask for,...
Regular expressions are a powerful practical tool for string processing. But there are simple examples of useful string processing tasks (like, say, removing brackets from an expression (E) -> E when E might itself contain brackets) which cannot be represented by a convenient regular expression. Is there a language of ...
so I know that this language is not regular, however, can you still define the language using BNF? This is the problem: {a^n b^n |n>0}
So I recently came across a question in my Algorithms class. Given a binary matrix of N X N. we can do following operation any number of times we can take a square of size M X M (1 <= M <= N) and convert all 1's to 0's in this submatrix this operation costs M coins we have to convert all 1's to 0's in least amount of...
I am struggling to find a good loop invariant for the following function, which returns a^b where a is a real number and b is a natural number: power <- function(a, b){ c <- 1 while(b > 0){ if(b %% 2 == 1){ c <- c * a } b <- floor(b / 2) a <- a * a }...
My (attempt at a) proof is as follows: $f\in o(g)$ means that $\forall c>0 \exists n_0 \forall n\geq n_0: f(n) \leq cg(n)$. Now taking the complement we get: $\exists c>0 \forall n_0 \exists n\geq n_0: f(n) > cg(n)$. Fixing some $c'$ satisfying the above and $n_0=0$ we get some $n_1 \geq 0$ where $f(n_1) > cg(n_1)$. We...
I'm trying to read chapter one of the famous book : Structure and Interpretation of computer programs. The chapter one starts with a mysterious paragraph: We are about to study the idea of a computational process. Computational processes are abstract beings that inhabit computers. As they evolve, processes manipulate ...
Is it possible to prove the total number of parenthesizations of n matrices is Ω(4^n/n^3/2) using the Induction Method? Recurrence formula from CLRS book When n = 1, the sequence consists of just one matrix, and therefore there is only one way to fully parenthesize the matrix product. When n ≥ 2, a fully parenthesized...
A question I was given $T(0) = 1,$ $T(1)=0,$ $T(n)= 2T(n-2)$ I think the possible solution is $T(n)=2^n$ Proof: by induction. Base Case: $n=0$ $T(0)=2^0=1$ Inductive Hypothesis: Assume for some $n$. $T(n)=2^n$ Show for $n+1$ $T(n+1)= 2(T(n-1))$ $=2(2^{n-1})$ $=2^n$ which is what I proposed. Is this correct? I'm a littl...
The idea for this problem comes from GATE CS 2014 Set-3 Q13. Given a graph, are there any heuristics to figure out a DFS traversal which has minimum/maximum recursion depth? Consider the graph from the question, labelled Consider the DFS traversal a-b-c-f-e-d-g-h-i-j-k-l-m-n-q-p-o-r-s-t-u with a recursion depth of 19....
CLRS pseudocode: begin for each vertex u in G.V - {s}, do u.color := white u.d := infinity u.p := NIL done s.color := green s.d := 0 s.p := NIL Q := NULL insert s into Q while Q is not null, do u = delete from Q for each v in adjacent to u, do if v.color = ...
Show that the language $\{0^n1^m0^n| m,n\in \mathbb{N}\}$ is not regular using closure properties. I tried showing this using pumping lemma but I am stuck when it comes to closure properties. Please help me out!
Consider a data structure that has only two functions. extract_lowerthan_median() and insert(). How can we design it in a way that the amortized cost for both the operation is O(1)? Using a 2 tree, a min heap and max heap will ensure that the root of min heap is always the median and allow us to extract an element smal...
I am trying to understand what an algebraic decision tree is but wikipedia lacks a formal definition, just an intuition. So I need to check if my understanding is correct. From what I have read it seems that an algebraic decision tree is: A tree where each node has exactly 2 children. Each node in the tree is a polyno...
Let $v_1,…,v_n$ be a finite list of vectors in $ℝ^k$ (with $k ≪ n$, in my case $k≈10$ and $n≈4~000$). I would like to know if I can precompute something so that given a linear form $f : ℝ^k→ℝ$, I can quickly get the $i$ maximizing $f(v_i)$. If $k=2$, I can do that with a convex envelope and a binary search. But even fo...
I have seen many posts which were related to algorithms for solving an N⨯N puzzle, but I could not figure out the time complexity or memory complexity in these algorithms, especially when we want to apply DFS and BFS for solving our puzzle. For example, if we assume that at first, the elements are not at their place, b...
I'm looking for some machine learning algorithm to train on data that are sampled from some submodular set function and I want the learned model predictions also obey submodularity. For example linear regression can do this (because it's linear hence it produce a model that obey both submodularity and supermodularity) ...
I've recently been designing a simple 8-bit microprocessor, similar to the Intel 8008. It doesn't make use of anything advanced as pipelining, as my knowledge isn't at that level yet to know how to implement it. The address length of 14 bits, and an instruction lengths ranging from 1 to 3 bytes. I've been researching, ...
The question is basically the title. If two NP-Complete problems reduce to each other, do we know that the reductions take equal amounts of time? What about space? Does this apply for all 'invertible' reductions?
I am studying graph algorithms, and I know that in algorithm theory there has to be an invariant of sorts that stays the same during the algorithm run that makes the algorithm valid and right to use. But I can't seem to find the invariant in Kosaraju's algorithm for finding strongly connected components. What is it tha...
I have a list of companies with n timeslots (number of slots may vary from company to company) and a list of students. Each student made a list of their top 3 companies they would like to talk to. Is there an algorithm to efficiently match those students to timeslots, taking the student's preferences into account? I al...
This is a bit of a theoretical question. I would like to know how to call the principle described below, in proper computer science terms, or math terms. Let's say we have a database in which one entity is split into two tables: main and meta. The main table is a matrix where rows are instances (for instance each row i...
On a turing machine and in the lambda calculus one can define transcendental numbers such as Pi, the golden ratio, etc. These are computatible functions with 0-arity that never terminate. In the theory of general recursive functions (which also defines the same class of functions as turing machines and lambda calculus)...
An undecidable problem is a decision problem proven to be impossible to construct an algorithm that always leads to a correct yes-or-no answer. I wonder if there are examples of probabilistic approaches (in the following sense below) that solve such problems. By a probabilistic approach, I mean a nondetermistic algorit...
The halting problem is semi-decidable. Does that mean that: If a program terminates it can always be established/determined? If a program does not terminate It can sometimes be established/determined? It can sometimes not be established/determined? When we write programs we can clearly proof in some instances that...
Non-computer scientist here, trying to understand what SICP (Structure and Interpretation of Computer Programs) means by a procedure, whether it matches the dictionary definition, and also how a procedure relates to an algorithm (so maybe I should ask separate questions). First, SICP defines a process: We are about to...
I wonder if there are "standard" models of computation that are less powerful than DFA that are still "mathematically interesting"? It is evident that restricting the set of DFAs in various conceivable ways easily yields examples, but would any of those generate considerably interesting mathematical questions?
Given a known strongly NP Complete problem $A$. If there is a polynomial time transformation from $A$ to another problem NP Complete problem $B$ does that imply anything about if $B$ is always/automatically strongly NP complete or not? I don't think that it is necessary that $B$ is always/automatically strongly NP Comp...
The halting problem is semi-decidable, which means that if a program terminates then it will always be able to be determined. Some programs can be proven to terminate without running them, with say: induction typed theories, such as typed lambda calculus. Ackermann function Are there some programs for which there is ...
I have consulted the literature concerning graph isomorphism algorithms, and all papers I could find involve finding a canonical representation of a graph. So to decide whether two graphs are isomorphic, you just check if they have the same canonical representation (i.e. the same equivalence class). There is, also, an ...
I found a one question I wonder, but there is something to be clear about. The link is https://electronics.stackexchange.com/questions/56488/parallel-multiplication-hardware/56518#56518 Q1. In his answer about the question, how can I make a 16 LSB bits by the time I get to the input of the fifth tier. I think 1 bit bef...
In order to show that the next problem is NP-hard: Problem: Vertex Cover and Independent Set Input: Graph G and integer k Output: Does G have a vertex cover of k and an independent set of k? The sets does not have to be complementary (just about size k). I have tried to reduce Vertex Cover but I cannot find how to ensu...
The halting problem concerns programs which take input. By framing the halting problem on the diagonal argument it is clear why this is so. What about programs with no input, constant functions. Can it always be determined if they terminate?
Classic searching algorithms such as binary searching and dictionary searching search sorted arrays based on a given element and make estimations on their own. What I'm looking for is a list of more such algorithms to solve the generic problem- given a sorted array, find an element $x$ present in the array. I'd like to...
Suppose you are given a bit string $B[1 ... n]$. Now, suppose that some bits are just padding bits conveying no information, the rest of the bits may be permuted and some meaningful (that is, non-padding) bits should be inverted from $0$ to $1$ and vice versa. According to my intuition, the total number of interpretati...
In a text file you can write both the letter 'A' and number '65'. But obviously one of these data will be saved with different bits while the ASCII standard gives the letter 'A' the binary code for 65. Does a .txt file use some sort of container for different interpretations of binary? How does this work?
I'm looking for the name of the family of algorithms whose exact runtime is dependent only on the size of the input. An example of such an algorithm would be naive $O(n^3)$ matrix multiplication. If we know $n$, we know exactly how many operations it will execute and how many cycles it will take to complete (ignore rea...
I am sure this question has been asked, but I was unable to search for it in a manner that would give me the solution. So I will present it here. I seen this in another database years ago, and I want to implement it in one of my apps. It is perfect: Pets 1. fish 2. dog 4. cat 8. monkey 16. mice 32. snakes 64. rock If ...