instruction stringlengths 35 29.1k |
|---|
I don't know which algorithm is more efficient for sorting, but I want to use Bubble sort and how to implement this algorithm.
|
I'm looking for an algorithm to solve a modified version of the assignment problem. It differs from the standard assignment problem in that the modified version has groups of tasks instead of just tasks. Similarly to the standard problem, each of the n workers is assigned one task, and there are n groups of tasks; but ... |
We have an array of integers of length N(even). A and B play a game where A selects a number followed by B without replacement until the array becomes empty(Both A and B select N/2 elements each). The goal is for A to have a sum (of the N/2 elements A chooses) which is (i) even, (ii) odd. In both cases, B plays against... |
I am trying to analyze the algorithm Product: multiply two n-bits binary numbers x and y.
function Product(x, y);
1. prod = 0;
2. while y not eq 0
3. y = y -1;
4. prod = prod + x;
return prod;
Assume: n = |x| = |y|
Give the worst case time T(n) function for algorithm Product.
Express T(n) in terms of... |
A simple question, but I can't find an answer in quite the form I'm looking for:
Assume $\mathsf{P} \neq \mathsf{NP}$, and thus $\mathsf{P} \subsetneq \mathsf{NP}$. If we have $L \in \mathsf{NP}$ and $L \notin \mathsf{P}$, does that imply that there is no algorithm for $L$ which runs in $O(n^k)$ steps for all inputs of... |
I've been struggling with this analysis of algorithms notion for a few hours now in an introductory course. Let us define a function $N(n)$ for positive integer $n$ as the number of times performing $n=log_7(n)$ yields $\leq 1$. So $N(1)=0, N(7)=1, N(7^7)=2$, et cetera.
I'm asked to find a good algorithm for computing ... |
It's often said that State Machine Replication and Byzantine broadcast are equivalent (e.g., the abstract of [1]), but it seems only obvious how to reduce SMR to BB. I.e., give BB one can construct an SMR by rotating the leader.
What does it even mean to reduce BB to SMR then? In SMR, there are clients and servers, but... |
Let's say that we have a regular language $L_1$ that is described by a right regular grammar. Now, assume we have a left regular grammar, can we describe the same language $L_1$ or would the left regular grammar produce the reverse of all strings present in $L_1$?
My understanding is that the left regular language woul... |
In Meijer, Fokkinga and Patersons "Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire" the ∇ operator for sum types is introduced which removes the tags from its argument:
∇ _|_ = _|_
∇ (i, x) = x
What is the type of this operator? Something like
A|B -> A U B
?
As the article is recommended on the ... |
I'm reading some old notes from a course on Turing Machines and I've bumped into the following question:
Is the following language decidable? The language formed by the set of all Turing Machines whose languages can be accepted by a Turing Machine with at most 37 states
My assumption is that the question boils to whe... |
I have just started learning about CSP and NLP, for which I have to write a review paper of some research articles.
The problem is that when a searched for research articles on some trusted digital libraries with the keywords CSP and NLP, there weren't many results that were related to both.
Do you have any idea on whe... |
The problem is whether a graph (which we represent as a flow network) has a single min-cut, or there could be multiple min cuts with the same maximum flow value, I've yet to encounter a well explained algorithm for solving this problem, let alone a complexity anaylsis or proof.
I was not able to find the exact resource... |
Say there was a decision problem which was solved optimally in polynomial time on a non-deterministic Turing machine, and verifiable in polynomial time on a deterministic TM, but would not halt when being solved optimally on a DTM. Would that problem be in NP, or is solution decidability on both NDTMs and DTMs a requir... |
Pumping Lemma for Regular Languages
Pumping Lemma for Regular Languages: If $A$ is a regular language, then there is a number $p$ ( the pumping length ) where if $s$ is any string in $A$ of length atleast $p$, then $s$ may be divided into three pieces, $s=xy$, satisfying the following conditions:
$for \ each \ i>=xy^i... |
This is a question in my text book that I cannot understand the solution provided for that:
In each case below, give a simple descreption of the smallest set of languages that contains all the "basic" languages $\varnothing$,$\{\Lambda\}$, and $\{\sigma\}$ (for every $\sigma \in \Sigma$) and is closed under the specefi... |
In the book Artificial Intelligence a Modern Approach 4th edition, the author claims that the A* algorithm is cost-optimal if the heuristic function is admissible (never overestimates the remaining true cost).
Additionally, if the heuristic is consistent (obeying the triangle inequality by using a neighboring node), th... |
Let's say that we have a context free grammar G, which is not in chomsky normal form, and we need to convert it to chomsky normal form.
The steps involved in the conversion are as follows:
Add a new start variable and point it to the old start variable
Remove all of the empty rules, except for the empty rule where the... |
I have x and y values to plot the curve and I need to find a tangent line of slope 1 that intersects the curve and the point at which it intersects. I was trying to do polynomial and exponential regression to model the data (>6000 data points) and fit the curve in R but cannot get it to work. It fits a majority of the ... |
So in my "Advanced algorithms" course, we were taught about the "self-organizing list" data structure. The professor showed the following three heuristic algorithms: Frequency Count, Move to Front and Transpose.
Looking online, I could not find any other "popular", "common" or "used" heuristic algorithms. Are there any... |
Let $n$ be the number of variables in the input formula and $m$ the number of clauses. Define $s_k = \inf\{\delta : k\text{-SAT can be solved in } 2^{\delta n} \text{ time}\}$. The strong exponential time hypothesis says that $\lim \limits_{k \to \infty} s_k=1$. I have two questions here:
What if the input size is ver... |
Let's say we've got $n$ numbers to multiply together. But the multiplication operation, like in computer floating-point arithmetics, is not associative. Thus the order of multiplication matters.
Furthermore let's say that we want to minimize the nesting of the expression tree that represents the entire multiplication, ... |
Usually, in bin-packing, we have objects of sizes $a_1,...a_n$, and each bin has size 1, We need to minimize the number of bins, and for this, there are best fit/first-fit approximation algorithms.
What will happen if there are more parameters than just size, say 3 parameters? Each object $i$ has say parameters $(a_i,b... |
Given a fixed number of infinite-capacity containers and a list of items of varying weights, how can I best place the items into the containers preserving their original order in a way that minimises the difference between the heaviest and lightest containers?
For example, given 3 containers and 10 items with weights [... |
For example, 5 can be written in 2 ways:
4 + 1
3 + 2
8 can be written in 5 ways:
7+1
6+2
5+3
5+2+1
4+3+1
How could this be determined for any positive integer N?
|
I have a file with trillions of numbers and I want to get all numbers that have a frequency <=100. These numbers are in text format (UInt8s) so I first have to parse them. As this is slower than reading the bytes to a buffer I have one thread reading the data and 80 threads processing the bytes.
I could give each threa... |
What is the algorithm's computational complexity for a variant of the Travelling Salesman Problem, where every node must be visited at least once, meaning that a node can be visited more than once? (The cycle starts from a specific node and, after passing all nodes (at least once) returns to the start node).
The graph ... |
Suppose $K=a_1<a_2<\dots<a_n$ be a set $n$ distinct keys that inserted into an AVL tree $T$. The probability of any permutation of the order of insertion of the sequence $K$ is equal. Also we first insert $a_{40}$ into $T$, how I can find the probability, $a_4$ be ancestor of $a_9$ or $a_9$ be ancestor of $a_4$?
Anyon... |
Is $Union = NP\cup co-NP$ closed under polynomial-time many-one reductions?
I understand that in order to be so, for $A\in Union, A \leq_P B $ there should exist a polynomial time computable function $f$ such that:
$x\in A \implies f(x) \in B$. So the function computed for an input from $Union$ is also in $Union$. It l... |
I came across this pair of blog posts explaining the problem with calculating variance on floating point data:
https://jvns.ca/blog/2023/01/13/examples-of-floating-point-problems/#example-3-a-variance-calculation-gone-wrong
https://jonisalonen.com/2013/deriving-welfords-method-for-computing-variance/
They show that a t... |
I’ve searched for a solution for this problem for some time now, it is out of an algorithm question sheet.
We know that in order to find the minimal amount of edges in a flow graph’s min-cut we need to find the maximal flow, $c_o$,set the capacity of the edges of the min-cut to $1$ and for for the rest $e\in E$ set $c(... |
I was studying algorithms, and that problem below came up.
Write an efficient algorith that calculates the biggest single positive forward change in value given the values.
There is a second image with some pseudo code with the resolution, I think. But I couldn't even understand it as well.
What does the problem mean... |
Kolmogorov said "It seems natural to call a chain random if it cannot be written down in a more condensed form, i.e., if the shortest program for generating it is as long as the chain itself. " So for example (in bits & bytes):-
$$ K(\text{a thousand zeros}) \approx \log_2(1000) \text{bits} $$
$$ K(\text{Shakespeare's... |
I am considering multivariate polynomials with integer coefficients that can be expressed as sums of products of terms of the form $y_i-z_j$ for positive integers $i$ and $j$. I am trying to find an algorithm to determine if there is a way to express them in terms of these linear factors in such a way that the terms ha... |
In Wikipedia I found out that the formal grammar of $\lambda$-calculus is the following:
<λexp> ::= <var>
| λ<var> . <λexp>
| ( <λexp> <λexp> )
Then, a few lines later they say that this is a valid $\lambda$-expression:
$$\lambda x.x^{2}+2$$
How does one matches with the other? Where is the "+" operator in the for... |
We have a graph where we want to get from node u to v in the shortest path possible.
I understand how Bellman-Ford works when we have exactly i edges to go from u to v or at most i edges to get from u to v. But how does this work when you have to go from u to v with at least k number of edges?
Is this a simple variatio... |
In the Church-Turing thesis Wiki page, there are a set of descriptions of the "behavior of a computor—`a human computing agent who proceeds mechanically'". I am content with all of them, except:
(L.2) (Locality) A computor can shift attention from one symbolic configuration to another one, but the new observed configu... |
Suppose we have an undirected graph $G=(V,E)$ and and it's Maximal spanning tree $T=(V,F)$ such that the edges in $F$ is the heaviest subset of edges $E$ from which you can create a spanning tree.
We're required to prove that for all $(u,v)\in V$, the bottleneck in the path $P(u,v)$ in $T$ is the heaviest bottleneck am... |
Is it true that there is no known succinct data structure that has integer array (vector) functionality? Desirable operations would be:
append O(1)
access(i) - returns i-th item O(1)
iterate(i..j) - i.e. iterate from i to j efficiently O(j-i)
The emphasis is on integer arrays and O(1). A structure that divides the ar... |
###################
# create_slider() #
###################
def create_slider(self, t0, t1):
# adjust the main plot to make room for the sliders
plt.subplots_adjust(bottom=0.25)
slider = Slider(
# left botm w h
ax = plt.axes([0.25, 0.1, 0.65, 0.03]),
... |
I'm trying to recreate the RSA key generator, from what I understood you must create two prime numbers of 256 bytes long, p and q. Since there really isn't a method able to generate prime numbers, you must generate random numbers so then you can test their primality using an algorithm.
Here is where the Rabin-Miller's ... |
I came a across a question where there were some statements made on Finite Automata, DFA and their states.
One such statements in the question was that a "Every DFA accepting a finite language must contain a dead state"
And the answer stated the statement to be true, and showed some DFA where there was a dead state fol... |
Turing Machines can be used to compute functions.
For example f(x)=x-1.
0011 is on the tape. Turing Machine computes for some time and finishes in accept state. On the tape, we see: _00_10_. Where _ is a blank symbol. Is it correct? Meaning 0011 == _00_10_.
For exaple in Python: [] + [1] + [] + [2] + [] == [1,2] is Tru... |
There are various meta-learning algorithms in RL that are proposed for settings when we have a (deep) neural network and the policy (or the value function) are parameterized as such.
Can these methods be applied to tabular cases? For instance by following the steps of algorithm 3 in the MAML paper (https://arxiv.org/pd... |
It is known that $QSAT$ is $PSPACE$ complete, and it is known that $QSAT_i$ is $\Sigma_i$ complete for any constant $i$. However, what if we had $QSAT_{\log n}$? That is, $QSAT$ where the quantifiers can alternate $\omega(1)$ times, but still $o(n)$. Would this be enough to make the problem $PSPACE$ complete, or are al... |
I am currently learning about how the compilation and linking works in C++. I think I kinda get how the compiler works, and that for a file to fully compile you don't need to have function implementations, but only declarations. It is the linker's job to link the function declaration to its implementation.
But now I ha... |
I know that Busy Beaver problem can be used to illustrate the Halting Problem and it's probably the canonical problem used when talking about the Halting Problme . But long time ago I came across some a computation of a sequence from a starting value, that was used to illustrate the problem (I thought the source was Un... |
Suppose we have some trees of the following forms:
We want to place these trees in a linear fashion in a way such that the last node has the minimum distance to the first node. For instance, if we have the following trees:
Then an optimal placement will be like the following:
The minimum distance between the first n... |
I am working on the following problem, given input list of length
n to two sublists of length n2 , which are recursively sorted and then merged into a sorted list of length n. The merge sort has the recurrence for its time complexity as T (n) = 2T (n/2) + O(n). We can assume that the algorithm is modified such that the... |
I need to convert a Max Heap to a "Partially Sorted Max Heap" such that all keys at depth i are smaller than all keys at depth i-1.
What is the most efficient way of doing this? Can this be done in O(n)?
|
Recently I began learning a couple array based programming languages: Dyalog APL and BQN. And I cam across this peculiar manner in which division by zero is handled in Dyalog APL. Using the in-built method ⎕DIV a user can change the behaviour of $0÷0$. For instance if ⎕DIV=0 then $0÷0$ will return $1$ and if ⎕DIV=1 the... |
I have a formula which cannot be expressed in terms of y.
fv = (p (1 + r) (-1 + (1 + r)^m) ((1 + r)^(m y) - (1 + x)^y))/
(r (-1 + (1 + r)^m - x)) + c (1 + r)^(m y)
I'd like to solve it numerically with some kind of matrix operation.
For example
with
r = 0.05/12
m = 12
p = 1000
x = 0.03
c = 2000
fv = 92988.93
Ca... |
I'm trying to say this in my paper: "$M$ is a key-value store, where 1) all keys are unique, 2) $k \in M$ means that the $k$ key exists in the store, 3) $M + (k, v)$ is a new store equal to $M$ but the key $k$ is assigned to $v$, 4) $M - k$ is a new store equal to $M$ but without the $k$ key.
Is it possible to omit all... |
Is there a way to make implication graph of expression of form :
$$ ((x_1 \lor x_2)\lor(x_3 \lor x_2))\land(x_3 \lor x_4)$$
I haven't been able to find any sort of text on this and the usual way to make implication graph like of 2-SAT doesn't really make sense because of the extra OR in between.
|
I want to know if checking whether a 3-SAT is satsifiable if and only if every clause has at least 2 or all three literal set to true NP-complete?
It seems similar to Exact-3SAT but it differs from it as the version of this problem which we'll call Exact2or3-3SAT ,where all literals are positive is trivial as its alway... |
Here's a question about semaphore.
(True/False) The signal operation can be implemented with spinlocks
The answer is false, but I don't know why.
I thought the signal operation can be implemented like
signal(mutex):
C.S. Entry section (including busy-waiting)
mutex++
C.S. Exit section
So the C.S. Entry se... |
Is it possible for an online algorithm to perform better than the optimal solution for the offline version of a problem, and if so, in what circumstances?
Doesn't competitive ratio rely on the fact that online algorithm can only reach at most the same performance as the optimal offline solution ?
|
I'm currently reading Design Patterns: Elements of Reusable Object-Oriented Software by GoF and having trouble understanding the following sentence (page 19, Section 1.6):
Composition requires objects to respect each others' interfaces,
which in turn requires carefully designed interfaces that don't stop you from usin... |
ERROR: type should be string, got "https://complexityzoo.net/Complexity_Zoo:R\n\nRL: Randomized Logarithmic-Space Has the same relation to L as RP does\nto P. The randomized machine must halt with probability 1 on any\ninput. It must also run in polynomial time (since otherwise we would\njust get NL).\nContains RHL.\n\nWhile requiring runtime in polynomial time avoids trivial RL=NL, it also allows running time stored. If an algorithm would on average take $f(n)$ steps, then trying to run $100f(n)$ steps would only have 1% chance of not halting, and rejecting in this case doesn't harm.\nSo why only \"Contains RHL\" shown?\n\nAnswering D.W.\n\nWhat does \"allows running time stored\" mean?\n\nLogarithmic-Space allows storing polynomial-size integer\n\nWhat do you mean by \"rejecting doesn't harm\"?\n\nIf X is in RL, then there's an algorithm that accept for 51% chance for input in X, and we can construct one that accept for 50% chance and never fall into infinite loop\n\nWhy do you think the two classes should be equal? Their definitions are different.\n\n\nRHL: Randomized Halting Logarithmic-Space\nHas the same relation to L as RP does to P. The randomized machine must halt for every input and every setting of the random tape.\n\n" |
In "Modelling Computing Systems: Mathematics for Computer Science", I came across a logic exercise to inductively define a merge sort function 'mergeSort', with a hint to first define auxillary functions 'split' and 'merge'. The style of the logic so far looks like this for inductively defined sets Odd and Even, and so... |
While I was learning the Constraint Satisfaction Problems, I analyzed the Knapsack problem(https://www.csplib.org/Problems/prob133/) and I saw the approach with the neural network was not the best approach in solving this problem since it has not shown the best results. Knowing that the neural network approach has show... |
Would it be correct to say that on a operation with a Non-regular language (L) with a Regular language will always return the language L?
I'm came across a property that when we intersect a non-regular language (say L) with Regular Language the resultant result will always remain in Language L.
$L \cap Reg = L$
Does th... |
I am looking for all possible ways to find and eliminate ambiguity in CF grammar. Please share your knowledge or opinion (preferably you will indicate the literature so that I can familiarize myself).I know that it is impossible to check whether the grammar is ambiguous and there is no 100% solution, but I need to cons... |
This question:Complexity of deciding the satisfiability of a quasi-monotone CNF formula
asked whether quasi-monotone SAT is NP-complete or not ?
I want to know if the restricted version of this SAT that is quasi-monotone 3-SAT is NP-complete or not, in this restricted quasi-monotone 3-SAT each clause has exactly 3 lite... |
A question in a textbook says, suppose the regular Clique problem, which takes as input a graph G and a natural number k, and returns whether or not G has a clique of size >= k, can be decided in time T(n) (for some function T: N → N) where n is the size of the input. Then, prove that the problem of finding the size of... |
I'm trying to know what is the exact function in medium term scheduler in operating systems.
As far my understanding, a process may be needed to be removed from the running queue when it is faced with an I/O request. So it is usually sent to blocked list which is also situated in the main memory. Medium term scheduler ... |
I'm studying the algebraic view of automata theory. One of the basic results is that the syntactic monoid of a language $L$ is the transition monoid $M(A)$ of the minimal automaton $A(L)$ accepting $L$. It is also very easy, from a monoid $M$ and a morphism $\mu:\Sigma^*\to M$, to build an equivalent deterministic auto... |
Studying for the exam in "Advanced Algorithms" course. I'm trying to solve the following question:
This question discusses a search operation for a vertex x in a splay tree. Determine how the depth of the vertices changes along the route from the root of the tree to x when, during the splay to the root, zig-zag and zi... |
To be more precise, Is ~(a+b) = ~a + ~b? Here, "~" bitwise NOT operator.
I ran into this question while thinking about the 2's complement, which adds 1 to ~x (i.e., -x = ~x + 1).
Suppose we are given -x (in binary), and we need to find x (in binary). We can do this by computing x = ~(-x-1), but computing -x-1 (by hand)... |
f(n) = log n^2; g(n) = log n + 5 => f(n) = Θ (g(n))
I think we can prove this for omega but how can we prove it for Big oh ?
because if we simplify it to logn + logn <= logn +5 => logn<=5 is not true !
|
All the sources I find on the internet say the time complexity of quick sort is worse if:
input array is sorted and we choose the leftmost element as the pivot
input array is sorted reversely and we choose the rightmost element as the pivot
I am wondering if time complexity is still $O(n^2)$ if we do the following ... |
As we all know, 3-SAT is NP-hard.
Two of the less known results are that Planar 3-SAT is NP-hard and also a 'restricted' 3-SAT, where any literal appears in at most two clauses turns out to be NP-hard.
My question is if there is any known result on what happens if we combine these two conditions? That is, suppose we ar... |
I'd like to implement pagination for an API. The elements are ordered by time but there can be multiple elements with the same timestamp. So there can be some duplication between the last elements of the previous page and the first elements of the next pages.
So far the de-duplication is handled on the client side by k... |
As the title says, I'm trying to solve the question where:
Input: A directed tree $T = (V, E)$.
Output: The maximal subset $A \subseteq V$ of vertices such that there doesn't exist any two vertices $u, v \in A$ that have a directed path between of distance $2$ or less.
I thought of starting to append all of the leaves ... |
I found a grammar for this language.
$S->caZac |cccc $.
$Z->aZa | cc$
But if I try to use pumping lemma for context-free languages on $L$ with the word: $ca^ncca^nc$ I obtain it's not context-free. How is it possible?
|
I am reading about algorithms to find the shortest path on a graph with one source, and I have a doubt about Dijkstra's algorithm about the negative weights on edges. In this case is Bellman-Ford algorithm a better solution for this part?
|
This might be a a simple and for some a silly question as well.
If I buy two hard drives and have windows in one and Ubuntu in the other, can I work with both two systems(one at a time).
Example, I wanna edit a photo and I quickly need to go to Adobe Photoshop, so I plug in the Windows harddrive and start editing, then... |
If an array is stored from lower region of memory to higher region, we've this indexing formula.
$$ Address (A[i]) = M+(i-L)*w$$
Where:
M = memory location where first element is to be stored.
L= Lower bound for index
i = index
w = word length
But for the case in question, we have:
$$L<i<U$$
$$A_i > A_{i+1}$$
|
We have an array of n measurements: (m_0, m_1, ..., m_n-1). The measurements are voltages, but that's not important, so let's say they are just numbers. The measurements can be positive, negative or zero. There are no NaNs or infinites, only "regular" numbers. We are given a certain non-negative threshold.
We want to f... |
We were given a question in class as follows:
You have a "magic oracle" that can decide if a Turing Machine halts. You have three TMs $T_1, T_2, T_3$. Device an algorithm that decides which of the TMs halt and which do not by asking the oracle at most twice.
The sketch of the solution given was
Construct a new TM $T_A$... |
A question is asked in the below link, which asks for the number of cases we can partition a multiset, where each part/segment in the partition has distinct elements.
https://math.stackexchange.com/questions/4622246/how-many-ways-we-can-partition-a-multiset-where-each-part-segment-in-the-partit?noredirect=1#comment9752... |
Here's a question in the OS textbook about calculating the cpu utilization.
I've tried to write down the (A) by myself as below.
(35+303)/((3+0.05)5 + (30+0.05)3) = 99.6xx%
But I'm not sure if it is right.
|
In a sorting algorithm, While computing the complexity of an algorithm why do we only account for the number of comparisons done but not the number of swappings done?
And what's the formal definition of complexity?
|
We know that the P language class is a polynomial-time solvable language class, and the NP language class can be determined in exponential time. And there exist some languages that can be decided only in exponential time and no polynomial time solution has been found yet, such as SAT language.
My question is whether th... |
(15 marks) Suppose a ray comes from a point (2, 8) and hits at mirror point (6, 6). Assume
that perpendicular vector a point (6, 6) is ̅= (0, 3). Find the reflection emitting point from
(6, 6).
[Assume 2-D coordinate system, you must draw the appropriate diagram of your
solution]
I'm pretty sure I can figure out the di... |
I have a directed graph $G(V,A)$ with arc costs $c_{ij} = \alpha_{ij}1_{x_{ij}>0} +\beta_{ij}x_{ij}$, where $\alpha_{ij}$ and $\beta_{ij}$ are, respectively, a fixed cost and a cost per unit of flow pushed along arc $(i,j)$. I'd like to solve the minimum-cost flow (MCF) problem in this graph, i.e., given a supply/deman... |
I'm trying to learn the implementation of the Monte Carlo method in R language. I am following a course with an example of predicting results for a board game. What I'm not understanding is the usage of a function that was implemented on the top of the code, and that is:
set.seed(5678)
Do you know what this function i... |
Can you verify this like please bro please tell me the answer to my question
|
$P$ is the language class that is decidable in polynomial time by a deterministic Turing machine.
$NP$ is a language class that is decidable in polynomial time by non-deterministic Turing machines and can be decidable in exponential time by deterministic Turing machines.
So are there any other language classes of time ... |
I need to implement my own red-black tree and I am stuck with deletion. I have found this book (Introduction to Algorithms) (p.222) and in the following code I can't understand this marked line.
Firstly, why do I need to do that if x.p is already pointed at y, because it is in particular y.right.p (== y).
Secondly, wh... |
Is there a $O(nlogn)$ time algorithm for computing $p(x)=\sum\limits_{i=0}^na_ix^i$ ?
I think with the method below I get O(n), but I need O(nlogn)
Hint: there's a way to calculate $x^i$ more efficiently.
This is exactly what I'm doing right ?
x = v
total = 0
for coef in coefs:
total += coef * x
x *= x
retu... |
Problem
In the problem, I was given the grammar for a non-deterministic finite state automata (NDFSA). There was no other useful context given. The problem asks you to use this grammar to draw the NDFSA and then asks you to convert the NDFSA into a deterministic finite state automata (DFSA). The grammar is written as s... |
In graph G: a cycle $A$ is a subcycle of cycle $B$ if there exists vertices $c$ and $d$ such that:
$cd$ is an edge of $A$.
$F$ is the resulting path of $A$ after removing the edge $cd$.
$E$ is a path from $c$ to $d$ of length at least $2$, and the cycle $B$ consists of the edges in $E$ and $F$
For example:
In the gra... |
I want to know if checking whether a a set of 3-literal clause is satisfiable such that every literal in each clause is either all true or all false NP-complete?
By 3-literal clause, I mean it can have a clause can have at most 3 literals.
I think this problem is NP-complete or co-np complete as it seems like a complem... |
The permuted kernel problem is NP-complete problem by simple reduction from partition problem. In fact, it is strongly NP-complete by reduction from 3-partition. The literature points to Garey and Johnson for the reduction from 3-partition. I checked G&J but did not find the reduction. Do you have a reference that cont... |
The problem that I'm trying to solve is:
Given an array of length N, I want to find the length of the longest palindrome in the given array.
With palindrome, we refer to a word, phrase, or sequence that reads the same backwards as forwards.
For example, if we give as input "1234321789" the algorithm should return 7.
I ... |
I'm trying to find the time complexity of T(n) = 1600T(n/4) + n! . So far I have thought of changing n! to something usable by the master theorem. Stirling's approximation gives us the equation
$$\sqrt{2\pi n}\left(\frac{n}e\right)^n$$
I am confused on whether the value for d in the master theorem would become n or if ... |
I have a math problem I need to solve so I can complete an optimisation in a computer program. My initial approach was just to brute force all the possible permutations but it got out of hand quite quickly for larger sets. Here's the problem
Let's say you want to take n bets each with odds k. We want to optimize the am... |
I'm currently investigating the computational complexity of a modified one-dimensional Suguru puzzle. The general Suguru puzzles were recently proven to be NP-complete (see here). My investigation considers a modified one-dimensional Suguru puzzle played in a $1 \times N$ grid of cells. These cells are grouped into one... |
This questions is about the work A novel similarity-search method for mathematical content in LaTeX markup and its implementation.
The parser used by Wei Zhong is LALR.
Now, supose I have to parse a function $func(foo)=bar$.
How is the parser able to understand the "$func$" as a whole string representing the name of a ... |
This questions is about the work A novel similarity-search method for mathematical content in LaTeX markup and its implementation.
Mr. Wei Zhong uses flex lexer generator.
Now, supose I find an expression like $\pi(x)$, the Prime-counting function.
How to represent the prime-counting function correctly and not interpre... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.