instruction
stringlengths
35
29.1k
I try to find the solution to this problem: How do you find all integers in a sorted array of size n that appear n/k times in less than O(klogn) time? I could only find this question, where O(klogn) solution was provided.
A configuration of a Turing machine $M$ which runs in space $S(n)$ contains the state, the head positions, and the content of non-blank cells of all the tapes. For $M$ and an input $x$, we define its configuration graph $G_{M,x}$ as a directed graph whose nodes correspond to all the possible configurations and there is...
Suppose we have an interval of integers [a, b]. I would like to have a function that returns random members from within the interval, without repetitions. Once that all members within the interval are explored, the function would start to return the same first random sequence again, in the same order. Example: a=1, b=5...
We know that the number of permutations possible for $n$ unique items is $n!$. We can uniquely label each permutation with a number from $0$ to $(n!-1)$. Suppose if $n=4$, the possible permutations with their labels are, 0: 1234 1: 1243 2: 1324 3: 1342 4: 1432 5: 1423 6: 2134 7: 2143 8: 2314 9: 2341 10: 2431 ...
True or false: To show that a language L is not context-free, one can alternatively show that the union between L and a known context-free language is not context-free. I know that you can prove closure under context-free languages using union, but does the above work, too? Any help you can provide would be greatly app...
It's impossible for a problem to require exponential space without being exponential-time. Consider that if an $EXPSPACE~~complete$ problem can be solved in $2^n$ time. It will now fall into the class $EXPTIME$. Then $EXPSPACE~~complete$ problems are in $EXP$ if they can be solved in $2^n$ time. This means they can re...
Given any problem $P$ that we know of being in $NP-\text{complete}$, where is the flaw in the following proof? Given a problem $Co-P$ which is the co-problem of $P \in NP-\text{complete}$, $Co-P$ is at least in $NP$ because the following algorithm can always be given: Co-P(J): bool res = P(J) return !res Where...
I have heard many times that Group Theory is highly important in Computer Science, but does it have any use other than cryptography? I tend to believe that it does have many other usages, but cannot find out where and how to apply Group Theory to other areas in CS, such as algorithms, data structres, graphs, complexity...
I want to remove indirect left recursion from these rules: S-->TU, T-->US|b, U-->ST|a I don't know if I can implement the algorithm correctly. My assumption is to make it like this: S-->TU, T-->U'b, U'b-->U'a Is this correct?
Given a diagram of a room with obstacles in it (like walls or furniture), find the 4 best places to put omnidirectional light sources in it so the area that is lighted is maximized. Here is a simple example diagram so the problem can be better understood: The solution I thought was to find the spot with most light and...
I was making exercices about the Pumping Lemma for CFL, and I stumbled up on this language: $$ \{ 0^{i} 1^{j} 0^{k} 1^{l} \hspace{0.2cm}| \hspace{0.2cm} i = l \hspace{0.2cm} \land j = k \} $$ I quickly made a CFG that represents that language (or so I believe): $$ S \to 0S1 \hspace{0.2cm} | \hspace{0.2cm} A \\ A \t...
I have a core SMT solver problem consisting of 100,000 bit-vector array clauses, and one 10000-dimensional bit-vector array. Then, my program takes as input k << 100,000 new clauses, and adds them to the core SMT problem. My goal is, for any input of k clauses, to solve the entire problem. Is there any static optimiz...
We have $ M = (Q,Σ,Γ,δ,q_0,q_a,q_r) $ and $ M′= (Q′, Σ , Γ′, δ′,q_0′,q_a′,q_r′)$. We want to construct a standard Tm that recognize L(M) ∩ L(M′). How do I go about it? I don't have much more information than this. Anything to get started would be appreciated.
I have an array a of n entries. I need to place a token on the first and last position of that array, so a[0] = 1 and a[n-1] = 1. I now want to place additional tokens into that array with a distance inbetween each index i where a[i] = 1 that is greater than 2 (so placing a token on every index is invalid as well as al...
Suppose you have $n$ nonequal sets $S_1, \ldots, S_n$ and some constant $0 \le k < n$. The goal of set clustering is to find a partition of the set $\mathbf{S} = \{S_1, \ldots, S_n\}$ such that the sum of the total distance for each subset of $\mathbf{S}$ is minimized and such that $\mathrm{cardinality}(\mathbf{S}) = k...
After instruction has been fetched, does it go to control unit and register file at the same time or one after the other? For example if the control unit and register read both have 80ps delay, and we're calculating the total delay for a cycle, would we take their delay as 80ps(if they occur simultaneously) or if they ...
My task asks me to check whether there is a common element in two sets $\{x_1,x_2,...,x_n\}$, $\{y_1,y_2,...,y_n\}$ with $x_i,y_i\in\mathbb{N}$ using the Fast Fourier Transform (FFT). (I'm aware that there is a simple $O(n\log(n))$ algorithm to solve this problem using sorting and binary search.) The tasks hints that w...
I was reading a book which describes a historical perspective: Pentium 4E (2004, 125 M transistors). Added hyperthreading, a method to run two programs simultaneously on a single processor, as well as EM64T, Intel’s implementation of a 64-bit extension to IA32 developed by Advanced Micro Devices (AMD), which we refer ...
From the notes: It is not difficult to observe that the suffix array $\texttt{SA}$ of the text $\texttt{T}$ can be obtained from its suffix tree $\texttt{ST}$ by performing an in-order visit: each time a leaf is encountered, the suffix-index stored in this leaf is written into the suffix array $\texttt{SA}$; each time...
The present state Q2,Q1,Q0 of the counter before applying the clock pulse was (101). If the input Clock frequency to the circuit is 100KHz, then the output frequency of the circuit will be ? My Approach: I have built the state table and I concluded that from 101 it goes to 010 and from 010 to 101 again so it acts like...
Given the runtime of an algorithm to be m!/(n!*(m-n)!) That is mCn, where both m and n are variables, is the complexity factorial or polynomial? Or is it something else? Please elaborate. Thanks
Given an infinite decidable language $L$, then if $S \subset L$ such that $L \setminus S$ is finite, then $S$ must be decidable. This is true since given a decider of $L$ we contruct a decider for $S$: Simulate the decider of $L$ on the input, if it accepts, go over $L \setminus S$ and check if it is there, if it is, r...
Consider the following grammar: S → bAb | bBa A → aS | CB B → b | Bc C → c | cC I have to provide the reasons as to why this grammar is not LL(1). So far all I can think of is that the grammar is not left factored given the productions: S → bAb | bBa But I am also wondering if the grammar is left recursive ...
In finite precision floating point arithmetic the associative property of addition is not satisfied. This is, it is not always the case that $$(a+b)+c=a+(b+c)$$ Even $a=(a+b)-b$ is not always true. To prove that $x+y<z$ is equivalent to $x<z-y$ with real numbers we can add $-y$ on both sides of $x+y<z$ to get $(x+y)-y<...
I have a set $M$, subsets $L_1,...,L_m$ and natural numbers $k,l\leq m$. The problem is: Are there $l$ unique indices $1\leq i_1,...,i_l\leq m$, such that $\hspace{5cm}\left|\bigcap_{j=1}^{l} L_{i_{j}}\right| \leq k$ Now my question is whether this problem is $NP$-complete or not. What irritates me is the two constra...
Given an array $a$, we have to find product of $a_{j}$-$a_{i}$ modulo $998244353$ over all $i$ and $j$ given $j>i$. For eg. Let the array be $1,2,3$ then my answer will be calculated as- $(2-1)$.$(3-1)$.$(3-2)$=$2$ As number of elements in the array could be large (upto $10^5$) I am looking for solution of order $nlog...
I do not understand the last sentence of the proof provided. It says that the fact that xz does not belong to L contradicts the hypothesis, but isn't it that xyz not belonging to L what we are trying to prove?
Nowadays, most introduction books, videos, and comments about theoretical computer science talk about Turing machines but don't discuss recursion theory anymore. These approaches are known to be equivalent. What is the reason behind this? Has recursion theory simply gone out of fashion or is there a fundamental/mathema...
I've been thinking about grammatical evolution problems and how the grammar influences the algorithm performance. It came to my mind the huge impact that the grammar that you're using has in the time that takes an algorithm to reach an optimum solution. The simplest example would be if your problem doesn't involve trig...
I am trying to imagine a way of encoding a BigInt into a bit stream, so that it is literally just a sequence of bits. Then upon decoding this bit stream, you would generate the standard BigInt sort of data structure (array of small integers with a sign). How could you encode the BigInt as a sequence of bits, and how wo...
I have the following regular expression: Of course I could think of a word like $w=a^{m+2}b^{m+2}c^{2m+3}$ and continue with the proof BUT I was just wondering, because $L$ is made up of a union of two expressions, is it valid to split $L$ into $ L_1=\{a^ib^jc^{2j-1} | i<=j \land i,j>0\}$ $L_2=\{a^ib^jc^{2j-1}| i>=2j-...
I have a full bipartite graph with node sets $A=\{a_1,a_2,\ldots,a_n\}$ and $B=\{b_1,b_2,\ldots,b_n\}$. Each node has a weight, $v_i$ for $a_i$ and $w_i$ for $b_i$. Each node $a_i$ is connected to exactly one node of $B$, say $b_j$, via an edge $e_i$, whose weight is $\min(v_i,w_j)$. Now I want to find a one-to-one map...
What are good algorithms for finding connected components in a graph defined by a set of elements X, where each x in X is itself a set of features f and a Boolean connectivity function (defined by generalization/subsumption) c(x,x')? c(x,x') = True if generalizes(x,x') or generalizes(x',x) else False generalizes(x,x') ...
Let's we have k matrices. For example we have 3 now, where first one is 8x5 ($a_1$ x $b_1$), second one is 5 x 6 ($a_2$ x $b_2$) and last one is 6 x 8 ($a_3$ x $b_3$). And our goal is to figure out if possible to multiply within any given matrices and reach a matrix of dimension x and y, when x and y is given ahead o...
I built a matrix multiplication algorithm and now I need some thoughts about following benchmark. C++ chrono:: high resolution clock Time(micro second) (Dim)256--> (Naive algo ) 296807, (My algo) 187479 (Dim)512--> (Naive algo) 2249495, (My algo) 1359046 (Dim)1024-->(Naive algo) 27930970, (My algo) 12309645 FYI, I ha...
A few things to get out of the way first: I'm not asking what properties the function must have such that a global optimum exists, we assume that the objective function has a (possibly non-unique) global optimum which could be theoretically found by an exhaustive search of the candidate space. I'm also using "theoretic...
I read about the similarities between the python list and c++ vector and it looks as if the only difference is python list is heterogeneous. Are there any other differences? How are they both implemented?
So there's following problem, that has been bugging me for the last few days: A solution of a PCP $ i_{1},\dots,i_{n}$ with the cards $(x_{1} ,y_{1}),\dots,(x_{m}, y_{m})$ is considered as $k$-limited if for all $j\leq n$ we say that $|\; | x_{i_{1}}\dots x_{i_{j}}| - | y_{i_{1}}\dots y_{i_{j}}|\;| \leq k$. So after e...
Context: First of all, my data: I am working with 3D data shaped onto a structured grid made of hexahedrons with for each 8 vertices and 12 edges. The data I'm working on is cell data (and not point data). Every cell and every vertex possess unique IDs. For each cell I can list every other cell sharing a common vertex....
I'm trying to find what the family of problem is - as well as an approach - for the following: I have a set of tasks T = [t1, ..., tn] to do, each of which has a corresponding reward ri. Each task takes place during a fixed interval - ie: task 1 is from times 1-4, task 2 from 2-5, and task 3 from 9-15. This means that ...
I'm trying to analyze the space complexity of using the coloring function $f$ which appears in "Colorful Triangle Counting and a MapReduce Implementation", Pagh and Tsourakakis, 2011, https://arxiv.org/abs/1103.6073. As far as I understand, $f:[n] \rightarrow [N]$ is a hash function, that should be picked uniformly at...
I am working through Bridge's computablity book and I came across this problem that does not have an answer. I don't know how to precede, any help is much appreciated.
So, I have an exercise in which I have to write a context free grammar for this language: $$L = \{x \in L(a^∗b^∗c^∗) : |x|_a > |x|_c; |x|_b > 0; |x|_c ≥ 0\}$$ meaning every string with any number of $a$'s, $b$'s and $c$'s in that order, with the amount of $a$'s greater than the amount of $c$'s and the amount of $b$'s g...
The typical nearest neighbor search implementation for k-d trees prunes branches when the distance between the target and the pivot along the current axis exceeds the smallest distance found so far. This is correct (doesn't wrongly prune any points) for any Minkowski distance. Is there a broader class of well-known d...
Is it correct to say that the Clique Problem is in $P$ iff there exists a family of Boolean circuits $C$ to decide Clique whose sizes are bounded by a polynomial? And based on this question, does that imply that there exists an equivalent set of Boolean formulas $F$ to decide Clique whose sizes are bounded by a polynom...
As a message I get (5,0,1,3), which is coding a sequence of numbers of length 2 in $\mathbb{F}_7$ as polynom with the 4 support points a1 = 0, a2 = 1, a3 = 2, a4 = 6. In the transimission occured an error. Calculate the original message. How do I do this? In my script we didnt't talked about polynomial codes directly j...
I know that under the hood, for a Haskell program, the GHC compiler uses graph reduction for optimization. Is there any way to view this graphical representation of the program? I haven't been able to find an existing plugin that, given a Haskell program, produces its graphical representation. I am relatively new to Ha...
I was going through the text "Introduction to Algorithms" by Cormen et. al. where I came across a lemma in which I could not understand a vital step in the proof. Before going into the lemma I give a brief description of the possible prerequisites for the lemma. Let $M=(S,\ell)$ be a weighted matroid where $S$ is the ...
Lets say that we have the language L = { $a^n$$b^m$$c^{m+n}$ $|$ $m$,$n$ $>=0$ } What is the way that i should follow to prove that the language is not regular? Assume that the language is regular. So,there is a string $w\in L$ such that $w = xyz$ , $|xy|\leq n, y\neqε $, n is the pumping length Lets say that the...
I was solving a question on LeetCode, where I had to generate all possible subsets of a given set of numbers. Although, the solution makes sense to me, I am unable to understand the derivation of time complexity for those solutions. A solution I found there was: class Solution { public: vector<vector<int>> subsets(...
I’m trying to design a DFA which accept string starting with 101 if the string start with 0 then it goes to dead state.Is my design is correct or wrong? And I don’t know how to draw transition table if the DFA has dead state.
It works I checked it but I don't know how to make it smaller :( the question is in my book,I can solve but it took too much time and effort and I'm pretty sure there's a simple soloution.
Show that the following problem is solvable.Given two programs with their inputs and the knowledge that exactly one of them halts, determine which halts. lets P be program that determine one of the program will be halted. P(Program x,Program y){ if(x will be halted) then return 1; else ...
As said in the title, i am quite curious wether NSPACE(2^(O(n)) equals NSPACE(n^2 * 2^(O(n)) I am aware of the fact, that NSPACE(k * 2^O(n)) equals NSPACE(2^O(n)) due to linear space reduction (i.e. some sort of super character representing k characters) But since neighter n nor n^2 is linear, we cant use this here. Th...
It's possible to return from a dpll algorithm M as maximum for MAX-SAT problem?: I have a sample: https://gist.github.com/davefernig/e670bda722d558817f2ba0e90ebce66f we can modify recurrency to return the outcome of MAX-SAT? Resources: https://en.wikipedia.org/wiki/DPLL_algorithm
I have a problem in which I am interested in taking a matrix of positive integer weights, including zero, where the matrix has dimensions nrow x ncol and the columns always sum to the same arbitrary number. I want to search for a list of paths (sets of edges essentially) that traverse through the grid space of the same...
Given the diagonal language $$L_d = \{ i : \sigma_i \notin L(M_i) \}$$ Where $M_i$ are all Turing Machines and $\sigma_i$ are all the words, if you put in in a Matrix like this: $$\begin{array} {|c|c|c|c|c|c|c|} \hline & \sigma_1 & \sigma_2 & \sigma_3 & \sigma_4 & \sigma_5 & ...\\ \hline M_1 & 1 & 0 & 1 & \dotsb & \dot...
Most non-convex optimization algorithms I have come across so far rely basically on random restart to find a better solution. e.g. Genetic Algorithm, Simulated Annealing, Metropolis Hastings Monte Carlo. Even in Stochastic Gradient Descent we can think of training each batch as a random perturbation. There are some non...
Suppose I have two sets $A$ and $B$ containing integers. Let $B'$ be the power set of $B$. Then suppose I have an algorithm that enumerates all possible pairings of elements in $A$ and $B'$ to apply a function $f$ to them and check something. I understand that generating a power set is $O(2^n)$, but what complexity cla...
You are given a polynomial of degree n. We have to find the value of the polynomial at n different points in O(n(log(n))^2). The answer should be modulo 998244353. I have read various blogs on it and a research paper but none could help me implement it. If anyone could provide some insight it would be really helpful.
I am trying my best to understand the sweep-line algorithm to find line intersections. I have understood most of the intuition except how it is calculating the intersection between 2 line segments using cross product. I am providing the code for that below, please ask me any doubts related to the code, so that I can ex...
Here is an excerpt from Andrew S. Tanenbaum, Computer Networks, 5th edition, Chapter 5 (The Network layer), Page 455: [Fifth, processes on the Internet are not required to use TCP or UDP. If a user on machine A decides to use some new transport protocol to talk to a user on machine B (for example, for a multimedia appl...
I have an interesting function. It takes subsets of {1,...,N} to positive integers, i.e. $f:P([N]) \rightarrow Z^+$. I know that if S is a subset of S', $f(S) < f(S')$. Also, if S and S' have the same cardinality, the ordering induced by f is lexicographic, so for example $f(\{1,2,4\}) < f(\{1,3,4\})$. Given a value ...
I am facing the following problem: Given an undirected complete Euclidean weighted graph $G(V, E)$ and its MST $T$. I need to remove an arbitrary vertex $v_i \in V(G)$, and given a vertex $v_j \notin V(G)$, I have to calculate the MST of $$G^{'}((V(G) \backslash \{v_i\})\cup\{v_j\}, (E\backslash\{(v_i, v_k): v_k \in V(...
From these notes pages 37-38. In HOL, I'm giving the task of proving: $\vdash \forall x^T. \forall y^T. (=_T x^T y^T) \implies (=_T y^T x^T)$ applying forall and implication introduction and the definition of $=_T$ I get: $(\forall_{T \to O} \lambda P'^{T \to O}. P' x^T \implies P' y^T), P y^T \vdash P x^T$ Here I set ...
I'm looking for some clarifications on an algorithmic task I've been trying to solve. This task is a part of Quiz 2 from the MIT 6.006 course. The main idea of creating k-copies of a graph G is clear. What I'm really confused with is the final graph G': Can you explain how the graph G' will look like? How will the G' ...
In Chapter 4 in Computational Complexity by Arora and Barak it states, regarding the configuration graph of a Turing Machine, that If M is deterministic, then the graph has out-degree one, and if M is nondeterministic, then the graph has out-degree at most two. In the configuration graph, a directed edge is placed fr...
Given an universum $U$ and two sets $A$ and $B$ of sets of elements from $U$. I want to find (if such a pair exists) $a \in A$ and $b \in B$: $a \cap b \equiv \emptyset$. Currently I can do it only in $O(|A| \cdot |B| \cdot |U|)$, is there way to improve this? Say, $|U| \leq 32$. Is there a way to speed algorithm up? I...
Lets say we are trying to solve some algorithmic problem $A$ that is dependent on input of size $n$. We say algorithm $B$ that runs in time $T(n)$, is asymptotically better than algorithm $C$ which runs in time $G(n)$ if we have: $G(n) = O(T(n))$, but $T(n)$ is not $O(G(n))$. My question is related to the asymptotic ru...
I understand why NP=coNP if SAT is in coNP (How do I prove that SAT in coNP implies NP=coNP?). But I'm missing why the following machine doesn't turing recognize the complementary of SAT: Given a turing machine M that recognizes SAT, the following turing machine recognizes coSAT: Run M on the input word w. If M accept...
I am looking for information on problems of the following kind. There is a function $f: [0,1] \to \mathbb{R}$ that is continuous and monotonically-increasing, with $f(0)<0$ and $f(1)>0$. You have to find the unique $x\in[0,1]$ such that $f(x)=0$. You can access $f$ only through queries of the type "what is $f(x)$?". B...
Well, suppose then we have an CPU system such as: Thread(s) per core $\equiv t$ : 4 Core(s) per socket $\equiv c$: 4 Socket(s) $\equiv s$: 1 Then, we must to perform a simple calculation such as: $ 4 \cdot 4 \cdot 1 = 16 $ Therefore, in general we have: $$ T = t\cdot c \cdot s \tag{1}$$ I guess that...
For range queries on a subarray [L,R] , I want to find all the indices of successive maximums from left to right within O(log(R-L+1)), excluding index "L". I know using segment trees I can find the single maximum in given time limit. Example if [L,R] is 20 3 10 5 10 7 6 7 5 7 5 -> the bold ones are the answers Note th...
DNS Spoofing and DNS Hijacking, both of them basically are type of attacks where the request is redirected to some other malicious website or some other web page. But I did not find some concrete difference between them, Can someone please explain the primary difference between DNS Spoofing and DNS Hijacking..
Is it true that if $L^*$ is recursive, where $*$ is Kleene star, $L$ is also recursive? I know that the opposite direction is true: If $L$ is recursive, then $L^*$ is recursive. But I don't know how to prove it in this direction.
I have a graph with a set of vertices $\mathcal{V}$ and a set of edges $\mathcal{E}$. There exists a path between every 2 vertices in the graph. To each edge there is an associated weight $w(e), e \in \mathcal{E}$. I define a (global) threshold $T$ such that if $w((u,v)) < T$ the two vertices $u,v \in \mathcal{V}$ are ...
The worst case time complexity of a given algorithm is $\theta(n^3logn)$. Is it possible that the worst time complexity is $\Omega(n^2)$? Is it possible that the worst time complexity is $O(n^4)$? The average time complexity is $O(n^4)$? IMO it is possible as long as you control the constant $c$, but then what's the po...
Here is an excerpt from Andrew S. Tanenbaum, Computer Networks, 5th edition, Chapter 5 (The Network layer), page 448: When aggregation is turned on, it is an automatic process. It depends on which prefixes are located where in the Internet not on the actions of an administrator assigning addresses to networks. Aggrega...
I'm working on a compiler for my own custom language. As I was reading an article on code optimization, I noticed that it assumed that the intermediate representation of the code had already been formed. Though I haven't yet started writing the optimization section of my compiler, I've been going through it in my hea...
I have an undirected weighted graph without multi edges. All the edge weights are whole numbers and known. I want to know in how many ways node values(node values are also whole numbers) can be assigned to the nodes such that the graph satisfies the condition that for every edge its edge weight is exactly equal to maxi...
If X is polynomial reduction to Y and Y is in NP, then X is in NP? Is this true, false or "we don't know"? Why?
In a game I am developing I came across an interesting problem, that seems like it could be solved using some modified variant of the knapsack problem, but it's a bit over my head. Let $x_i$, $ 1\leq i \leq n$ be the objects we are dealing with, and $p_i$, $ 1\leq i \leq n$ the cost associated with each item. Suppose t...
I'm sorry if the question is not relevant, i have tried to search for articles about it but i couldn't find satisfying answers. I'm starting to learn about machine learning, neural networks etc ... and i was wondering if making a neural network that takes a graph as input, and output the answer of an np-complete proble...
If X is in NP then $\overline{X}$ is in NP. True, false or "we don't know"? Why?
The following comes from section Dynamic Tables, Introduction to Algorithms by Cormen. et. al. In the following pseudocode, we assume that $T$ is an object representing the table. The field $table[T]$ contains a pointer to the block of storage representing the table. The field $num[T]$ contains the number of items in ...
I'm working on a system that will require manual data entry of 10-digit numbers (Σ = 0123456789). To help prevent data errors, I want to avoid generating any two strings that have a hamming distance of 1. For example, if I generate the string 0123456789 then I never want to generate any of these strings: {1123456789, 2...
Is it possible, according to the current state of knowledge, that orthogonal matrices can be multiplied faster than arbitrary matrices? More precisely, let $T(N)$ denote the worst-case time of the fastest algorithm to multiply two arbitrary $N\times N$ matrices (in the real RAM model). Let $T_{\rm O}(N)$ denotes the wo...
I was studying Union Find, and according to Wikipedia, there are 2 types of union: union by rank and Union by size. My question is, what is the runtime difference between the two (if any)? Intuitively, it feels like Union by size would always be better, since each time we merge, we are increasing the rank of every node...
In what applications would you choose an edge list over an adjacency list or an adjacency matrix? Sample Question, VisuAlgo: Which best graph DS(es) should you use to store a simple undirected graph with 200 vertices, 19900 edges, and the edges need to be sorted? Suppose your computer only has enough memory to store 4...
I am looking for the optimum algorithm for the following: 10-15 players Each player has between 20 and 40 cards. Each card can have one of up to 200 possible characters, and a separate numerical rating (higher is better). Card's characters may duplicate between players, or in players hands. Ratings are highly unlikely...
I have a question from one of the exercises in CLRS. Show that there is no comparison sort whose running time is linear for at least half of the $n!$ inputs of length $n$. What about a fraction of $1/n$ of the inputs of length $n$? What about a fraction $1/2^n$? I have arrived at the step where for a linear time sort...
I'm searching for an algorithm but struggle to find anything, as I'm not sure how to formulate it correctly. I created a simple survey app in Angular with 24 questions and each has 2-5 answers. When the user answered all the questions I'd like to give him a token (as short as possible) on the result page that he can no...
I have given the following SAT variation: Given a formula F in CNF where each clause C has exactly 3 distinct literals and for each C in F either all literals are positive or all literals are negated. Example: $F= (x_1\vee x_2 \vee x_4) \wedge (\neg x_2\vee \neg x_3 \vee \neg x_4) \wedge (x_3\vee x_4 \vee x_5)$ Is...
Given the two equivalent terms $A \vee B$ and $B \vee A$, Gödel numbering returns two various codes $2^{4}.3^{\overline{A}+1}.5^{\overline{B}+1}$ and $2^{4}.3^{\overline{B}+1}.5^{\overline{A}+1}$, respectively. These two codes do not generally equal to each other, which is an unfortunate if one would like to observe th...
An applied problem I am working on could be modeled as the following problem on graphs: Given an undirected graph $G=(V,E)$ and an integer $k>0$, find the largest set $S\subset V^k$ such that for each $A\in S$ the induced subgraph $G[A]$ is connected and such that no two $A_1, A_2\in S$ are adjacent in $G$. For $k=1$...
I read somewhere that the problem which asks whether or not a CFG $G$ generates $1^*$ is decidable. The proof goes like this: $1^* \cap L(G)$ is context free since it is the intersection of a regular language and a CFL, therefore we can test if $1^* \cap L(G)$ is empty since it is decidable to check if the language pr...
Suppose you need a c compiler. It would be preferable to write that compiler in a c-like language, given the complexity of a compiler of that degree. At best, the c compiler would be written in c, but that would require a c compiler to begin with. If a mistake is made in the making of one of the early iterations of com...
Prove: If $T'=(V,F')$ is a spanning tree, but not a MST of $G=(V,E)$, then there are edges $e' \in F'$ and $e \in $ $E$ \ $F'$ such that $w(e)<w(e')$ and $T'$ \ $\{e'\} \cup \{e\}$ is a spanning tree. My idea: Let $T=(V,F)$ be a MST of $G$ for all $e \in T$, try to insert it into $T'$ and see if there is an edge in the...
A Fibonacci heap is a data structure for priority queue / heap operations. It seems to have the best complexity for all operations: Since it has the best performance, why not use it everywhere? What are the disadvantages of it?
What is the difference between $\text{SIZE}(n^k)$ and $\text{P}/\text{poly}$? For reference: $\text{SIZE}(n^k)$ is defined as the class of problems solvable with Boolean circuits (of fan-in two) with $O(n^k)$ gates. $\text{P}/\text{poly}$ is defined as those problems over $\{0,1\}^*$ which can be solved by an infinit...