instruction
stringlengths
35
11.4k
What does $\#P$ closure under addition and multiplication mean? Does it mean given $NTM$s $N_1$ and $N_2$ we can create in deterministic polynomial time an $NTM$ $N_\times$ and $N_+$ such that for every input $x$ we have $$\#N_\times(x)=\#N_1(x)\#N_2(x)$$ $$\#N_+(x)=\#N_1(x)+\#N_2(x)$$ accepting paths?
Suppose I have an array of numbers, and a function boolean isPrime(int n) that I'm allowed to use. Boolean isPrime(int n) receives a number n and return true if the received number is a prime and false otherwise. I need to write a function int foo(int[] a) that receives the given array and return the biggest prime numb...
Apologies for this simple question. I found it in the book Algorithms by Sedgewick and Wayne. Give a formula to predict the running time of a program for a problem of size N when doubling experiments have shown that the doubling factor is $2^b$ and the running time for problems of size N0 is T. $$ \frac{T(2N)}{T(N)}=2^...
Complexity zoo states that $MOD_{2^k}P=MOD_2P$. It is clear that if $MOD_2P$ accepts (number of accepting paths is off) then $MOD_{2^k}P$ accepts. Why is it clear that if $MOD_2P$ rejects (number of accepting paths is even ) then $MOD_{2^k}P$ rejects? Does $MOD_{2^k}P=MOD_2P$ have a different interpretation? I mean som...
Consider receiving as input $x\in\mathbb N$ and computing some (any) prime $p\in[x,2x]$. What is the complexity of the above problem? A natural way to approach this problem is to generate random integers in $x,\ldots,2x$ and check for their primality using Miller-Rabin or a deterministic algorithm such as AKS. Howev...
What is the maximum number of edges that a simple directed graph on $n$ vertices can have, if the graph has the following restriction. Size of Intersection of Neighbourhood of any pair of vertices is at most $k$? Neighbourhood is defined as follows. If a vertex $v$ has directed edges towards exactly three vertices $a$,...
I've recently finished a course on languages in computer science, so we covered characteristics of regular, context-free, decidable and semi-decidable languages. While that is all well and good, we never went into any detail on what applications of this knowledge are (other than compilers being context-free language re...
I have got assignment to implement set class with linked list, so I first made it with unordered list and time needed to insert million integers is bit less than hour. Then I thought I can get it to work faster by making list ordered (since in average it should take less time to check is element already in set) but it...
I am looking at the following github. In this, layer3 has a shape of (1, 20, 72, 256) and I interpret this is as a single layer having 20 input nodes and mapping to 72 output nodes and there are $256$ filters, so the depth is $256$. Then, after applying a 1x1 convolution to this, the new shape becomes (1, 20, 72, 2). I...
I am self-studying the book Intro to Algorithms 3ed by CLRS. One of the problems seems to give a piece of information that is not necessary, Problem 11-4 in the book states Let H be class of hash functions in which each hash function h ∈ H maps the universe U of keys to {0, 1...m-1}. We say H is k-universal if, for ev...
I have a black-box function optimization problem: $$\arg\max_{\vec{x}} \; f(\vec{x}, \vec{y}) \\\text{subject to } \vec{x} \in \mathbb{Z}_2^N, \|\vec{x}\|_1=K, K<N, \vec{y} \in \mathbb{Z}_2^M$$ The function $f(\cdot)$ is a black-box function whose output I can only simulate: I cannot access its exact form. The variabl...
A sequence of English letters are given, every sequence forms a word and we know that the size of each word is at most $15$ and the number of words is at most $50000$. For a given input word $w$ I need to search if the $w$ exists in the database of words. The framework of the database and the application is on the web...
I came across following problem: Let $L_1$ and $L_2$ are two languages and both of them are accepted by DPDA. If $L=L_1-L_2$ is any language, then what is the smallest language family $L'$ belongs to? I know DCFLs are not closed under set difference operation. Neither do CFL are closed. However CSLs are closed under ...
Suppose for different classes $A,B,C$ we have that $A\subseteq P^B$ and $A\subseteq P^C$. We have $A\subseteq P^{B}\cap P^{C}$. Does it also mean $A\subseteq P^{B\cap C}$? Supposing $A\subseteq P^{B\cap C}$ also holds does it also give $A\subseteq {B\cap C}$? If $P^B=B$ then does it mean $A\subseteq {B\cap C}$ or $A\s...
I'm trying to find a good solution to the following problem: Given a set of 3d real number coordinates inside a cube, I want to group them into containers. The containers should contain all elements that are in predefined distance to at least one of the other elements. Should two elements be closer than a predefined di...
I'm trying to find the maximum number of different substrings of string consisting only of lowercase letters 'a' - 'z', if the length of string can be up to $5000$ Firstly, I was thinking that the number of substrings is $\frac{n\cdot(n-1)}{2}$ but then I noticed that a lot of the substrings will be the same, and also ...
Is there any difference between structural-recursion and Tail-recursion or they both are same? I see that in both of these recursions , the recursive function is called on the subset of the orignal items.
I'm familiar with reductions to the language $A_{\mathrm{TM}}=\{\langle M,w\rangle | M \text{ accepts } w \}$, for example $A_{\mathrm{TM}}\le H_{\mathrm{TM}}$. Are there examples for reductions from $A_{\mathrm{TM}}$. By that I mean, a reduction such as: $B\le A_{\mathrm{TM}}$ (many to one reduction).
The 7th chapter (7.3 section) of "Automata Logics and Infinite Games" by Erich Gradel, Wolfgang Thomas, Thomas Wilke gives a way to convert max parity game to mean payoff game. I do not understand how to use the solution for mean payoff game i.e $\nu(v)$ to compute the winning region of parity game. It states "It is o...
Why do we need binary trees when we have multiway trees. Are binary trees even used. Are they used only for teaching the concepts of trees?
The Master Theorem provides a method of solving recurrence relations for divide-and-conquer algorithms. It was first presented to me in my intro algorithms class as the following: For a recurrence of the form $T(n) = aT(\frac{n}{b})+f(n)$ with constants $a \ge 1$ and $b>1$, Case 1: if $f(n) = O(n^{\log_b(a-\vareps...
We will consider a set whose elements I call "precedences". Precedences are related by two relations: "is subclass of" and "higher than", which are specified by some pairs (given on algorithm input) of precedences conforming to these relations and by the below rules. All sets in consideration are finite. Let "is subcla...
Take: An algorithm $A$ that is analytically nice in some way, say, for some class of inputs of length $n$ it runs at $O(f(n))$ on some Turing machine. $k+2$ independent, identical such machines. Is there a generic method to produce algorithms $A_{in}, A_{out}, A_{1},\dots, A_k$ for which tapes can be made so that: ...
I have just played a few games of Rummikub and the manipulations I made during my turns became more and more complex transactions. A few turns reordered the whole field, so that other players did not recognize anything and had to plan their turns again. As always, I thought about representing this in a computer program...
This question arose out of a concrete problem I had, which was to find an $\varepsilon$-free variant of the following LL(1) grammar $G_0$ that I developed for a Lisp-like language $L$ (I found a monotone LR(0) variant): $$ \begin{array} \\ P & \rightarrow & (EP \\ & | & \varepsilon \\ E & \rightarrow &iE \\ & | &sE...
I learned that algorithms written in programming languages always return some value, not necessarily an input value. But, if the return type of the main function is void, then does the algorithm return any value?
I have an arr[] of M integers. He has to find all integers K such that : 1) K > 1 2) arr[1]%K = arr[2]%K = arr[3]%K = ... = arr[M]%K where '%' is a modulus operator with following constraints : - 2<= M <=100 - 1< value of each integer <109 - All integers will be distinct I have written an algorithm and program for thi...
Definition : Kolmogorov complexity is a static complexity measure that captures the difficulty of describing a string. For example, the string consisting of three million zeroes can be described with fewer than three million symbols (as in this sentence) From wikipedia In algorithmic information theory (a subfield of ...
For Christmas my brother got me this puzzle: The premise is that you have a metal medallion with a series of holes in it and a metal ring with a slit just large enough to slide it from hole to hole, barring obstacles, like the edge of the map and an obstruction near the top. The goal is to be able to remove the ring f...
Can someone explain with a hands on example how the Gelfond Lifschitz reduct works in order to check stable model semantics? edit a simple example here - at least as far as I understand the thing. So far grounding is clear to me - but the the application of the reduct is not. My goal in the end is to check stable model...
I need to find the minimal path cost from left edge of a $n\times n$ grid to the right edge where each node has some non-negative weight $cost(i,j)$. $i$ represents horizontal coordinates while $j$ represents vertical coordinates. Only the following movements are allowed in the grid: $$ (i,j)\to(i+1, j-1) \quad\text...
Suppose that $p>0$ and $n>0$ is a natural number. How do I prove that $$ \sum_{k=1}^n k^p = 1^p + 2^p + \dots +n^p \sim \frac{1}{p+1}n^{p+1}=\Theta(n^{p+1})$$ for $n \rightarrow \infty$?
Doing exam papers now and I came across two questions which I cannot get my head around sadly. Both are regarding Amdahl's law and Parallel Computing but they seem rather simple and frustratingly enough I cannot really find a definitive answer to any of those questions. The questions are: Why must Amdahl's law always ...
start off stating the definition of a loop invariant. It is a condition that must be true at the start of the loop and must be true after each iteration of the loop. I understand what it is but i have trouble trying to come up with one. Here below is a program which i know is correct and I have stated the loop invarian...
I'm trying to prove a problem that a friend sent me, he is saying that my solution is not good and I wanted to ask if he is correct and im wrong , and if so why? here is the questions: $L=\{<M>| \text{ M accept all languages with no more then 1 palindrome}\}$ prove that L is not decidable by showing that : $H_{TM} \leq...
Let there be a set of cardinality $n\in \mathbb{N}$. Let there also be $n$ subsets of that set. What is the smallest k such that union of some $n-k$ of those subsets is of cardinality at most $k$? The problem is very similar to minimal $k$ union problem, but is more specific, how can I prove it is NP-complete?
Suppose we are given a digraph A. We need to calculate its connectivity digraph B. I conceived two algorithms: 1. Set X = A. Loop Set Y = X*A united with identity Stop the loop if Y = X Set X = Y End loop B = X 2. Set X = A. [Or instead "X = A united with identity" and remove "united with identity" in the third step...
Introduction Hello, I'm designing a generalized model of Turing machines for a formalization in MIZAR. Mizar needs some concrete objects to work with, so I spent some time figuring out how the "tape" of a Turing machine could be defined since that part is usually left out when introducing Turing machines. After some th...
Is it possible in theory to build hardware with exactly same computing logic as any computer program? Or in other words: Is it possible in theory to implement any software in hardware? That's my thoughts: if computers in general is finite automata so the software what is a product of computer is in general finite autom...
I'm trying to understand TCP right now. In the header there is "Window Size" which to my understand is the maximum amount of data that can be sent at once. My question: How does the server know how much data it can send? If I understand it correctly, the only information the server gets from the client is the ACK numbe...
Some computational problems have different complexity on different graph classes. For instance, 3-edge coloring is NP-complete on cubic graphs but polynomial on cubic bipartite graphs. What are the graph problems that have different complexities on directed and mixed graphs. A mixed graph can have both directed and u...
I have an algorithm broken down into the pseudish code below. But the gist of it is, we go through every person in a list, we then ask them to talk to all of their friends. Every time we choose a person to eval in the list, it costs $log N$ time. Every time that person talks to a friend it costs $log N$. What is the ti...
for i = 0 ... log(n) - 1 for j = 2^i + 1 ... 2^(i + 1) [code with Big-Theta(1) running time] Given this piece of code the outer loop runs log(n) times. But I'm confused as to how to try to calculate the running time of the second loop so as to multiply them. Thank you for reading.
The following formulas are said to be defined in WS1S logic. $Closed(Z, R) := ∀x ∀y(x ∈ Z ∧ R(x, y) → y ∈ Z)$ $(z_1, z_2) ∈ R^∗ := ∀Z.(z_1 ∈ Z ∧ Closed(Z, R) → z_2 ∈ Z)$ However since WS1S formula requires bounded second order variables to be finite, I am not sure if the second formula is valid. $Z$ which is bounded he...
I am familiar with mathematical (gradient-based) optimisation methods, some heuristic methods like GAs or linear programming methods like simplex algorithm. I am not too familiar with graphs / trees and their search. But it does seem like all possible solutions can be represented as a graph and a graph search algorith...
Given two languages $L_1$ and $L_2$, is there a known way to show that $L_1\not\leq_T L_2$? In other words, is it possible proving that there is no Turing reduction from $L_1$ to $L_2$?
I'm not sure what the following algorithm does but it seems that it calculates the shortest paths from a node $t$. Initially we're given a graph $G=(V,E)$ with non-negative weights $c(e) \ge0$ for each edge $e\in E$ and we're given a node $t\in V$. The algorithm is as follows: Initialize array $A$ such that $A[v] = 0...
This question was asked in peter linz exercise. I have tried languages such as $\phi,\epsilon,\Sigma^*$.
How to proof UNIQUE-SAT is in $\Delta^p_2$ or in $P^{sat}$ 1) when given a bool formula can I ask oracle whether the given formula has at least one satisfying truth assignment and whether it has at least two? 2) Is UNIQUE-SAT in NP?
My problem is as follows. I am working on an experiment where I need to align a 3D vector with spherical coordinates $\vec{v} = (r, \phi, \theta)$ (red) to an infinite 1D line (blue). That line lies, at some unknown angle $\xi$, in an infinite 2D plane, with unknown vector span (green). To do this alignment, I can in...
Till now I have believed that a LL language is a language generated by a LL grammar. Same goes for LR. Now I know some of the hierarchies such as $LL(1)\subset LR(1)$. I used to think that the hierarchy is valid for language as well as grammar i,e if a grammar is LL1 then it must be LR(1); If a language is LL(1) then i...
From Database Management Systems, by Raghu Ramakrishnan, ‎Johannes Gehrk Let R be a relation schema, F be the set of functional dependencies (FDs) given to hold over R , X be a subset of the attributes of R, and A be an attribute of R. R is in third normal form if, for every FD X -> A in F, one of...
For general linear programming (LP), i.e. optimization of a linear objective over a general polyhedron, to the best of my knowledge/recollection one can use the simplex algorithm (or hypothetically, although it's not done often in practice, the ellipsoid algorithm). Matroids are well known for the property that the gre...
It is quite straightforward to understand $\#P$ closure under addition and multiplication since there are canonical $NTM$ constructions. Is there illustrative non-trivial example to understand $NTM$ construction for closure under binomial coefficients?
Currently we are discussing applying Johnson's algorithm on undirected graph with negative edge weights. And the graph may contains cycles, but the sum of weights of any cycle is guaranteed to be non-negative. If we consider the undirected graph as bi-directed, then any negative-weight undirected edge will create a ne...
Consider a finite set of colors and a given an unweighted graph with the following properties: 1) Graph is connected. 2) All vertices of the graph has a color in the given set of colors. 3) No two adjacent vertices have the same color. Define a flip as the following: change the color of a given vertex V AND all reachab...
Why not to some constant like 3 or 4 dimension? I suspect that it is because Cholesky Decompostion will work only for $n \times n$ matrix $B$ where $B^TB = P$ where $P$ is a semidefinite matrix. Is it true? Or there is something else?
I have this initial function \begin{split}(\overline{A}+\overline{B})(\overline{D}+\overline{C})+AB\overline{(\overline{C}+\overline{D})}\end{split} Which i reduced to \begin{split}{\overline{AB}*\overline{CD}}+ABCD \end{split} The first part is easy to do with NAND but the OR ABCD part i have no ideia how to do...I su...
Hi I'm doing some exercices on reductions and one of them is like this: My problem rather than doing the reduction is understanding it. For the positive case I want that if Mx(x) never stops then p's domain has to be strictly included in q's domain which has to be stricly included in p's range. Am I wrong? Therefore ...
I am new in Computer Vision. Suppose you have 8 points (players in a basketball court) in a 2D image (png photo), that is we know the pixel coordinates of each. I would like to compute camera position w.r.t. the field. We have the actual dimensions of the field. Also, I can write the equations of two or three transvers...
Does anyone know of an algorithm who is able to return how similar a DFS Tree is from another DFS Tree? (Or any kind of tree in general) I'm not looking for a true or false. Instead, I would like it to return something in the form of "DFS A is ~87% similar to DFS B" Thanks!
For any integer $k$, does there exist a decision problem in $\textbf P$ that can be proven to require $\Omega(n^k)$ steps?
I want to solve the following problem: You have a list of numbers, for example [10, 33, 7, 7, 12]. The goal is to find the permutation of this list that maximizes the function $\sum_i a_{i-1} a_i a_{i+1}$, where indices are cyclic (taken modulo the number of elements). My initial thought was to simply sort the list b...
I need to come up with an algorithm that iterates through an array and if any element appears m times, then the array needs to be modified so that it only appears min(2, m) times. For example, if A = [2, 2, 2, 3, 4, 4, 5, 5, 5] and m = 3, A = [2, 2, 3, 4, 4, 5, 5]. It is easy to do with extra space or nonlinear time bu...
I understand how to calculate the probability of a hash collision. I am designing a DB and have a potential case where a record could have the inherited hash of its parent plus its own hash, meaning I could potentially query two hashes to determine probable record matches. If I have 1 billion records, a 64-bit hash wil...
Consider the problem of designing a data structure that provides the interface functions $\rm{pop}, \rm{push}, \rm{findmin}$, all running in constant time. This problem may be solved by (e.g.) having the $\rm{push}$ method compute the new minimum as well, and place it on the stack together with the pushed element. Is ...
I want to calculate the time complexity of the listed algorithms, please correct if I'm doing something wrong: The question is, do some operations like multiplying, dividing, or plus really affect on time complexity ? // Time complexity is O(log n) void calculate(n: Int) { while (k < n) { k *= ...
I'm trying to explain the basics of Bitcoin to my parents. One of the core components of bitcoin, is signing transactions to make sure your identity can't be impersonated, and thus the need to explain a simplified asymmetric cipher. What's an extremely simple asymmetric cipher I can use as an example? How can this simp...
I want to construct a FA for the language $\{w \in \{a,b\} | $length of w is either even or divisible by 3$\}$. I've been playing around with some FAs, but I can't seem to create one that does the job. I can easily create one that accepts words with even length, and also one that accepts words with lengths divisible by...
One thing I understand is that the complement of every Turing recognizable(but not decidable) language is non Turing recognizable. What about the complement of non Turing recognizable language? Is the complement of every non r.e a recognizable language. I don't know how to approach this problem. But one idea I had was...
I have a DAG and I wish to find the minimal set of vertices that have a path to all other vertices. My solution was to simply find all the vertices that their incoming degree is 0. However, if there are two vertices in the DAG that have an indegree of 0 and that point to a common vertex then one of the two vertices is ...
Options are: Signed magnitude One's complement Two's complement Excess notation This is the question from an 'example of a previous exam' I've been given at university. Answers were not provided. As far as I understand only one answer must be chosen, but I'm not seeing which one. My attempt at solution As we see fro...
Implemented is done in C++. Supposing we have defined a class T with no restrictions and three functions cond, next and f returning bool, void and anything respectively, are for(T k = T(); cond(); next()) f(); and { T k = T(); while(cond()) { f(); next(); } } So, I would like know that time complexity of...
Exactly $1$-in-$3$ SAT ($X_3SAT$) is a variant of the Boolean satisfiability problem. Given a set of clauses, each clause having three literals, is there a set of literals such that each clause contains exactly one literal from this set? $X_3SAT$ is known to be $NP$-complete. It remains $NP$-Complete even when it is mo...
If $f(n)=\Omega(g(n))$ and $h(n)=\theta (g(n))$ then does this implies $f(n).g(n)=\Omega(g(n).h(n))$ I saw a proof where they have proved If $f(n)=O(g(n))$ and $h(n)=\theta (g(n))$ then this implies $f(n).g(n)=O(g(n).h(n))$. So I thought may this should also hold. I have taken some examples and the formula holds on a...
If I understand it correctly, an algorithm that computes the value of a real function $f$ has computational complexity $O(g(n))$ if the following holds: When we compute $f$ to precision $\delta$ requires on the order of $g(n)$ steps. However, what if we have an algorithm that first "finds a more efficient algorithm to...
INOI 2017, Problem 2, Training Ash and his Pokemon Pikachu are going on a journey. Ash has planned his route for the journey so that it passes through N cities, numbered 1, 2, …, N, and in this order. When they set out, Pikachu has an initial strength of Sin as well as an experience value (XV) of 0. As they travel th...
How do you define $\oplus P\cap PP$? $L\in\oplus P$ iff $\exists\mbox{ NTM }M:\forall x,\#acc_M(x)\mod2\equiv0$. $L\in PP$ iff $\exists\mbox{ NTM }M:\forall x,\#acc_M(x)>\#rej_M(x)$. Consider the classes $C_1,C_2,C_3$. $L\in C_1$ iff $\exists\mbox{ NTM }M:\forall x\#acc_M(x)>\#rej_M(x)\mbox{ and }\#acc_M(x)\mod2\equ...
Consider language $L = \{<M> |L(M) \subseteq L(0(0\cup1)^*) \}$ where $<M>$ is a valid encoding of a turing machine. I know that the language is applicable for Rice Theorem. Now, I understand that in this case the language group in $RE$ is: $C = \{L\subseteq \Sigma^*|L\subseteq L(0(0\cup1)^*)\}$ However, I'm not su...
If I have numbers ranging from 1 to n, and I generate all the permutations of these numbers. Now, I create Binary search tree from these permutations. For a value n i want to know how many BSTs would have same structure. for example for n=3; we have: 1,2,3 1,3,2 2,1,3 2,3,1 3,1,2 3,2,1 In this 2,1,3 and 2,3,1 pr...
From Sipser Gacs we know $x\in L(M)$ for a machine $M\in BPP$ $\iff$ $$\exists t_1,\dots,t_{|r|}\forall r\in\{0,1\}^{|r|}\vee_{i\in\{1,\dots,|r|\}}M(x,r\oplus t_i)=1.$$ From Adleman we know $x\in L(M)$ for a machine $M\in BPP$ $\iff$ $$\exists r\in\{0,1\}^{|r|}M(x,r)=1.$$ Why is this just $BPP\subseteq P/Poly$ (look...
Over the alphabet $\Sigma=\{a,b\}$, we define $$L=\{a^pb^m: p\text{ is prime }, m>0\}+\{a^r:r\geq 0\}.$$ I must show that this laguage is not regular using the pumping lemma. I guess I should apply it to a word of the form $a^pb^m$, and my intuition is that I should come to the contradiction of $p$ not being prime. Bu...
Where can i find a proof related to the subject mentioned?
Consider the following context-free grammar: $T \to (*) \mid (T*) \mid (*T) \mid (T*T)$ This effectively forms a notation for binary trees: A binary tree is a $*$, with optional children on either side, all surrounded by $()$. This is clearly unambiguous, because you can distinguish between the presence and absence o...
I am going through the following lecture notes on LR parsing : https://www3.nd.edu/~dthain/courses/cse40243/fall2016/chapter4b.pdf For the following grammar : The following LR automation has been done : and the following is the LR parsing table drawn for it : In the table I can see that the alphabets "R" ,"G" and "...
I just want to know whether there exists a horn formula that is equisatisfiable to $(p\lor q)$. I would also be interested to learn if there exists an equivalent as well.
In the Floyd-Warshall algorithm we have: Let $d_{ij}^{(k)}$ be the weight of a shortest path from vertex $i$ to $j$ for which all intermediate vertices are in the set $\{1, 2, \cdots, k\}$ then \begin{align*} &d_{ij}^{(k)}= \begin{cases} w_{ij} & \text{ if } k = 0 \\ \min\{d_{ij}^{(k-1)}, d_{ik}^{(k-1)} + d_{kj}^{(k-1)...
I want to create a regular expression for the language $L=\{ w \in \{a,b\} |$ w has neither aa nor bb as a subword$\}$. I've tried various things, but I can't seem to get the correct regular expression.
If I have the following two languages: $L_1= \{ w \in \{a,b\} |$ $w$ has neither $ab$ nor $ba$ as a subword$\}$ $L_2= \{ w \in \{a,b\}^* |$ $w$ has neither $ab$ nor $ba$ as a subword$\}$. Is there any difference between $L_1$ and $L_2$? I understand the impact of the Kleene star, but I don't see what difference it make...
Can a 3 color DFS be used to identify all cycles in a directed graph not just detect them? In other words if I have a directed graph with multiple cycles, can I run a function on them such that the function returns the list of nodes that compose each simple directed cycle in the graph and not just a boolean true or fa...
I am working on exercise 12.4-5 of CLRS (Cormen et al, Intro to Algorithms 3rd ed) Consider RANDOMIZED-QUICKSORT operating on a sequence of n distinct input numbers. Prove that for any constant k > 0, all but O(1/nᵏ) of the n! input permutations yield an O(n lg n) running time. By RANDOMIZED-QUICKSORT, they simply me...
I am doing some past exam papers and I found two interesting questions which I cannot answer due to them not being extensively covered in the lecture notes given to me by my lecturer. The questions go like this: "Explain the mechanism a SIMD computer uses to support conditional statements like if and while." SIMD is...
I've been asked a question about B+ Tree. The question is: Suppose we have object of the following type: class Obj { private: int value; int key; public: Obj(int uniq_key , int value) } and I am creating a Generic B+ tree which will sort objects in it leafs nodes by keys and not by values. (The keys are uni...
Consider the sequence $s_1 = (1, 0, 1, 0,\dots)$. It seems "regular" in a way that, e.g. $s_2 = (1, 2, 3, 4,\dots)$ is not. I'm not sure how to formalize this intuition though. One thing which jumps out at me is that $L =\{(0 1)^n\}$ is a regular language, and $s_1$ is in some sense the limit of the strings in this la...
Note, while I know how to program, I'm quite a beginner at CS theory. According to this answer Turing completeness is an abstract concept of computability. If a language is Turing complete, then it is capable of doing any computation that any other Turing complete language can do. And any program written in any Turi...
I read the lecture 4 of CS162 (UC Berkeley: https://inst.eecs.berkeley.edu/~cs162/sp17/static/lectures/4.pdf), but I got little bit confused about the meaning of the keyword "buffered" they used when mentioning the following informations: Kernel buffered reads Kernel buffered writes Data buffered automatically by C-li...
Brian Randell, in his article The COLOSSUS, explains how computing ushered in the 20th Century, by the development of the Colossus computer. He cites a passage from the Passages from the Life of a Philosopher, illustrating how Charles Babbage described the Analytical Engine : That the whole of the conditions which e...
I recently got asked the following question: A set of $n$ cities are numbered from 1 to $n$. Given a positive integer $g$, two cities are connected if their greatest common divisor is greater than $g$. The number $n$ may be as large as $10^5$. Alice has a list of $q$ cities that she'd like to visit. Given Alice's list...
I've looked through CS SE and I've found a page that said you could find use BFS to find a MST if the edges are unweighted, but what if the edges are directed? Given a directed graph between V vertices, I'm trying to find the minimum directed edges I need to add in order for every vertex to be connected to every other...
I'm interested in using a random projection as a locality sensitive hash. In every example of this I've seen, it is suggested to pick a random hyperplane and produce a binary number corresponding to which side of the hyperplane a data point lies. I want to use locality sensitive hashing with a random projection, but I ...