instruction
stringlengths
35
29.1k
On the website for the book Modern Compiler Design, it is claimed that: [The book] recognizes lexical analysis, LR parsing and BURS code generation as instances of bottom-up pattern matching and explains them uniformly using dotted items, thus unifying three important techniques in compiler design, [...] (BURS seems ...
Below is the language, determine (R), (RE), (coRE). and prove your answer. $L=\{\langle M_1,M_2\rangle|M_1,M_2$ are Turing-machines and $L(M_1)\cap L(M_2)\neq \emptyset \}$ Attempt: I Think the language $L\in RE$ Because we need to use $U-MT$ such that we check all the $L(M_1)\cap L(M_2)\neq \emptyset$ to see if all l...
Are there any (deterministic or randomized) algorithms that run in time $\operatorname{poly}(n)\log^p{n}$ for $p < 0$? What are some examples?
I am a newbie to algorithm designing. I am working on user association and load balancing algorithm designing in millimeter wave wireless communications. In this topic I am able to formulate the problem, but my query is how does one decide the algorithm after completing problem formulation. Any help in this regard woul...
I am looking for an algorithm for the following problem: I have a set of users and a set of books. Every user has their own set of favorite books, which may be empty, and is a subset the set of books. We can assume that every book is a favorite book of at least one user. Ideally I want to distribute ONE book to every u...
I'm not sure if there's a name for this problem, but I'm hoping to validate my proposed solution or hear other ideas for solving it. This stems from a real engineering problem I've encountered at work, so a practical solution is preferred over a perfect one. The Problem I have an infinite queue of items $I = I_1, I_2, ...
Assume we have a balanced binary tree. On each node, we call: def node_depths(root, depth): if not root: return 0 return depth + node_depths(root.left, depth + 1) + \ node_depths(root.right, depth + 1) node_depths itself is O(n) time. But calling it on each node produces an O(nlogn) time algorith...
I need to solve an optimization problem for a given set of polyominoes, for example the five Tetrominoes known from Tetris. The goal is to place each one of the figures on the 2d grid, so the area they enclose is maximal. Staying with our Tetromino example, the optimal solution would be: Bruteforcing the problem becom...
Introduction Hi everyone, I am currently pondering how to efficiently design an algorithm for a sorting problem and hope that someone here may help me out a bit. The problem I have two lists of integers, let's call them the 'input' list and the 'position' list, and want to sort the 'input' list based on the position of...
I am using a Genetic Algorithm framework to solve a path-finding problem. Specifically, given the following 32x32 maze: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X | X X | X X | X X | G X X | ...
I want to ask about a turing-machine-like construct with an infinite number of states. in this post the claim is that every language is accepted: Can a Turing machine have infinite states? I understand that we can scan over the input from left to right once, and end up at a unique state for each possible input string. ...
We say that dfs runs in $O(n+m)$ . For any connected graph $m \geq n-1 $. Therefore : $$m \geq n-1 \implies O(n+m) = O(m)$$ Do you agree ? Because, I have seen in many algorithms proofs this bound $O(n+m)$ but most of the times we are dealing with connected graphs .
In essence, is kernel basically the code that implements a set of system calls?
I'm building an implementation of the dynamo paper, yottastore. Given a key, I need to find which NVMe block stores the data. To do that I hash the key to find the shard where I have an in memory array in which at position [hash] I can find a struct with: 32 bit hash (needed for resizing) 64 bit pointer to NVMe block ...
So in my attempt to convert the following DFA into a regular expression, I ended up with ((ba)*(ab(ab)*)*(aa(ba)*a)*)*. The exercise I'm following wants me to convert the DFA into a regular expression then describe its language in plain English, however, I can't seem to come up with anything for the converted expressio...
It is for me unclear how I can derive from a npda whether the lambda-transition means “I don’t care which symbol I read” or “I have read all the symbols”. For example, see the following automata: If I am correct, the red ones have the first meaning, and the green one the second. Maybe I totally misunderstood lambda-tr...
My problem is to build a machine that decide this language: {〈A, w〉| A is a DFA and w is the longest word in L(A)} I know that DFA has finite states and eventually for every word that i simulate on A ,i would get an answer (yes/no) and know if w is in L(A). In order to know if w is biggest can i build a TM M that Non d...
As the title says, I've developed my own algorithm that can do so, however mine would take 1-2 seconds searching through an array with 1 million length, however I am very curious if this can be made so much faster like 0.01s or even 0.001 is this mathematically impossible? I've used C++ with vectors and jsons to create...
Assume that I have a program Login.c that I have compiled with cc and generated the executable a.out. Now, along the questions posed from "Reflections of Trusting Trust", I want to check that a.out is the intended executable and nothing else, e.g. that there is no malfunction injected by the build system. There are tec...
The following statement seems trivial, but how can it be formally proven/argued? $$\bigcup_{s \in \delta_{N}^{*}\left(q_{0}, w\right)} \delta_{N}^{*}(s, a) \;\equiv\; \delta_{N}^{*}\left(q_{0}, w a\right)$$ In words: taking the union of the states when reading a symbol ‘a’ from all the possible states in a NFA having r...
Statement: Given any dfa $M$, application of the procedure 'reduce' (see below) yields another dfa $\hat{M}$ such that $M$ and $\hat{M}$ are equivalent. Furthermore $\hat{M}$ is minimal in the sense that there is no other dfa with a smaller number of states that also accepts $L(M)$ First some background information: Th...
I was wondering if there is an approach to sort the sums of k integers in a set of n integers; which would be a generalization of the x + y sorting problem. Or even without generating the whole set of k sums, would it be possible to generate de m largest k sums in a set of n non negative integers?
All British citizens are provided with a National Health Service (NHS) number either at birth or when they first register with an NHS doctor. According to the NHS Number wikipedia page, the 10 digit number contains a checksum digit, which is calculated using the following algorithm: The current system uses a ten-digit...
I am well aware that recursively enumerable sets (which are subsets of $\mathbb N$) are closed under intersection. What is more interesting is whether or not the cardinality of the intersection is computable/decidable? That is, given two recursively enumerable sets $A$, $B$, is $|A \cap B|$ always decidable/computable ...
In his Quantum Computing Since Democritus, Scott Aaronson outlined a proof sketch of Blum's Speedup Theorem which roughly looks like the following. Given an enumeration of Turing Machines $\{M\}_{i \in \mathbb{N}}$. Let $S_i = \{M_1, ..., M_i\}$. We can construct a computable function $f(n)$ such that if $f(n)$ can be ...
How can I prove this: f(n) = o(g(n)) if and only if f(n) = O(g(n)), but f(n) ≠ Θ(g(n)) ?
I have lived my academic career thinking these two terms were interchangeable but something arose in me that said they're distinct. Are there any logical, formal definitions distinguishing between the two?
I am going through the book "Network Flows" by Ahuja et al. In chapter 19.2 "MAXIMUM WEIGHT CLOSURE OF A GRAPH", I find this example of turning a vertex-weighted (positive or negative) digraph into a flow network. The min-cut in the flow network is supposed to correspond to a max-weight closure in the original graph. ...
Given a turing machine with some states, how can I recognize all halting states of that machine? I think that I should go over each state and check if there is a transition that is not defined for that state with one (or more) of the tape alphabet symbols (also containing the blank symbol). Would this be a good approac...
i have seen this question where someone was asking if $\{a,b,c\}^* \setminus \{a^nb^mc^k \mid n \leq m \leq k\}$ is context free. Then there was an answer that says that it is context free because: The language, in turn, is context-free. This is because we can write it as a union of context-free languages: Words not o...
Prove or disprove: deterministic Turing machine equivalence Nondeterministic Turing machine such that word accepts if and only if there are exactly 2 accepted paths and all the others reject or no stop. I know that need at least 1 accepted path to accepting a word in a nondeterministic turning machine. At first glance,...
Neural networks are good at image analysis. They are also being used in video games which could outperform professional human players. I wonder if they can also play a purely object-finding game where a player needs to find objects in a photo as shown in the picture.
There are many different general strategies when designing algorithms for a problem like divide and conquer, greedy, dynamic programming, etc. I understand that it is not always obvious which to use for a problem. However, I am at a complete loss as to how to even begin to make educated guesses. I assume intuition play...
Suppose I have an encrypted string of bytes. "T37mQkZosCsrcbqf/rvSWbd67qH3sXMggKdVd8fzMdg=" Suppose I know that somewhere in the original plain text string I know there is a string of numbers in ascii: "1234567" Is is realistically possible to figure out the encryption key, or the rest of the string with just this info...
I do have a seemingly fundamental question that I somehow struggle to intuitively make sense of. Setting: Let us consider a randomized algorithm $R$ that has $t$ steps. In each step, it is fed with random input data $(s_1,...s_t)$, where each $s_i$ is drawn from some exponentially large set (uniformly random). Moreover...
Please help me to find the Time Complexity of the recurrence relation $T(n)=4T(\frac{n}{2})+\frac{n^3}{log_2n}$ using iterative method.
I want to support two operations: Insert a (key, value) pair into the data structure in $O(\log n)$ time. The key can be assumed to be a unique integer. Given an integer query value $v$, I want to return the (key, value) pair $P$ such that the value of $P$ is as great as possible amongst all (key, value) pairs with ke...
I'm trying to use a VAE (CNN-VAE to be exact) to reduce the dimension of some images I have in a dataset. I successfully trained my VAE, but now I'm not sure of the latent variable to return. Should I use $\mu$, $\sigma^2$, or $z$ (which is sampled from $\mu$ and $\sigma^2$) ? Thank you in advance for the advice. Liam...
Usually LRU cache is implemented with double linked list to fast remove oldest visited, push to front, and move from any place to front; also uses map to fast find element by key. In 64bit systems pointers are wide, and cache has large overhead, especially if key is long and value short. I have tested in C++ with key a...
Given a $n \times m$ rectangular grid of cells each with an integral weight: $w_{i,j}$ and two integer parameters $w \ge 2$ and $h \ge 2$ (for group width and height respectively). Select the subset of cells that maximizes the combined weight of the selected cells and is constrained such that each selected cell is a pa...
The task is to "Show that the transformation f -> ((ln fx)x, (ln fy)y) is invariant under additive and multiplicative illumination changes." From my lecture notes, for ((ln f)x, (ln f)y), I have: ln (c*f(x,y)) = ln c + ln f(x,y)x = (ln c)x + (ln f(x, y))x with the note that the first term is 0 if c is global and theref...
I'm a SW engineer. I'm just curious why computers become slow over time. "Slow" here I mean from a usual user PoV: It takes more time to launch an application. Application UI takes longer to respond user interactions. Sometimes even freeze and unresponsive. Playing video files on local HDD becomes noncontinuous. Somet...
Suppose given the recurrence $$T(n)=T(\frac{n}{2})+\frac{n}{\log n}.$$ I think the answer is $$T(n)=O\left(\frac{n}{\log n}\right).$$ because $$T(n)=T(1)+\sum_{i=0}^{\log n-1} \frac{n}{2^i(\log n-i)}$$ but how we can show that $\sum_{i=0}^{\log n-1} \frac{n}{2^i(\log n-i}=O\left(\frac{n}{\log n}\right)$?
Following up on these two posts Generalised 3SUM (k-SUM) problem? https://people.csail.mit.edu/virgi/6.s078/lecture9.pdf The claim is that k-sum in the general case can be solved in $O(n^{k/2}log(n))$ However, I don't follow this claim. The quote reads For even : Compute a sorted list of all sums of /2 input elements...
I was going through Distributed Systems by Maarten van Steen & Andrew S. Tanenbaum. While going through size scalability of systems, I came across this in a note. I want to know the derivation of this formula. Also, for $\left ( 1 -\frac{\lambda }{\mu} \right )$ to be greater than zero, $\lambda$ should be less than...
Given a list of lists containing tuples in sorted(by day) order find and print the total number of stock units owned for every day that occurs at least once. #first number in each tuple represents a day, second number represents how many units of that stock is owned. #if a day is missing, you can assume the stock valu...
Is $n=\Theta(n^{1+o(1)})$? To me it appears to be true as $n$ tends to infinity $n^{o(1)} =0$.
Suppose I have two LR(1) languages $L_1$, $L_2$. Is $L_1 L_2$ (their concatenation) guaranteed to also be LR(1)? References to proofs would be very helpful.
I know computability, but not model theory and logic, so this question may be naive or confused in that respect. A blog post of Scott Aaronson mentions a Turing Machine $M^*$ such that the statement P: \begin{align} &\text{$M^*$ runs forever on a blank tape} & (P) \end{align} can be proven in ZFC+large cardinal assumpt...
Suppose I have two LR(1) languages $L_1$, $L_2$. Is $L_1 \cup L_2$ also LR(1)? References to proofs would be very helpful.
For any directed/undirected labelled graph G := (V,E,L), where L is the finite set of labels, and every edge has a label. For simplicity, let us assume that L = {a,b}. Is there a P-time algorithm to determine whether all possible cycles passing through a vertex "v" has at least one edge (every cycle) with label "a"? We...
I am wondering if there are known to be any EXPTIME-complete problems (or even just problems in EXPTIME) which are known to also be in IP, so a prover can convince a verifier that an answer to an EXPTIME problem is say "yes" in polynomial time? Although this seems like a natural question that maybe is solved, if the a...
I know that this kind of question has been asked before, but I still see different kind of answers getting multiple upvotes, but I am not sure if they are all correct. That’s why I wanted to ask it again. I will put some answers that I have read and their difference in this question. So my question: For a language $L$ ...
In the book Formal languages and automata by Peter Linz, 4th edition (Jones & Bartlett Learning), on pages 300-301, there is a proof for the fact that the halting problem is undecidable. The proof is as follows: We show that there is no TM $H$ that solves the halting problem. Assume there is a TM $H$ that solves the h...
I want to know how hardwares write a byte in memory? If there is difference between writing process in RAM and ROM I would like to know as well. Specially I want to know: Is hardware writes values bit by bit? (I mean like writing first bit then go to next) Is there a header that move around and change bit by bit? If n...
I have different time intervals (contains partial or full overlaps). I provided the sample input and output so that it would be easy to understand. Sample Input-1: [1-5, 2-3, 3-5, 3-5, 3-6] Sample Output-1: [(1-2):1, (2-3):2, (3-5):4, (5-6):1] The above output informs that, for the interval (1-2), there is only one int...
Lets say the alphabet is Σ=∅,what are the possible languages of this alphabet? According to my definitions: I know that an alphabet is a finite set of symbols Σ I know words is a set of all finite symbols consisting of letters from the alphabet (Σ*) and an empty string part of all words ε ∈ Σ* I know that a language i...
Could we say that Dynamic programming is nothing but recursion + Memoization? Although the formal definition of dynamic programming is that the problem should have an optimal substructure property, which in a way is nothing else but recursion.
In the Introduction to Algorithms Book By Thomas H. Cormen, Third Edition, they give an approximation algorithm for the Vertex Cover Problem with 2-approximation ratio: Where G is undirected graph. The complexity of this algorithm is O(V+E). I do not know why. It should be O(E) since the while loop in line 3 clearly w...
Question Let $L$ be a regular language. Let's say we sort $L$ by length and then lexicographically; then let $L_p \subset L$ be every $p$th word in $L$ according to this sort. Is $L_p$ regular as well? Example For example, let's use $L = a^*b^* = \{\epsilon, a, b, aa, ab, bb, aaa, aab, abb, ...\}$. Then $L_2 = \{\epsil...
The right answer is Theta(n log logn). But, can someone explain why it is the case? I know intuitively that it is because k is k^2 each time, so it couldn't be (logn) for the second loop. However, what is the actual mathematical analysis that makes it (log logn)?
Suppose I have the mesh of an geometrical object (Interval in 1d, Region in 2d, Volume in 3d). How can I find out whether a point lies on its boundary or not? I am looking for algorithms with explanations. Any resource would also be appreciated.
Given two binary matrices of the same size with the same element counts, how can we find a map mapping ones to ones such that the sum of differences of distances of all pairs of neighbors is minimised, where the distance of each cell is the number of steps it needs to walk horizontally, vertically or diagonally to reac...
Let L be a regular language. Then there exists a regular expression r such that L = L(r). Proof for NFAs with only 2 states (can be generalized!), partly seen during a lecture and completed by me: Let $M=\left(Q, \sigma, \delta, q_0, F\right)$ be an nfa that accepts $L$ The nfa $M$ has only two states $q_0$ and $q_1$ w...
i want to show that for all $CFL$ and not $REG$ languages $L \subseteq \{0,1\}^*$ exists $L_1,L_2\subseteq\{0,1\}^*$ with: $L_1$ is $REG$ $L_2$ is $CFL$ and not $REG$ $L_1 \subseteq L_2 $ $L \subseteq L_2 $ and $L \neq L_2$ I struggle at showing it for all $L$. What I did so far is some kind of a little sketch. Let ...
I know that to illustrate speed-up advantage of Grover's algorithm we can apply "square root": if the brute force search takes 100 hours, Grover's quantum search algorithm should take about 10 hours. What would be similar numbers for Shor's algorithm for, say, 10-digit numbers?
Given a real matrix $M \in \mathbb{R}^{n \times m}$ and a vector $v \in \mathbb{R}^{n}$ I would like to find an element $x \in \mathbb{R}^m$ such that $v - Mx$ has maximum number of zeros. If the matrix $M$ has rank $n$ then it is easy to find some $x$ where $xM = v$. But in the case where $m<n$ the best I can think ri...
Issue: I am having a hard time figuring out how to use the worst case for Rolling Hash, especially if the occurrences are only "a and b" for the string. Not only that but it is a bit of a hassle to figure out the process if the pattern that we tried to find from the given string will only contain one character occurren...
I'm implementing a q-learning agent for tic-tac-toe that requires mapping from tic-tac-toe boards to float values. Since certain game states are equivalent and should have the same value, it would be more efficient to store all games that are mirrors or $90^{\circ}$ rotations of each other, only once. Is there an algor...
I recently saw this answer on a question in the Quantum Computing SE. The answer demonstrated how we can probabilistically find the answer to the Deutsch Jozsa problem on a PTM in $O(1)$ time, with an error of $\frac{1}{2^k}$, where k is the number of entries we check. I will provide an algorithm and proof of why (to m...
Let $n\in\mathbb N$. Given a set $S\subset\mathbb N$, let $\Delta(S) = \{a-b\mid a,b\in S\}$ denote its set of differences. I'm interested in finding a small set $S_n$ such that $\{1,\ldots,n\}\subseteq\Delta(S_n)$. For example, if $n=8$ we can use $$S_8 =\{1,2,4,8,9\}. $$ How can we construct a small $S_n$ efficientl...
I am enrolled in the Algorithmic Toolbox course on Coursera, and as apart of the first week that are walking us through how to implement algorithms. But I am having trouble understanding the symbol and wording that they are using. This is an example of the psuedocode: StressTest(N ,M): while true: n ← random integer be...
Consider the problem of tiling a rectangular region with a given set of Wang tiles. It is well-known that this problem is NP-complete: every NP problem can be encoded as some form of tiling problem (see e.g. here). It is also well-known that there are particular sets of tiles that only tile the plane aperiodically. The...
I realize this is sort of a trivial ask, but I want to make sure I understand OWFs and it's usually explained with some jargon that I don't find clarifying. So, I'd just like to know whether or not my understanding of one-way functions is "essentially correct": $f$ is a one-way function iff it can convert $n$ input bi...
Let $G(V,E), |V| = n, $ be a (undirected) graph and a coloring function $f: V\rightarrow \{1,2,3...s \}$ which assigns to each vertex a color, such that in total there are $n/s$ vertices of each of the $s$ colors. Starting from a given vertex $a$, the task is to find out if there is a path in the graph, such that it co...
I have an image with a list of segmentation polygons. Getting the bounding box with the polygons is easy enough. I used the bounding box to crop out the objects of interest. Now, I want to scale the polygons so that they wrap around the cropped object. I scaled the polygons using the ratio of the original image size to...
$\require{enclose}$ Definition of parent For any three strings $x$, $y$, and $p$, we say that $p$ is a parent of $x$ and $y$ if and only if all of the following: $p$ is a $\enclose{updiagonalstrike, downdiagonalstrike}{\text{substring}}$ sub-sequence of some permutation of the concatenation of $x$ and $y$. $x$ is a $\...
Before I even attempt coming up with an efficient algorithm, I tried googling for similar problems but didn't get far, most queries mentioning "sets" in them led to some sort of Multiple subset sum or other subset construction problem. What I'm looking for is quite literally the opposite. The problem is very straightfo...
I am struggling to understand the difference between the notions $P, NP, NP-$complete, $NP-$hard. Let's take the example of the $NP-$class. We say that these problems are solved in non-polynomial time, i.e. they have an exponential time complexity, while at the same time we say that they are verified in polynomial time...
I am unsure if it has infinite equivalence classes or not, respectively how to interpret the textbook solution. My approach was that it has infinite because, lets say we have $x = a^5$ and $y = a^7$. If we append them with $aa$ then $x = a^7$ and thus $x \notin L$ and $y = a^9$ and thus $y \in L$. Because $9$ is a squa...
Given an array of N integers, there may be a need to perform q queries. A query could be like determining the number of values that are less than an integer k. Which data structure could be used to minimize Time Complexity? My Thoughts: One easy way could be to keep the numbers sorted. And then, for each query, we just...
Given $n$ distinct sets $S_1, S_2, \cdots, S_n$, how to find a set $X$ such that $X \cap S_1, X \cap S_2, \cdots, X \cap S_n$ are still distinct, and the size of $X$ is minimum? For example, given $\{1, 2\}, \{1, 3\}, \{2, 3\}$, let $X=\{1, 2\}$, then the intersections are $\{1, 2\}, \{1\}, \{2\}$, which are still diff...
Hello I am trying to solve this recurrence equation using the recursion tree method: T (n) = T (n −1) + n^2 In particular, what is big-O of T (n)? Here is what I have done so far: I am not sure if I drew the tree correctly, and I don't know how to figure out the runtime. If someone could draw out the tree, and explain...
Update: To clarify. MyNOR (http://mynor.org/) stores some combined instructions in ROM to make programs take up less space. It seems very possible that instruction sets for CPUs might do similar, in more normal computers. I was interested if such load as part of some operative system/kernel/whatever it is called, or is...
Why is Solution 1 faster than Solution 2? The input passed to both solutions: let myArraySortedSquares = Array(stride(from: -100000, through: 100000, by: 1)).shuffled() Solution 1 with O(nlog(n)) time complexity and O(n) time complexity Time elapsed: 2.76 s. // Time: O(nlog(n)) | Space O(n) func sortedSquaredArray_sol...
My book Sebasta's Concepts of Programming Language (Chapter 1) states: Orthogonality in a programming language means that a relatively small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the language. Furthermore, every possible combinat...
if we define halting problem as follows $ \begin{align*} h(m,n) &= \begin{cases} 1 & \text{if program $m$ halts on input $n$} \\ 0 & \text{otherwise} \\ \end{cases} \end{align*} $ and we have two sometimes correct solutions $f$ and $g$ for $h$ that are always correct if they agree but fails to agree ...
I have some algorithmic complexity estimates in Giga Operations Per Second (GOPS) and I would like to compare those with the capabilities of state-of-the-art processors. However, the processor performance is commonly measured in FLOPS. According to this (Eq.4) FLOPS_core = OPS * FLOPs/operation What would be a reasona...
Let's say there are four sets containing integers. No set has any duplicates within itself, but duplicates exist across sets. A = [1, 2, 3, 4] B = [2, 3, 4, 5] C = [3, 4, 5, 6] D = [4, 5, 6, 7] The goal is to store each unique element in a resulting set R. The naïve single-threaded solution would be to iterate over ea...
As part of pre-processing my (very large) directed acyclic graph, I want to eliminate as many unnecessary edges as possible. By "unnecessary" I mean an edge that could be absent from the transitive reduction of the graph. For example, in the graph {(1 -> 2), (2 -> 3), (1 -> 3)}, edge (1 -> 3) is considered unnecessary....
Wikipedia defines range of data type: the set of possible values that that variable can hold. Suppose we have two data types A and B. Now, with attention to the definition of widening in section 7.4 of Concepts of Programming Languages, we can say: range of B is larger than A when range of B includes at least ap...
I am trying to understand what the time complexity for an autocomplete function for a Trie-based dictionary would be. Every node contains a letter and whether it is the last letter of a word, and if so, how frequently it shows up in the english language. From my understanding, if we have a Trie (prefix tree), and we se...
In the PBFT paper written by Miguel Castro it has been mentioned: (In Abstract:) "BFT has been implemented as a generic program library with a simple interface." (Also in page 71:) "The algorithm has been implemented as a generic program library with a simple interface. Thelibrary can be used to provide Byzantine-fa...
This is a pretty vague question and can be applied to many math problems not just recurrence relations. Above I fully understand, setting up the recurrence relation from the algorithm given. And how the next step would be plugging and chugging to find a pattern that we can use. So as shown above, we do not know what ...
Consider an array A[1..n] that first increases up to some point p then it decreases until some point q and then increases again. That is A[k] < A[k + 1] for all k in [1..p] and [q..n] and A[k] > A[k + 1] if p < k < q. Suppose we are searching for the element A[p] or the index p, whats the fastest possible algorithms M...
Prove or give a counterexample: for every function f from non-negative integers to non-negative reals, o(f) = O(f) − Θ(f). Here “−” denotes the set minus operation. I try to make some tryout but failed to make the abstract function f to into working, can someone give me some Hints or solutions?
When I was trying to solve a problem, I met another problem like this: Given a undirected connected graph $G=(V,E)(|V|\le100)$ and some subgraphs of $G$: $G_1,G_2,\cdots,G_n(n\le 32)$, and all $G_i$ is connected and include all the vertexs in $G$. We need to cut some edges in $G$ so that neither of the subgraphs $G_1,G...
I need to propose an algorithm for a NP-hard problem. I use dynamic programming which leads to a running time $O(2^s\cdot n^2), s\leq n.$ The algorithm aims to finding a path in a graph $G(V, E)$ (in which each of the n nodes is colored in one of the $s$ colors) containing all the $s$ colors which are represented a sin...
Let's say I have a 60 set of numbers from 0-100,000 so like [81, 98, 115, 189, 254, ... , 97866, 98441, 99671] all unique and progressively increasing. Would it be mathematically possible to compress this sequence by 80-90%? so far I've tried gzip which only compresses at 50% and other algorithms the best one I found w...
What is the asymptotic of ${n \choose 3} \log ^4n$ ? I know that ${n \choose 3}$ is in $\cal O (n^3)$, but what about the term $log^4n$ and what about the product of the two?