instruction
stringlengths
35
29.1k
The problem is in this other question. Why does this always work? It's not clear to me how one would use induction. For $n = 3$, a quick calculation shows it works, however, I don't think it generalizes well.
while(n>1){ n = sqrt(n); } Where sqrt returns the root of n. n = 2^k and k is a power of 2.
Suppose there is a specific set function with some properties - $f=2^V\to \mathcal{R}$. It is known that the following problem is NP-Hard: Find $S\subseteq V, |S|\leq k$ such that $f(S)$ is maximized. My goal is to show that designing a constant factor approximation algorithm in polynomial time is NP-Hard. Correct me ...
Are there specific terms or adjectives in graph theory to name these two situations? Two vertices are non-adjacent (disjoint? I have seen that the term "disjoint" is rather used for paths with non-common vertices or edges). Two connected non-adjacent vertices (the shortest path or paths connecting them have a lenght $...
I have been trying to solve this HackerRank problem (link). The basic premise of this problem is that there is a tree with undirected, but weighted, edges. The cost of a path in this tree is taken to be the MAXIMUM cost of any edge in the path. I will be given a series of queries in the form of [L, R] and I have to ou...
For a NOT gate if $x_1$ is input and $x_2$ is the corresponding output, I see the equivalent CNF (conjunctive normal form) is $(x_1 \lor x_2) \land (\overline x_1 \lor \overline x_2)$. My expectations was that the CNF should not include $x_2$ as it is the output of the gate. I was rather hoping the formula to be of a f...
Does $\mathrm{EXP}^\mathrm{EXP}=\mathrm{EXP}$? Here is my thought: $\mathrm{EXP}$ machine can ask $2^{O(n)}$ queries to the oracle, and each oracle would itself solve an exponential time problem in a single step. So the total power would be $2^{O(n)}\times2^{O(n)}$ which would still be in EXP.
Let's say I have a list of items, each of which has some value Eg. L1 = [A, B, C, ...] And another list of items L2: [1, 2, 3, ...]. Each of the items in L2 needs to calculate the max value of a subset of the items in L1 Eg. Item 1 wants max(A,B,C) , item 2 wants max (D,E,F) , etc. I cannot figure out how to calculat...
I was reading up about formal languages (see here: https://pdfs.semanticscholar.org/18b2/d685d5e244a6bfc5a31d312f1e8d322c16a9.pdf) and got confused when I started reading about this expression: 0(0+1)∗+(0+1)∗0 This is how I think it works: The first and last 0 indicates where these two characters must be present. In ot...
i was reading the binary search and ternary search algorithms. But i had a doubt with recurrence relation of ternary search as somewhere it is T(n/3)+c and T(2*n/3)+c. I want to know which one is correct as solution for both is same. i have referred a and b and both are different. Which one is True and HOW??? Also the ...
I have some troubles understanding why the halting problem is in EXP. In Wikipedia the following is written: It is in EXPTIME because a trivial simulation requires O(k) time, and the input k is encoded using O(log k) bits which causes exponential number of simulations. It is EXPTIME-complete because, roughly speaking,...
I'll define the problems UHAMPATH Input: A undirected graph G and 2 nodes, s and t Question: Is there a hamiltonian path from s to t in G? UHAMCYCLE Input: A undirected graph G Question: Is there a hamiltonian cycle in G? $$UHAMCYCLE \leq_p UHAMPATH$$ my reduction is as followed $(G) \to (G', s, t)$ function(G) ...
Let's assume we've got an automata with infinite stack ($s_n \epsilon \mathbb{Z}$) and infinite amount of "registers", but no arbitrary memory access whatsoever and it's data is separated from code. I'm sure that this is at least pushdown automata, but I'm not entirely sure can we pull this machine up to the linear bou...
The setting of this question is a bit long-winded, but please bear with me. This fall I will be lecturing a course on mathematical information theory, and on a few lectures we will be discussing Kolmogorov complexity. One of the challenges I face is that most of my students will most likely not be familiar or comforta...
QUESTION Given some NFA $A$, can you simulate the determinization of it (using Subset-Construction for example) while remaining in $PSPACE$? MORE DETAILS I'm asking this as I want to be able to construct $\overline A$ (the complement of $A$) in poly-space complexity. More specifically, I want to receive $\left <A,w \ri...
Is there an algorithm that can list all possible parenthesizations of a given set of commutative factors? This is related to the Catalan number. It, however, merely determines the number of such occurrences, while keeping a given factor order. As an example (found at the above link): from "abcd", the algorithm should p...
We need to select participants, based on the quotas provided. For example: exactly 15 men exactly 15 women exactly 10 young exactly 10 middle aged exactly 10 old exactly 10 poor exactly 10 middle class exactly 10 rich The total number of participants should be exactly 30. What algorithm should be used to do that? Simpl...
In the book "Computational Complexity: A modern approach", Arora and Barak proof the statement that $DTIME(n) \subsetneq DTIME(n^{1.5})$ by constructing a separating language $L \in DTIME(n^{1.5})$ but $L \notin DTIME(n)$. The language $L$ is the one decided by the following Turing Machine $D$: On input $x$, run for $...
As stated in equality at nLab, "computational equality" is about computational steps which take for example, $s(s(0))+ s(0)$ to $s(s(s(0)))$ and it acts exactly and can be considered same as definitional equality (at least in type theory). But then if we consider $p$ in $p:Id_\mathbb{N}(a+b, b+a)$ as computation steps...
The definition on Google says 'serving or intended to pre-empt or forestall something, especially to prevent attack by disabling the enemy.' So, how does this relate to an algorithm, especially the Nearest Neighbour Algorithm?
HAMPATH/UHAMPATH is A directed / undirected graph G and 2 nodes s and t and is there a hamilton path from s to t? Likewise with HAMCYCLE/UHAMCYCLE but has a hamilton cycle on $G'$ The reduction for directed is $HAMPATH \leq_p HAMCYCLE$ function(G, s, t) G' = G add node t' to G' add edges (t, t') and (t', ...
as reading the book Algorithms by Dasgupta, C.H Papadimitriou. on Page 63. And it is well known that $\log(n!)≥c\cdot n\cdot\log n$ for some $c > 0$. There are many ways to see this. The easiest is to notice that $n! \ge (n/2)^{(n/2)}$ because $n! = 1 · 2\cdot\cdots\cdot n$ contains at least $n/2$ factors larger than...
When I need to replace the CPU of my computer, I turn it off, replace the hardware, then reboot it. But what if you need to replace the CPU (in a single CPU machine) without stopping the processes running on it? Is that possible, and if so, how? This is a theoretical question. It doesn't matter if the procedure is comp...
What I'm trying to figure out is what happens when using a multi objective optimization algorithm such as NSGA-ii and instead of trying to find the usual 2/3 objectives, I use 10 or many more objectives?
i'm trying to reduce CLIQUE to SAT: Given: Graph G=(Vertices V, Edges E) and $k \in \mathbb{N}$ Output: Formular F such that if G contains a complete subgraph of size k, the formular is satisfiable (and vice versa). I tried doing it the way Cook/Levin showed that SAT is NP-complete by introducing a set of booleans $v...
Consider different ways of evaluating a procedure call and its arguments. Essentials of Programming Languages says All the parameter-passing mechanisms (natural parameter passing, call by value, call by reference) we have discussed so far are eager: they always find a value for each operand. We now turn to a very dif...
I find myself solving problems for a test and the next problem I still can't solve it. There are n ordered sequences, $S_1$ to $S_n$. It is requested to intermingling them to obtain a single sequence, but doing the minimum possible work. The sequences are interspersed by two, the interleaving sequences $A$ and $B$ a l...
My apologies if the question sounds naive, but I'm trying wrap my head around the idea of time complexity. In general, the Karatsuba Multiplication is said to have a time complexity of O(n^1.5...). The algorithm assumes that the addition and subtraction take about O(1) each. However, for binary addition and subtraction...
Regarding the word sense disambiguation problem, read the following fact written on Knowledge-based Word Sense Disambiguation using Topic Models: Note that although WordNet is the most widely used sense repository, the sense distinctions can be too fine-grained in many scenarios. This makes it difficult for expert anno...
A few years ago, a youtube channel named hackerdashery, made an extraordinary youtube video explaining P vs NP, in a semi-vulgarized way : https://www.youtube.com/watch?v=YX40hbAHx3s At 7 minutes and 56 seconds however, he talks about why it is so hard to prove that P $=$ NP or that P $\neq$ NP, and states that provi...
I am interested resolving a programming challenge problem, but I'm struggling obtaining an efficient solution. Consider yourself as a point located on the origin $(0,0)$ of an infinite two-dimensional flat world. There are $n$ sea waves surrounding you, each one modeled as a circle with center $(x_i, y_i)$, initia...
I'm looking for the formal specification for the Abstract Data Type Algebra for the Associative Array, Associative List (AKA multimap), and other similar ADT to cite for use in a data specification similar to Binary JSON. The Wikipedia Associative Array entry uses non-standard math terminology and their sources are all...
Take for example "Hamiltonian cycle for a large graph". The proof works by starting with a graph G that contains a hamiltonian cycle, then constructing an isomorphic graph H, and then either showing the mapping between the graphs G and H or releaving the cycle in H. It is said that we prove that that we know a hamilto...
Problem statement In an university, there are $t$ course categories, $m$ courses, $n$ sections, $p$ students. $i$-th section has: A student capacity: $cap_i$. Two lecture timings. (Formally, each section has two elements from $S$ associated with itself, where $S$ contains all lecture timings.) A parent course $course_...
Problem For my game, I'm building a system where players have power/weight, and they can downvote each other, players with 66% of downvote weight are banned. The weight of the votes is calculated based on the total weight of the active players, and banned players cannot vote, so the total weight of the system can chang...
Kadane's Algorithm is an algorithm that solves the maximum subarray problem by clever dynamic programming. Is there a way to further modify the algorithm so that we would get to know the resulting subarray that produces the corresponding maximum sum? PS: I don't know whether I should post this here, or Stack Overflow,...
Hi in the data mining and machine learning course that I'm taking there is a subject on feature spaces and there is this part about feature vector aggregation and metric spaces that I don't really understand. Now our curriculum is basically a huge presentation and the whole information about feature vector aggregation ...
I'm working on the same exercise as described in this post: How to show that hard-to-compute Boolean functions exist? In the answer there I don't understand how the number of circuits with at most $m$ gates was found to be $O(m^{4m})$. My construction of the number of gates required: Let any logic gate in the circuit t...
I know that a regular grammar has a definition $$\begin{align}S &\to aS\\ S &\to \lambda \end{align}$$ But I dont really know how to apply this information to check whether or not a grammar is regular... So for example I have a grammar $$\begin{align}S &\to aSbSb\\ S &\to \lambda \end{align}$$ If I compare it to the d...
The book I am reading suggests that in a many-to-one multi-threading model, the threads are unable to run in parallel in a multi-core system. I am thinking this is not the case because if we have many-to-one means that multiple user threads are mapped to one kernel thread. However, there might be many kernel threads ru...
In the Set Cover problem we need to cover each element at least once. I'm considering the case where I want each element to be covered at least $k$ times with constant $k$. I consider the classic LP for the problem and randomized rounding. Is it indeed the case that the modification of the LP from $\geq 1$ to $\geq k...
Actuality I work in computer vision, specifically on a problem known as "scene graph modeling." This problem aims to convert an image $I$ in a graph $G=(V,E)$ where the nodes $V$ represent the objects (and the features) in scene and the edges $E$ the relationships between objects. An interesting paper on this topic is ...
Some facts about "Segmented Paging" 1) Each process has one segment table. 2) There is one-page table per segment. Fact about "Paged segmentation" 3) Contains page table of segment table. Now consider following problem In a paged segmented scheme of memory management, the segment table itself must have a page tabl...
I would like to merge connected nodes with a specific attribute of a directed acyclic graph. The purpose is to detect max connected clusters of blue nodes and merge them. After each merge operation, the graph should remain acyclic. Let's say my graph contains blue nodes and white nodes. A and B are connected, they may...
I was wondering if there are any calculus relationships implicit in Big-O notation. For example, an algorithm linear according to Big-O notation reduces the size of the problem by a constant amount at each step, and also involves looking at each part of the input a constant number of times. The derivative of a linear e...
How can we prove rigorously the proposition "Suppose the if in case 1 is true, the equation 4.23 is true"? For given constant b and j, the implication in green makes sense. If the upper bound of j was fixed, the equation 4.23 follows directly. However, when n increases, the upper bound of j also increases, though is ...
I was going through the concept of Interpolation search and it stated that when the elements are "uniformly distributed", it takes O(loglogn) to search an element using interpolation search. Can someone please explain me this?
I'm curious about what do we need volume as an abstraction on top of hardware partition? What problem it tries to solve? What is the limitation of this concept?
I'm looking for a concrete language that can be pumped but is not regular. I understand that closure properties can be used to further test if a language is regular/nonregular.
Recently I came up with a traveling-salesman-esque problem. As usual, we have $n$ vertices, and a weighted edge between any two vertices. However, each vertex is associated with a color, which may be repeated. Then, you are given a sequence of colors, and you want to find the shortest path that follows this sequence. I...
We run a report, but for one of our big clients, it is taking too long. There is a loop where it loops for a list and fetches it upstream 1by1. We're making this a bulk operation now, but some items in the list might be invalid and upstream don't tell us which. I now need to silently handle the failures and remove them...
I've started to read the section about the RSA cryptosystem in CLRS (page 958) and I don't understand the way it describes how to encrypt a signed message. If Bob wants to send a message $M$ to Alice: Bob takes $M$ and encrypts it (using Alice's public key): $P_A(M) = C$. Sends $C$ to Alice. She decrypts it using her ...
Let's say I have two substitutions given [a:=b] and [c:=d]. What are some conditions that hold for a,b,c,d ∈Σ* iff forall s∈Σ* s[a:=b][c:=d]=s[c:=d][a:=b] Also you can assume that a,c≠ but you cannot assume so for b and d.
I found this related question, but that's not quite it Is it possible to model this with integer programming: $$A = \begin{cases} 1 & \text{if } B \geq C \geq D \\ 0 & \text{otherwise}\end{cases}$$ where $A \in \{0,1\}$, $B, D \in \mathbb R$ and $C \in \mathbb N$. We have upper and lower bounds on $B$, $C$ and $D$.
I trying to solve the following problem in $O(n^2)$: We have vertices which represents cities and a textfile containing an edge on each line. How many roads do we need to build to make the graph connected - you can travel by road to each city? Basically, at the start, we have just the vertices. As we read the textf...
Below is the solution to a merge sort exercise - "Use a merge sort to sort the list". I'm confused because I thought that there needed to be an initial phase of breaking the list in to sub-lists, yet here only the "reconstruction" phase is shown. Am I missing something, or is there a problem with the given solution ple...
I am doing some reading into computer science and how the computing system works in order to be ready for my 1st year at university doing a Computer Science degree. I came across a term within the definition for a computer system that I tried looking up for on the internet called 'dynamic entity'. The problem is, I cou...
Traditionally, the traveling salesman problem has you visit a city at least once and at most once. However, if you were an actual traveling salesman, you would want the least cost route to visit each city at least once, and you wouldn’t be bothered visiting a city 2, 3, or more times. For given city, you might stop an...
I'm currently reading "The Algorithm Design Manual" by Steven Skiena. On page 73, he discusses the time complexity of implementing $ Predecessor(D, k) $ and $ Successor(D, k) $ and suggests that it takes O(1) time. If the data structure looks something like [(k0, x), (k1, x), ...] where the keys k0 to kn are sorted, g...
The question here is to find a path from A(rad) to B(ucharest). I'll be using the initials of the cities in the picture instead of their full names. Some ground-rules: we're traversing in alphabetical order. And traversal must stop once the goal node has been generated, not expanded. This last part is where I feel lik...
Design a Pushdown Automata, accepting either by final state or by empty stack to accept the set of all strings of 0’s and 1’s such that no prefix has more 1’s than 0’s This is a homework question, but not graded. I'm not looking for the answer, right now I'm just trying to understand the question. I don't underst...
In my highschool class we are learning about Artificial Intelligence, and especially the problems that come with machine learning. I was wondering if chatbots like cleverbot were good examples of overfitting. Obviously, when you get a reply that doesn't make sense, is that a result of the bot modeling a training datase...
Is there any algorithm/protocol out there to solve/mitigate the free rider problem without requiring identification? In a web system, I want to distribute exactly one virtual dollar per day to each person, without requiring identification when a person creates an account. A solution of mitigation, would mean for exampl...
Recently Harvey and Hoeven published a paper proving that integer multiplication can be performed using at most O(n log n) operations. This algorithm is theoretically interesting, but in practice completely silly because you only start to see advantages on numbers with an absurd number of digits. But suppose that we on...
Let $(E,D)$ be a probabilistic encryption scheme with $n$-length keys (given a key $k$, we denote the corresponding encryption function by $E_k$) and $n+10$-length messages. Then, show that there exist two messages $x_0, x_1 \in \{0,1\}^{n+10}$ and a function $A$ such that $$\mathrm{Pr}_{b \in \{0,1\}, k \in \{0,1\}^n...
According to wikipedia and other references there exists complete language $L \in EXP$ such that for every languages $L'$ in $EXP$ there exists a polynomial reduction $f$ that converts instance of $L'$ into $L$ in polynomial time. I believe this definition is fine but I have some observation that are confusing me. I co...
I'm doing a replacement for the venerable make utility that will support, among other things, automatic cleaning. The utility figures out automatically what files and directories are targets, and then deletes those, if the user wishes to do a clean operation. However, a file may reside in an automatically created direc...
A Bitonic sorter takes a bitonic sequence as an input and the output is a sorted list. I want to analyse Bitonic Sorter by knowing its depth/runtime. Can anyone give an idea on its recurreence formula? Thanks.
Hi I'm attempting to self teach myself from Algorithms (Sedgewick) and ran across the following problem: 3.1.15: Assume that searches are 1,000 times more frequent than insertions for a BinarySearchST client. Estimate the percentage of the total time that is devoted to insertions, when the number of searches is 10^3...
I read some computation theory lecture notes and after citing and proving the proposition: $\emptyset \in S \Rightarrow L_S = \{\langle M \rangle : L(M)\in S\} \notin RE$ it says that $\emptyset\in S$ is not a sufficient condition, i.e $L_S \notin RE$ doesn't yield $\emptyset \in S$, by giving the counter example $L_{\...
I have a vague understanding that a (sane) programming language is RE as they are Turing-complete, being able to describe any Turing machine. But I cannot pinpoint what aspect makes a programming language RE, not context-sensitive. For example, I'm guessing the variables in any scope structures like for can be describe...
A property $P$ is simply a set of sequences of states and a certain program is characterized by its set of sequences of states, let's call it $T$. A program is compliant to a specific property P if $T\subseteq P$. Intuitively, a specific liveness property LP1 is the set of traces (sequences of states ) in each of which...
So, I came up with a DFA for the regular expression. Now for every string described by the regular expression, the DFA accepts it. But in order to ascertain if it's really a DFA for the regex, you also need to know whether the reverse is true or not. Which is to say that the set of strings accepted by the DFA is descri...
If i take a safety property $SP$ and a liveness property $LP$, is it true that the result of their intersection is a safety property (and not a liveness property) ? Why ? Thanks
My answer is constant time O(1) since an implementation would naturally have the pointer to the root. However, the solution guide I am looking at argues it is O(logN).
The "Computational Component" section of the Type Theory - Wikipedia (as well as a few papers about cubical type theory and 2d type theory) talk about canonicity property. Would you please explain exactly what this property is and what does it mean in type theory? Why and how is it lost in the Homotopy Type Theory wi...
When defining $\Sigma_i^P$ or $\Pi_i^P$ completeness, we want to use a reduction that fulfills the following property: If $L' \leq_p L$ and $L \in \Sigma_i^P$ or $\Pi_i^P$ respectively, then $L'$ is also $\Sigma_i^P$ or $\Pi_i^P$. I can see how Karp-reductions fulfill this requirement for the complexity class $P$. How...
We have a graph G of treewidth $\operatorname{tw}(G)\leq k$, for some $k\in\mathbb{N}$. I've seen a claim that that implies that the clique-width of the same graph is at most $k \cdot 2^k$. This implies that given a tree decomposition of the graph we can construct a proper expression tree using at most $k \cdot 2^k$ la...
For optimization purposes I'm trying to analyze a large list of executed program commands to find chunks of commands that are executed over and over again. This problem is similar to searching repeated substrings in a string. However, in my case I'm not looking for the longest substrings but rather smaller substrings t...
I was thinking that if they were equal, say they are required to be zero this would be enforce the balance property more effectively. Can anyone explain why 1 is a satisfactory rather than just them being 0?
Given a string s, return the last substring of s in lexicographical order. Example 1: Input: "abab" Output: "bab" Explanation: The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab". More specifically, I am looking for an accompanying proof/intuition. I...
Lets say we consider the Erdős-Renyi undirected random graph $G(n,p)$ with $V(G) = \{1,2,\cdots,n\}$ and $\displaystyle{P((u,v)\in E(G)) = p} \quad \forall u,v \in V $. Is there anything we can say about the probability of the $G$ containing a $HAM$ Cycle? This seems like a helpful quantity to figure out for certain co...
I came across this description of Batch Interface: "commands and directives are used to manage those commands that are entered into files and those files get executed. " I would really appreciate if someone explains in detail what Batch Interface is and how it's different from Command Line Interface?
I met a wired question from the algorithm test of my school. For the first time I thought it is a normal quick-sort problem and feel confident to solve it but as I read the algorithm carefully, it is a little different from the quick sort algorithm... The original algorithm and question are: QUICKSORT(A, p, r) 1 if p ...
I have a problem which requires ordering nodes in a graph based on some given statistics. However, the given statistics of each node may be very hard to compute. Thus, I will use some sampling techniques to compute approximate statistics for each node. With more samples, the approximate estimated statistics will be mor...
How can I compute the minimum time for two points to meet in $O(N)$ time? All I can think is to compute the time for all the point pairs and get the minimum. Can anyone give me some hints?
Let $G$ be an arbitrary directed graph. Does $G$ always have the same strongly connected components on $G$ as on $G^*$? Here, $G^*$ is the inverted graph of $G$ (i.e., $(u,v)\in E \rightarrow (v,u) \in E^*$). I'm thinking yes because otherwise the algorithm of Kosaraju would not work at all? But do not have another exp...
What is the best approximation for odd cycle transversal? (on general graphs) Sorry if this is easily found everything I found about odd cycles is about paramaterized complexity and kernels
In "Computational Complexity, A modern approach", Arora & Barak proof the following claim (Claim 5.11.2): Suppose that $\mathsf{NTIME}(n) \subseteq \mathsf{DTIME}(n^{1.2})$. Then $\Sigma_2$-$\mathsf{TIME}(n^{8}) \subseteq \mathsf{NTIME}(n^{9.6})$, which they prove in the following way: If $L \in \Sigma_2$-$\mathsf{...
The problem I want to solve is this: Given a list $A$ of $n$ elements, I want to verify that they are all distinct. If I were to do this "myself", I would need $O(n)$ space and $O(n\log n)$ time to solve it, e.g. via a hashmap or binary tree. Luckily, I have an untrustworthy but omnipotent oracle ally who is willing to...
I am currently learning the pumping lemma, and encountered the following question, which I am unable to solve: Prove that $L = \{ 0^n \mid \text{$n$ is power of 2}\}$ is not regular. I considered $w = 0^{2^n}$, where $n$ is the pumping lemma constant. Then I divided $w$ into $xyz$, where $y \ne \epsilon$ and $|xy| \l...
How do you evaluate how many times some loops will run, when you start to complicate the boundaries conditions? For example, take this function: def f(n): s = 0 for i in range(n): for j in range(i, (n + i**2) // (n - i) + 1): s += 1 return s for i in range(10): print(i, "->", f(i)) ...
I was watching a lecture video and the Professor states that it would be very rare to see the order of a Btree to be even. I was hoping for an explanation but he cut it off there and moved on with the lecture.
I'm just getting started with learning about K-nearest neighbor and am having a hard time understanding why standardization is required. Reading through, I came across a section saying When independent variables in training data are measured in different units, it is important to standardize variables before calcula...
I have some basic confusions about the definition of the guarded fragment of first-order logic. Hopefully someone can tell me where I'm wrong. GF in FO is defined by: Atomic formulas, $x=y$ and $R(x_1,...,x_n)$, are guarded formulas. If $\phi,\psi$ are guarded formulas, so are $\neg \phi$ and $\phi \wedge \psi$. For v...
Let's say that a set of natural numbers $S \subseteq \mathbb{N}$ is primitive recursively enumerable if there exists some primitive recursive function $f$ such that $S$ is the range of $f$. That is, we can enumerate $S$ by calculating $\{f(0), f(1) \ldots \}$. What is known about this class of sets? Where does it stand...
Given a set $S$ of line segments (possibly sharing endpoints) and a query point $q$, how fast can we find the closest visible endpoint from $q$? If $p$ is the closest visible endpoint to $q$, then, in this case, it means that the line segment $pq$ does not intersect with any other line segment in $S$. I am trying to im...
I have a solution to the following problem: Given a stairway of $n$ stairs, which you can climb from $1$ to $m$ at the time ($1 \leq m \leq n$), return all the ways you can climb the stairway. E.g. for $n = 3$, $m = 2$, the possible ways to climb are $[2,1], [1,2], [1,1,1]$ // outputs all the ways to react total us...
Consider the algorithm LastMatch below, which returns the offset (shift) of the last occurrence of the pattern P in text T, or -1 if P does not occur in T: LastMatch(T,P) for(s = T.length - P.length downto 0) j = 1 while(j =< P.length and P[j] == T[s + j]) j++ if(j == P.length + 1) return s return ...
Let Fact be the following decision problem. Given two natural numbers $k \le n$ the machine accepts if and only if $n$ has a non-trivial divisor that is less than or equal to $k$. Prove that if Fact $\in$ P then there is an algorithm that given $n$, it produces its decomposition into prime factors in polynomial time in...