instruction
stringlengths
35
29.1k
My professor mentioned that if we already know the divide and conquer algorithm for the closest pair of points in 2 dimensions it's easy to think of a similar algorithm for the 3 dimensions. But I am a bit confused as to what changes we have to make. I think we'll divide the points in two sets based on the x coordinate...
Conflict-Free Replicated Datatypes (CRDTs) are a class of distributed data structures where replica states are allowed to temporarily diverge, but will eventually converge (in the absence of network partitions). 2 Specifically, the class of CRDTs known as state-based (or convergent) achieved the above by requiring the ...
There are integer tuples which index cells of a sparse multi-dimensional array (points inside n-parallelepiped), $n \le 32$. The array itself is a BST with keys formed as $key = (...((a_0 * S_1 + a_1) * S_2 + a_3 ) * ... + a_{n-2}) * S_{n-1} + a_{n-1}$, such keys preserve the order of tuples and can be compared in cons...
I would like to ask this question as I am not sure about the answer. Let $G=(V,E)$ be a connected, undirected graph, and let $x,y\in V$ be two different vertices. Let $A$ be the problem of finding the shortest simple path between $x$ and $y$, and let $B$ be the problem of finding the longest simple path between $x$ and...
I am looking for an algorithm to find the best order of items to fit on pages. Consider the following case, we have a page with the height = 300 We have images with the following heights - [150,200,100,150,300] So I want to find the best order for this images in order to fill the page. For example: First page: 150 - 15...
A bit confused about the term minimum bottleneck spanning tree. I thought it was the spanning tree with the cheapest maximum edge, but the example I was given seems to contradict this. In the example above, my material says: For the given graph G, the above figure illustrates all the spanning trees for the given grap...
I'm the author of GateBoy (a gate-level simulation of the original Game Boy hardware) and Metron (a C++ to Verilog translation tool). One big issue I had to work around for both projects is the inability of C++ (or really, any current procedural programming language) to express atomic state change in a way that is both...
Suppose we have a matrix $A$ of dimension $n \times n$ and two vectors $\vec{u}$ and $\vec{v}$ of dimension $n$. Then we have $A\vec{v} = \vec{x}$ with time complexity $O(n^2)$ and space complexity $O(n)$ with the naive algorithm (since the output is a vector of length $n$). (Forgive me if there is a better runtime. I ...
About few ago in my freshman year of college I stumbled across an an old blog post on r/programming posing a programming challenge. Here is the short version of it: Hundreds of ships would like to dock to each other to build a floating city of ships. Although they are all bound to each other, any ship must be able to ...
how to count all pairs such that w^x=y^z, where 1<=w,x,y,x<=n and 1<=n<=1000000 for example for n=3, there is 15 solutions 1^1=1^1 1^1=1^2 1^1=1^3 1^2=1^1 1^2=1^2 1^2=1^3 1^3=1^1 1^3=1^2 1^3=1^3 2^1=2^1 2^2=2^2 2^3=2^3 3^1=3^1 3^2=3^2 3^3=3^3
I am research scholar currently working in complexity theory. Recently, i have started working on hard proofs and reductions. It is very well established that there is a polynomial reduction from every known hard problem to a possible hard problem. So, while proving the hardness of a problem, it does not matter which h...
I build a python script which uses OpenCV implementation of KNN Backgroud Segmentation/Remover. I know the basics of how KNN works, but not how the background segmentation works. For the MOG algorithm I found lots of papers, but I havn't found a single one for KNN background segmentation. Apart from wanting to understa...
I got the following question from my academic instructor and since I am new to graph algorithms I would be happy if someone could review my solution. Given undirected graph $G = (V,E)$, suggest an algorithm that determines whether or not it is possible to assign directions to edges in a way that the indegree of each v...
Let's say we have a graph $G$ with $|V|$ nodes. We wish to select the smallest set of nodes $S$ that: $dis(i, j) \le k, \forall i \in S, j\in V-S$, where $k$ denotes a certain distance threshold. Smallest means the least number of nodes.
Consider an ambiguous context-free grammar $G$. Define $A(G)$ the set of ambiguous words, meaning: $$A(G) = \{u\in L(G) \mid u \text{ has at least two derivation trees for }G\}$$ Can we say something about $A(G)$ in the general case? In particular, is $A(G)$ a context-free language?
Godd afternoon, We have set C of k coins; For example C = (2, 3) We have positive integer n. In how many ways we can represent n using those coins? Example: If n = 12; C = (2, 3) we can represent 12 as 3+3+3+3, 3+3+2+2+2 or 2+2+2+2+2+2, so in three ways. Introduction: For any predefined set of coins, there exists fo...
Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the subsequence(which is not necessarily contiguous) (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i...
Let $s \in \Sigma^*$ be a finite string over alphabet $\Sigma$. Find all "compressible" substrings of $s$, that is substrings $t \leqslant s$ (notation) such that $t\alpha t \leqslant s$ for some $\alpha \leqslant s$ and $|t| \geq 2$. It's true that with the usual size of a smallest grammar for $s$ that a length-2 s...
T(n) = 2T(n/4) + sqrt(n) I am trying to solve this question and ended up with the answer O(√n.log√n). But when I checked online the answer was supposed to be O(√n.logn) or √n.logn base 4. I am not sure how to remove the square root from n.
I am bit confused on these terminologies. While studying Paging of Operating System we study about Page and Frame. Size of one Frame of Main Memory = Size of one Page of a Process While studying Cache Memory Mapping in Computer Organization we study about Memory Block. Size of one Block of Main Memory = Size of one ...
As we know, Quickselect chooses a 'random' element in order to partition the array around that element in every iteration. Assume the random element is at most the $\frac{1}{k}\cdot n$ largest element, and at least the $\frac{k-1}{k}\cdot n$ largest element, for some constant $k>1$. I'm asked to prove that under those ...
I am reading the paper HyperEnclave. I have a few questions about the OS in general. Is is safe to assume that attackers cannot mount physical attacks during boot process of the OS? Can we assume that the OS is benign during boot process? Is it possible to remove some parts of the OS and disable DMA capability of pe...
I know that regular languages are closed under closure properties. But, for example, we know if $L$ is regular, then its complement $L^\complement$ is also regular. If we have $L_1$ and $L_2$ as regular then $L_1 \cap L_2 = L_3$ makes $L_3$ regular. Now for the case of when $L$ is not regular, then its complement $L^\c...
Lets say I have n lists from different sources, each contains m possible location of the user. I need to choose the most probable prediction of the user location. My idea was to pick one location from each source that so that those n locations are closest to each other. The average of those n locations will be my estim...
This is problem 88 from Miscellaneous exercises of Kozen's "Automata and Computability". The shuffle $A||B$ of two languages $A$ and $B$ is defined as $\{w \mid w = a_1b_1\ldots a_kb_k,$ where $a_1\ldots a_k ∈ A$ and $b_1\ldots b_k ∈ B,$ each $a_i,b_i ∈ Σ^∗\}$. Show that if $L$ is context-free and $R$ is regular, the...
I don't really need hands on coding help, I need to clear my concepts of some of the more complex topics of DS and Algo like NP-Completeness, Computational Geometry, String Matching, Multithreaded Algorithms and Backtracking Algorithms. I have so far read CLRF(Cormen) as my go to book. But sometimes I just can't wrap m...
I have a bag of sets which overlap, and I am looking for an efficient (if possible, optimal) way to leverage that overlap to store those sets with minimal space requirements. For example, consider these two sets: S = {1,2,3,4} T = {2,3,4,5} An efficient storage solution would somehow make use of the overlap, e.g. X = ...
So I'm writing a software that generates random MIDI tracks based on a given mode, tonal etc. As for now the randomisation works on tones building sequences of equal duration. What I'd like to do is also randomise the duration of each note in a sequence, but at the same time I'd like it to fit with the time signature. ...
There are N islands and there is one pirate. The pirate can start out from any one of the n islands and has the option of either staying on the same island for the next day or moving to a different island. All the islands are connected to each other by routes. Each evening of the day the pirate steals some gold on the ...
If $L ⊆ \{0, 1\}^*$ is a language, then we denote by $ \overline{L}$ the complement of $L$ For example, the definition of $coNP$ is $coNP =\{L | \overline{L} \in NP\}$ The complement of $SAT$ language is $\overline{SAT} = \{\phi | \phi$ is not satisfiable$\}$ Of course, there are other $P$ languages What I want to ask...
I'm looking for a context-free grammar that recognizes precisely the numbers 1 - N in order: 1,10,11,100 valid (numbers 1 - 4 in base-2) 1,1,10,11,100 invalid (duplicate 1) 1,10,100 invalid (missing 3) 10,1,11,100 invalid (has all numbers but 1 and 2 are not in the correct position) I'm not sure where to start to creat...
Take $s = a^{10}$ for our example string. Compute the set of all potential grammar reducing variable-rules: $$ A \to aa \\ B \to aaa \\ C \to aaaa \\ D \to aaaaa $$ There is always exactly $\left\lfloor \dfrac{|s|}{2}\right\rfloor - 1$ of these over a singleton alphabet, or in other words $O(|s|)$. Now enumerate all...
Setup I have a non-empty set of elements $U$ that are arranged spatially. I would like to partition $U$ into $N$ non-empty, disjoint subsets, $A_i$, having up to $M$ elements each. Each subset is only allowed to contain neighboring elements. I would like to also partition $U$ into $N$ non-empty, disjoint subsets, $B_j$...
I feel like I am understanding P ≠ NP fairly well, but there is one issue I feel like I am missing. It seems like a search for an answer generates information that a check does not. Is this a correct way of looking at it, and if so, how does that not already imply that P ≠ NP? Example for Clarification Let's take the w...
Consider the following schedule S.Is S conflict–serializable? Append the commit operations of these transactions at the end of the schedule in an appropriate order such that S is recoverable. How many such orders are there? $$S: r1(X); r2(Z); r1(Z); r3(X); r3(Y); w1(X); w3(y); r2(Y); w2(Z); w2(Y);$$ I have already foun...
Let $P$ be a symmetric (positive definite, if that helps...) matrix of size $n$. Let $F$ be a matrix of size $n$. Is there an existing efficient algorithm implementation to calculate $FPF^T$ ? Is there an even more efficient existing implementation for the special case where $F$ is upper triangular ? To give some con...
I'm currently enrolled to a CS course about programming languages and we learned about structural induction. In a question from our home assignments we need to proof that the following CFG has balanced parentheses: My initial solution used simple induction and following the derivation rules of the CFG but the TA told ...
In Tomasulo's algorithm, is there only one reservation station per functional unit (even with multiple same-function FUs like, say, 3 adders)? Can there be more?
I'm facing this problem for some time now, I've tried a greedy approach yet I result to trying a DP-ish approach, only to get stuck at a standstill. Given a board of length $n$, and an increasing monotonic "price" function $p:\mathbb{N}\rightarrow\mathbb{R}^+ $, an acceptable partition (Notated by $X=\{x_1,x_2,\ldots x...
Consider the set of all linear programs of the form: maximize $c x$ subject to $A x \leq b$ $x \geq 0$ where there are $m$ variables, $n$ constraints, and all coefficients in $A, b, c$ are integers from a given finite set $K$. Since the number of such programs is finite, the number of possible optimal values of these p...
I'm looking for an algorithm that is closely related to the 2-dimensional nesting problem (also known as lay planning, bin packing, and the cutting stock problem). The main differences between this and normal nesting are: A fixed number of elements to be placed The elements cannot rotate The elements must be placed in...
When we speak of a variable, sometimes we will mean the string it expands to, and other times, the variable itself. Let $t \leqslant s$ mean substring. Take the string $s = a^6$. Then its compressible substrings are $aa, aaa$. Now assign positioned variables $A_i \to aa$, $B_j \to aaa$, for $i = 1...5, j = 1...4$ lik...
I'm stuck here, how can i prove this: $$L_1 \cup L_2 \subseteq L_1^*L_2^*$$ $$\begin{array}{rcl} x\in L_1\cup L_2 & \Rightarrow & x\in L_1^* \lor x\in L_2^*\\ &\Rightarrow &x\in L_1^*\cup L_2^* \end{array}$$ What's next?
How can I calculate the complexity of computing $MD(b)$, where $b=(b_1,b_2,\dots,b_n)$? $$MD(s) = \max(s)-\min(s) + \min(MD(s\setminus\{\max(s)\}), MD(s\setminus\{\min(s)\}))$$ where $s$ is a finite multi-set of numbers with base case $$MD(\text{one element})=0.$$ Thoughts: I think the time complexity is $O(n^2) $ beca...
Given a graph G = (V, E) with edge lengths c : E → R, and a number d ∈ R, is there a Hamilton cycle of length l ≤ d in G? Show that the Travelling-Salesman problem is contained in the complexity class NP. I am somewhat struggling with this exercise because I have little problem understanding the formality. I know that ...
Let's say that I have a Las Vegas algorithm for a given problem (whose answer is true/false for simplicity) with a chance of answering p, and a Montecarlo algorithm for the same problem which is q-correct (it gives the correct answer with a probability of at least q) Could there be any way to combine them both in order...
If we have this language $ L = \{a^mb^nc^n:m,n \in N\}$, would its complement be $\{a,b,c\}^* \setminus L = L^\complement = \{c^nb^na^m:m,n \in N\}$? This was the professor's answer, which I find incorrect, because it doesn't include for example $aba$, which should be in the complement as well. Since the given language...
Description Similar to the encoding of a Turing Machine, we can encode a Push-Down Automata. Denote $\langle M \rangle$ as the encoding of PDA M, and a natural number n, is language $L = \{ \langle M \rangle | \text{ M is a PDA, L(M) contains at least 1 string w that } |w| \leq n \}$ a recursive language? Question By t...
Let $A \subseteq Z$, where $Z=\{1,2,3,\cdots,n\}$. Now given any $B \subseteq Z$, we need to check whether $A \cap B =\varphi$ or not. I am looking for a randomized algorithm. I am trying to implement it using a bloom filter. Create a bloom filter for $A$ and $B$ respectively. Now consider the intersection of $A$ and $...
I guess the question does not apply just to CS as I'm trying to understand how it applies to RAIDs, but I guess it's maybe the most suitable place to ask anyway. There's a lot of info that RS codes are often used to implement second parity for RAID-6. There are some systems that implement triple-parity. Am I right that...
I work with elements that have a representation in two different vector spaces and I would like to compute an indicator of how similar the neighbors of the elements are in these two spaces. To do so, I start by computing the list of the $n$-nearest neighbors of all elements, then I use a sequence similarity measure th...
I am creating a database on students' interests using the Entity-Relationship Model for a University assignment. Should I implement the circled stuff as attribute, or an entity set?
Problem definition I have a directed graph $G = (V,E)$, with positive weights $w(e)>0\:s.t\:\forall e \in E$ I would like to find the longest walk (i.e. edges and nodes may be repeated) in terms of most accumulated weight, under the condition that once an edge $e$ is traversed, its weight will become its own negative ...
Given an array $A=\{\frac{S_1}{K_1},\frac{S_2}{K_2},...,\frac{S_n}{K_n}\}$ whose any $S_i$ and $K_i$ are positive floating-point, and an positive floating-point $R$, how to select a set of element $C=\{\frac{S_{p_1}}{K_{p_1}},\frac{S_{p_2}}{K_{p_2}},...,\frac{S_{p_m}}{K_{p_m}}\}$ such that the absolute value of the dif...
I designed an algorithm where, at some point, I need to compute the product of a list of integers $n_1,\dots,n_m$ (possibly, there are repetitions in the list). The integers themselves do not depend on $m$ but can be, somehow, arbitrarily large. EDIT: right now, I'm using a naive for loop: prod=1 for n_i in list: p...
if we have $f(n)=f(n-7)$ and $f(2)=3$ can we conclude that $f(n) \in \theta(1)$? what if we also have $f(1)=2$?
Is an infinite set of RE languages create a language that is also RE? I think it's true, and my first intuition is to try induction to prove this statement. Am I on the right way? Thanks!
This is a real world problem, which due to some specific aspects of it I am having a hard time finding relevant literature for it. I am looking for either an algorithm, or a pointer to relevant paper(s) describing a solution. I'm assuming one was already published, but I am just fumbling with my search terms. Problem s...
I'm finding it difficult to understand why due to the pigeonhole principle, 2 distinct words must go to the same state in a DFA. Is it that if there are n words and m states, where there are more words than states (n > m), that 2 words must end up in the same state? Is this somewhere along the right path?
Right now i am looking at the following statement, but i cant grasp why it is correct. Can somebody help? "If we look at F0 uniformly distributed (and, say, pairwise independent) elements of [0, 1], we expect about t of them to be smaller than t/F0." Kind Regards, Ilian
What is the complexity class of: given a graph G, is the graph has a maximal clique of size k? k is integer less than or equal the number of graph vertices. A related question, Given a Graph G, Find a maximal clique of size k. This is np because it is polynomially verifiable. Right? The essential question if the above ...
I'm working on a resource allocation problem, where there are $n$ different Items and $m$ different tasks ($n\geq m$). Also, The profit of assigning subset $I=\,(\, |I|\leq n)$ of items to task $j$ is calculated by $f(I;j)$. If no item is assigned to task $j$, then the profit is calculated as $f(\emptyset;j)$. The obje...
consider the following function $$ \begin{align*} f(m,n) &= \begin{cases} k & \text{if program $m$ halts on input $n$ after $k$ steps} \\ m & \text{if program $m$ loops on input $n$} \\ \end{cases} \end{align*} $$ can you find an algorithm for this function?
As part of a college project, I need to compare the speed of arithmetic operations directly in binary on different processors. Example: At what speed will binary addition be performed on an Intel Core I5-12400 processor? Initially, I had the idea to write a program myself that would perform the appropriate tests. The p...
I am a teacher of undergrad graph theory and we tend to invent some weird (and false) characterizations of trees and recently I stumbled upon this one. Is the following true? $G$ is a tree if and only if $G$ is connected and between each pair of vertices of same degree, there is an unique path connecting them. If we re...
For example, are there worst case Decidable(but non primitive recursive or other insane time complexity)problems that have a polynomial average case complexity? If so Are there undecidable worst case problems that have polynomial time average case algorithms? Is there a limit on the arithmetical hierarchy where there c...
I'm currently in need of the inverse operation of the concatenation of 2 regular languages. Formally, for 3 regular languages $A,B,C$ such that $A \cdot B = C$, only $A$ and $C$ are known, and $B$ is the smallest language that fulfills the equation (which implies $\forall w \in B: A \cdot (B \setminus \{w\}) \subset C$...
Let $A=\{$ M is a TM, $s\in \mathbb{N}$ and $\exists x\in\Sigma^*$ s.t M rejects $x$ in at most $s$ steps $\}$. I want to define its complement, so how do I negate "$\exists x\in\Sigma^*$ s.t M rejects $x$ in at most $s$ steps"? Is it: $\forall x \in \Sigma^*$ M accepts $x$ in at most $s$ steps? Thanks a lot!
We know that there are basically 3 fundamental parts of a processor namely : Control Unit (CU) Arithmetical Logic Unit (ALU) Clock Also we know that they maintain several important and different functions of the processor. However, if we had to arrange them according to their importance/priority , then which one shou...
In a B-Tree, one of the rules is: Every node (except the root) is at least half full But then, in a 4-way B-Tree, we have the following case. Suppose we want to insert $10,20,30,40$ to the tree. After inserting the 3 first element we get the following root: [10 20 30] After adding the 40, we split as follows: ...
Im trying to understand the following question. Suppose $h,f:\{-1,1\}^n\rightarrow \{-1,1\}$ satisfy $\sum_x h(x)f(x)\leq 0.5$, then one can rewrite this as $\textsf{Pr}_x [h(x)=f(x)]\leq 3/4$. Can we use this statement to show: there exists $i\in [n]$ such that $\sum_i h(x)f(x)h(x^i)f(x^i)$ is small (where small here ...
Consider the following game: You are given a set $S$ and a fixed list $q_1$, $q_2$, ..., $q_n$ of yes or no questions about the elements of $S$. Your opponent chooses an element of $S$ without telling you which. You then ask a series of questions taken from the list and your opponent truthfully answers "yes" or "no" to...
Can CYK algorithm be used for ambiguous context free grammar?
Does the answer depend on the number of bytes requested? If it is forced to keep a buffer due to some unknown device/diver, can it optimize and skip the buffer if it's going to be a disk read? I'm looking for any insight beyond "It's implementation dependent". How I got here: C++ implementations of POSIX compliant syst...
Let $L\in R, L_2\in RE$ and $n\in N$. Define $L_n=${$w|w\in L \vee (w\in L_2 \wedge |w|\leq )$} Find a decider for $L_n$ For the right hand side, I thought I could check the length of and then simulate the recognizer that recognizes $L_2$ until it accepts. I don't know how many steps it'll take the machine to halt and...
This article from IBM (link) talks about Memory hierarchy in its actual hardware parts. NUMA While operating systems present memory to the running applications as a unified space, modern large systems have memory organized in a hierarchy, by core, chip, module, socket, node, and chassis/central processor complex (CPC)...
I'm researching static recompilation but there doesn't seem to be too much information about the subject. I've heard that dynamic recompilation (emulation) can be up to 6 times slower than native assembly, but I'm curious why we aren't able to translate to a different architecture ahead of time. Even though some instru...
Assuming this set of instructions: declare variable 'A' which has value 5 declare variable 'B' which has value 2 From what I've understood, those instructions are loaded into RAM an then read by CPU, they are composed by OPCODE + Data. So, lets assume that the opcode to set a value for a specific RAM address is (0001...
Given doubly linked list $L$ that contains $n$ elements of numbers. Between QuickSort, and MergeSort and InsertionSort, which algorithm preferred to sorting $L$ by just swapping links of $L$? I think the InsertionSort is better option but I have no any idea to show that that minimize number of changing pointers. Any h...
I know that there are many techniques to represent graphs. Suppose I have a directed massive 3D graph with 100,000 nodes at maximum. Suppose the graph looks somewhat like the following: Suppose each node of the graph has three pieces of information: A 30-character string as a label floating point values as coordinate...
In Cormen's Introduction to Algorithms, he states the the LP relaxation for the minimum vertex cover approximation problem is $ \begin{align*} &\sum\limits_{v \in V}w(v)x(v) \tag{35.15} \\ x(u) + x(v) &\geq 1 \text{ for each } u, v \in E \tag{35.16} \\ x(v) & \leq 1 \text{ for...
An arithmetic circuit relates to calculating the value of a polynomial given some inputs. But is it still considered a circuit if the DAG corresponds to the evaluation of multiple polynomials that share nodes? Consider $f(x, y) = 3x^4 * y^3$ and $g(x, y) = 3x^4 * y^2 + x^2$. $f$ and $g$ share the node corresponding to ...
I am currently struggling with figuring out the following problem: Given decidable languages L1, L2, L3, L4, ... Is the infinite union of Languages L1, ...... decidable? I have an intution that it is not, but I cannot find an example against that thesis. Thank you in advance
Apologies if this question exists somewhere. I'm sure it's been asked, but I don't know how to search for it. This is not a homework question but rather a scientific problem I ran into. If this is a standard CS exercise, just mark it as duplicate and point me where I need to go. Problem statement: Consider an undirecte...
I'm working on understanding graphs and graph algorithms. The problem is from: https://courses.engr.illinois.edu/cs374/fa2020/labs/sol/lab_12_b_sol.pdf (Q 1.D) Describe an efficient algorithm to update the minimum spanning tree $T$ of a weighted undirected graph G when the weight of one edge $e \notin T$ is decreased....
I'm sure this question has been asked before, but I have no clue what I'm trying to achieve is called and couldn't find anything helpful. I'm trying to find the name of an algorithm that starts at a point and rotates around a "board" in either clockwise or anti-clockwise rotation. I'll draw some examples to shown what ...
Consider L1 = Any language generated by a machine M1 L2 = Any language generated by a machine M2 Machine can be – FA, PDA, LBA, or TM Assuming Machine M2 is more powerful than M1 Let L3 = L1 $\cap$ L2 Now can we always say that L3 can be generated by Machine M2 ? For eg: L1 = Any Context Free Language (i.e Generated ...
in here they claim: "there is an algorithm deciding almost all instances of [halting problem]" so I'm wonder whether there is a computable function $h':\mathbb{N}\to\{0,1\}$ such that the following turing machine is a halting decider (for TMs running on blank input) except for itself $$ \begin{align*} M(m) &= \begin...
I am trying to understand Circuit Complexity's relation to classical Time Complexity. Here is what wiki mentions: "If a certain language, ${\displaystyle A}$, belongs to the time-complexity class ${\displaystyle {\text{TIME}}(t(n))}$ for some function ${\displaystyle t:\mathbb {N} \to \mathbb {N} }$, then ${\displaysty...
Is CFL $\cap$ DCFL = CFL, always true? CFL - Any Context Free Language DCFL - Any Deterministic Context Free Language
This question is in the context of quicksort. Consider that a subarray of distinct elements of size $k$ is sampled from the input array of size $n$, and then we choose a pivot from the sampled subarray. We want to compute and bound the probability that the element of rank $s$ in the original array lies in the middle th...
The COIN-CHANGING problem is NP-complete, but I am having difficulty finding a proof for its NP-hardness in the form of a reduction from another NP-complete problem to COIN-CHANGING. Apparently, a reduction from SUBSET-SUM to COIN-CHANGING is possible according to this (hopefully old enough) algorithms assignment from ...
I need to prove that $T(n)$ is $\mathcal O(n\log n)$ with the substitution method. $$ T(n)\leq 3\log n + n + \frac{6}{n}\sum^{2n/3}_{n/3}T(i).$$ This is my attempt: I assume $T(n) \leq c n \log n$ and then \begin{align*} T(n) &\leq 3 \log n + n + \frac{6c}{n}\int^{2n/3}_{n/3}x\log x dx\\ &\leq3 \log n + n + \frac{6c}{...
In section 30.2 of CLRS (third edition), they given an algorithm for computing the fast Fourier transform of a vector represented as an $n$ dimensional array when $n$ is a power of $2$. They say that an algorithm for general $n$ is beyond the scope. Is generalizing the algorithm to any $n$ very tricky? Any references w...
I need to prove that the following expression is $\mathcal O(n \log n)$ with the substitution method: $$ T(n) \leq 3\log n + n + \frac{6}{n}\sum^{n - \frac{\log n}{3}}_{i=\frac{\log n}{3}} T(i)$$ This is my attempt, assumming $T(n) \leq c n \log n$: \begin{align*} T(n) &\leq 3\log n + n + \frac{6c}{n}\int^{n - \frac{\l...
Are the following two stat rules equivalant? stat : 'if' expr 'then' stat ('else' stat)? ; stat : 'if' expr 'then' stat // with higher priority | 'if' expr 'then' stat 'else' stat ; That is, does ANTLR 4 always put the alternative without the optional part before the one with the optional part, or vice v...
I'm trying to implement self-organizing lists DS to publish as a public module. Over the course of Algorithms, we learnt that if you add a new element to the list, it should still do the huriectics. For example, in Move-To-Front, when you do insert(2) it will add 2 to the end of the list and then move it to the front r...
Suppose we have a minimization ILP. Denote its value by $OPT$. Let $PER$ be the solution to its LP relaxation. Given a real number $t$, we would like to decide whether $OPT \leq (1+t) \cdot PER$, in time polynomial in the problem size and $1/t$. Denote by FPTAD, the class of ILPs for which this is doable in polynomial ...
Suppose Alice has a verifiable (message, signature) pair from Cedric, who would not cooperate and routinely uses an algo (ecdsa, eddsa, rsa, or insert yours here) to sign messages. Alice wants to interactively prove to Bob she has that (message, signature) pair with the valid signature, obviously. It doesn't have to be...
It is common to have proofs that use contradiction to show that some language is undecidable in computability theory. An example proof can be seen in 4.2 Undecidability “Introduction to the Theory of Computation” by Sipser proving 4.11 the undecidability of A_tm. Basically, these proofs assume the existence of a decide...