instruction stringlengths 35 11.4k |
|---|
Supposing we have either a NFA or a DFA with accepted language $L$, what is $L^*$? And how can I build an automaton that accepts it?
|
In "regret" styled analysis over $T$ steps of an iterative algorithm $\{x_i \in F \}_{i=1}^T$ (where $F$ is some feasible set) being given the sequence of loss functions $\{ f_i\}_{i=1}^T$ one defines the regret $R_T = \sum_{i=1}^Tf_t(x_i) - \min_{x \in F} \sum_{i=1}^T f_t(x)$ Most typical analyses assume that the $f$s... |
I'm using the definition of the height of a tree as the longest possible path from the root to a leaf by its number of edges, e.g. a tree of 2 nodes has a height of 1. With that in mind, what would be the number of binary search trees (don't have to be balanced) that have the maximum possible height for n-nodes?
So ... |
Is there an algorithm that removes edges to convert a non-planar DAG to a planar DAG while maintaining reachability? For example, the graph $G$ below is non-planar:
but, by removing certain edges to produce $G'$, it can be made planar but every vertex still has the same transitive closure (meaning vertex $t$ is reacha... |
I'm trying to write an induction statement to prove a full node in a tree but I have no idea how to do that. I've always been terrible when it comes to logic. Where do I even start with this?
I know that a full node has 2 children.
|
Assume I have $P$ processors, each having a different vector $v_p$ of size $N$, $p=1, ..., P$. I learned in this question/answer that for computing the matrix-vector product
$$w = (E\otimes I_N)v$$
in parallel, where $\otimes$ is the Kronecker product, $v = (v_1, ..., v_P)^T$ is the stacked vector consisting of all lo... |
I have the following problem.
Given an array A, filled with 0s, we should set some elements to be equal 1, considering such rules:
If all elements equal 0,set A[0] to 1
Next 1 should be set at maximal distance from any other 1s. At this
stage it will be A[size-1].
In case of equal distances, set 1 at the element with ... |
I am prety stuck over here:
prove or disprove that every $L$ got $L'$ s.t $L'\geq L$ and for every $L''\geq L$
$L''\ngeq L'$
basically it means L' is the hardest...
my intuition tells me that this is correct, but I cant prove why.
I tried to prove using counting but got stuck:
we got $\aleph_0$ pairs of functions th... |
I'm looking for a way to recognize and possibly extract source code from text files that may contain only source code, source code mixed with plain text or just plain text without any source code.
There's different source code contained in the data set, just to name a few examples: Java, C, Python, Bash, PHP, Javascri... |
The deferred acceptance algorithm solves the Stable Marriage Problem in a two-sided network, where each agent has complete preferences over each agent of the other side. There is always at least one stable matching but there can be several. Traditionally, the problem was solved by having men propose and women accept/re... |
Question:
Given that f(n)>0 and c>0
Prove that f(n)+c = O(f(n)) or provide a counter-example if it's false.
My Effort to solve: \begin{eqnarray*}
f(n) + c \space \leq \space d\cdot&f(n)\space for \space all\space n \geq n_0\space and \space d>0\\
\end{eqnarray*}
So i believe there can be found some large d that s... |
This is how I would think it
n^2 = O(log n)
f(n) <= c*g(n)
should c=1 ?
n0 = 1
n^2 <= log n
0 <= log n - n^2, for all n>=1
we take n=1 then 0 <= log(1) - 1^2
0 <= 0 - 1
0 <= -1
Therefore n^2 = O(logn) false?
Is this correct?
|
I have an algorithm for finding if there is a cycle in a connected graph by depth first path creation of a graph until there is a duplicate in the path. Beside simply starting this algorithm at all possible points for an unconnected graph, how can I find if an unconnected graph is cyclical in good time and in a simple ... |
I stumbled upon an interesting problem and I'm stuck with it, since I can't find parallels to other problems or algorithms to solve it.
We have a set of objects $O = \{a,b,c,...,z\}$, objects can make triples, e.g. $T=(a,b,c)$ $a,b,c \in O$ and we have a set of triples $X = \{T_1, ... T_n\}$. Each triple is assigned a... |
I was reading Stanford's CS 229 materials on Linear Quadratic Regulation (LQR) (Lecture note 13, YouTube Lecture 18, around minute 36),
and it mentions that:
[...] the quadratic formulation of the reward is equivalent to saying that we want our state to be close to the origin. For example, if $U_t = I_n $(the identity... |
Why is it that the test for an infinite language on the DFA $M$ has an upper bound of $2n$?
That is to say, when testing for a string of length $k$, why does the theorem say:
$$n \leq k < 2n$$
I understand the lower bound of $n$ IAW the Pumping Lemma of $|w| \geq n$. I'm just not sure why $2n$ was chosen and I think I'... |
There is already a post on this topic on stackoverflow.
Nevertheless, I am asking the question here again, primarily because I do not understand the answer given there, and also because I have some takes on the problem I would like to supplement with.
To reiterate, we have a problem in CLRS which goes like this:
Show ... |
I have been looking into vpn (virtual private network). And I wanted to know more about the theory, how does it work really:
what does it do with the packages?
why is it secure? (or why can it be unsecure)
how does it work on the internet?
how can it simulate you're coming from another country?
It feels so mainstream... |
Given an array of $N$ numbers and a number $K$, Find the minimum number of swaps required to bring all the numbers greater than or equal to $K$ together. Swap here means, swapping value of $array[i]$ and $array[j]$, where $1 ≤ i , j ≤ N$.
We are also given that:
$1≤N≤10^5$
$1≤array[i]≤10^5$
$1≤K≤10^5$
Sam... |
I'm trying to work out how to find the gamma $\gamma -code$ that encodes the postings list (12, 18, 21, 22).
Is the postings list encoded just by a list of the individual $\gamma$-codes for each integer? E.g. for 12 the gamma code is: 0001100, and so the first entry in the $\gamma$-code for the pointing list is just 00... |
I'm looking for a data structure, in which the operations $Init, Median, Min, Max, Delete$ run in $O(1)$ amortized-time, and $Insert$ should run in amortized-time as low as possible.
I tried to work with Min-Max Fibonacci heaps and pointer to median, but got stuck.
I believe the $Insert$ operation can be done in $O(\l... |
What i know is that applications create "socket"(visualized concept for high level programmers),the socket will address the ip addresses and send to internet and forward the feedback data.What i wonder is do applications send tcp packets directly to hardware interface or through another program like firewall?And how ex... |
Let's say we're talking about a 1 GB video file. It's copy-pasted from hard disk D1 to the hard disk D2, then from D2 to D3, and so on, all using Windows. If we continue this process for like 1 million times, what would the resultant file look like? Do error bits accumulate and finally corrupt the file?
|
Lemma. (Transitivity) "$\leq_p$" is a transitive relation on languages, i.e., if $L_1 \leq_p L_2$ and $L_2 \leq_p L_3$, then $L_1 \leq_p L_3$.
Proof. By definition, there are poly-time functions $f$ and $g$ such that $x \in L_1 \Leftrightarrow f(x) \in L_2$ and $y \in L_2 \Leftrightarrow g(y) \in L_3$, thus $x \in L_1... |
A 010101
B 110011
C 111000
D 000111
The minimum Hamming distance of those code words is 3 as the minimum difference is 3 but the correct answer is 2.
How can I find the correct Hamming distance?
|
I have collected data from numerous volunteers driving a simulator in 8 different scenarios (classes). A volunteer drives in a map for 4 minutes in one scenario (one experiment), then he drives in the same map for 4 minutes in a different scenario(second experiment).
Our current dataset has around 0.4 million rows of ... |
For any non-planar DAG, we can compute the transitive reduction, and sometimes it will be planar (e.g. $K_5$).
However, sometimes the transitive reduction is also non-planar. For example, $K_{3, 3}$'s transitive reduction is just $K_{3, 3}$.
Alternatively, it's possible to add vertices and adjust the edges to maintain ... |
I was reading the question Consistency and completeness imply soundness? and the first statement in it says:
I understand that soundness implies consistency.
Which I was quite puzzled about because I thought soundness was a weaker statement than consistency (i.e. I thought consistent systems had to be sound but I gue... |
What is meant by in the following statement (from the paper titled "Implementing Lightweight Threads"):
As in singlethreaded processes, the number of signals received by the
process is less than or equal to the number sent.
Why is the number received less than or equal to the number sent. I don't have enough backgr... |
Given a 2D image of a human face and the corresponding 3D shape, how do I project the shape onto the images to extract texture patches from them to form a partial UV map?
|
I was wondering what is the difference difference undecidable language and Turing recognizable language. I've seen in some cases where they ask:
Prove that the language $ A_{TM} = \{ \ <M,w> | \ M \mbox{ is a Turing Machine accepting } w\}$ is undecidable.
Prove that the language $ A_{TM} = \{ \ <M,w> | \ M \mbox{ is ... |
Given a $G=(V,E)$ bipartite, undirected, 4-regular graph, I would like to find a perfect matching in linear time.
It is easy to show that there is a perfect matching for the graph, by using flow and showing a flow of size $|V|/2$.
Using flow networks, we can also use Dinic's algorithm to find the max-flow which is equa... |
I have a research problem which has a general outline as follows:
I have a 2D parameter space, $(\alpha, \beta)$ which serve as initial conditions on some set of partial differential equations. Given values for $\alpha, \beta$ I can integrate this set of PDEs numerically to obtain a result in a 2D phase space $(x,y)$.
... |
Do we know of any necessary condition for a Boolean function or say a depth $2$ LTF circuit to have a low (~poly(dim)) sign-rank?
|
If one ignores the conflicts when accessing the dequeue in Work-Stealing algorithms, does it matter (and in what ways) if one steals from the top or bottom (or anywhere randomly) of the dequeue? Does it matter (and in what ways) if one steals one or more items ?
|
Until just now I thought that I have fully understood Rice's theorem but this example irritates me:
$L^* = \{ \langle M \rangle \mid M \mbox{ is a Turing machine such that }L(M) = H_{all} \mbox{ } \}$
where $H_{all}$ denotes the totality problem. Correct me if I'm wrong but in my opinion this is not the same as $L' = ... |
I found this problem on an algorithmic book. I have solve the requestments about time (O(n^2)) but I can't figure out how it works.
Input: Two n-bit integers x and y, where y ≥ 1
Output: The quotient and remainder of x divided by y
function divide(x, y)
if x = 0:
return (q, r) = (0, 0)
(q, r) = divide... |
Context
In randomized algorithms two schemes of computation are common:
Las Vegas algorithms with random running time
Randomized algorithms that have a probability of success, and have to be executed multiple times before getting the answer
You can also transform the latter in the former with a loop but they really d... |
Say you have a language L = "{0,1}* without strings that start with 00". How do you prove this is decidable? I'm drawing a blank on this one.
|
DEFINITION: $f = O(g)$ if positive integers c and $n_0$ exist such that for every integer $n$ $\geq$ $n_0$, $f(n) ≤ c·g(n)$
so:
$n^2 \leq c·log(n)$
$\frac{n^2}{log(n)} \leq c$
is this enough proof? since the fraction will grow larger and larger depending on n>1, so its false?
|
Disclaimer: I'm very new to computer science & game programming
I'm having trouble with understanding how to implement a static evaluation function in chess. The logic seems simple like just apply a weight to each piece on the board and subtract the pieces from each side, but its much more complex than that isn't it? Y... |
Problem domain - I'm implementing a home monitoring system using smart phones. At regular intervals rear camera of the phone takes images and compare them for a change detection. This change detection is done inside the android app itself. Only after a change is detected, image is sent to server.
I want to know a fast ... |
In the field of the intelligent swarm, there are many algorithms can find global optimization, such as Ant Colony Optimization (ACO), particle swarm optimization (PSO).
Is there any optimization algorithm implements using MapReduce which can run at Hadoop?
|
Im studying finite state machines, in particular the deterministic and the non-deterministic versions.
What i have not understood is :
why in a non-deterministic state machine it's allowed that from a state it's possible to go nowhere ?
This is not allewed in DSM. Why ?
|
Note: Not sure with the tags.
I'm quite new to this area of Computer Science. I was used to just developing software and applications and applying certain algorithms when necessary. However, I am tasked right now with a very complex task. I apologize in advance, although being a Computer Science graduate, I've only bee... |
The overall architecture of the Android OS is a Stack. What specifically justifies Stack to design the overall architecture of Android? Are all mobile OS like Windows Mobile, iPhone OS developed as software stacks? If yes then why? Why not a queue, tree, graph, heap, etc.?
For more information and clarity to my questi... |
Does there exist a universal constant $c$ such that for any strings $x, y$, we have: $$K(xy)\leq K(x) + K(y) + c$$
where $K(\cdot)$ denotes the Kolmogorov Complexity of a binary string and $xy$ means the concatenation of $x$ and $y$? I know the answer to this problem is no but I am seeking a proof for this, any hint?
U... |
"Each process that is executed is divided into blocks of same size, called pages."
"Thread is a part of process being executed."
Are pages and threads both part(s) of process? Whats the difference between thread as a part of process and page as a part of process?
|
In response to a clock interrupt, the OS saves the PC and user stack pointer
of the currently executing process, and transfers control to the kernel clock
interrupt handler.
Then the clock interrupt handler saves the rest of the registers, as well as other machine state, such as the state of the floating point register... |
I'm looking for a method for determining a path for a UAV that interpolates a set of input locations, with a constraint on maximum curvature and given an initial velocity vector.
The cost (length) of the path should be as small as possible.
I know a little bit about Dubins curves but that's in 2D and only for two point... |
I am reading in my book that this NFA machine accept the string 10100. If we follow the execution, we will find our self in branch with the state final q0.
The only answer for me is that when we are in state q0 after 1010 and 0 is coming we can't move any more so this branch will die even it is in the final state. Am ... |
I was recently thinking about the validity of proof by contradiction. I’ve read for the past few days things on intuitionistic logic and Godel’s theorems to see if they would provide me answers to my questions. Right now I still have questions lingering (perhaps related to the new material I read) and was hoping to get... |
I've read some about genetic algorithms and the general approach, but I haven't found anything about using it when the length of the solution is unknown. How would the generation of the initial population look like? Would mutation then include adding/removing alleless? Are there any general methods for this?
|
Consider a (smooth) function
\begin{align*}
F: \mathbb{R}^2 \to \mathbb{R}
\end{align*}
with the contour
\begin{align*}
\mathcal{C} = \{x \in \mathbb{R}^2 | F(x) = 0\}
\end{align*}
The function (and possibly derivatives) will be given as analytical expression, and be continuously differentiable everywhere. I am trying ... |
One strategy for ordering the growth of functions involves substitutions when comparing functions using the limit as $n$ goes to infinity comparing two equations using the following rule.
$$
\lim_{n\to\infty}\frac{f(n)}{g(n)} =
\left\{ \begin{array}{cc}
0, & f(n) \in O(g(n)) \\\
\infty, & f(n) \in \Omega(g(n)) \\\
c... |
I am attempting to learn neural networks using the Keras libary on the MNIST hand written digit dataset, using dense layers only. I am trying to figure out what the best shape for the network should be but I can't seem to find any literature or discussion on the subject.
By shape, I mean should the hidden layers have m... |
After reading Dimitris Andreou's blog post on reachability, it seems that reachability can be reduced to order-maintenance. A solution to the order-maintenance problem has the following interface:
Insert (X, Y ): Insert a new element Y immediately after element X in the
total order.
Delete (X): Remove an element X fro... |
If I were to sort the list of numbers 1,7,5,7,1 using Hoare's algorithm as described at the very beginning of wikipedia item on Hoare partition scheme with 5 being the pivot, and the indexes start at 1 and 1, then what would happen? If they are switched, nothing is really sorted. And the same goes for the two indexes b... |
An adversarial autoencoder helps us to impose a prior distribution $p(z)$ on the encoded values of the inputs, or $q(z)$.
On the contrary, an ordinary autoencoder (which we train like an ordinary neural network (comparing output to input using mean squared error) does not give us any control over the encoded distribut... |
Given a directed acyclic graph G, give a linear time algorithm to determine if the
graph has a directed path that visits every vertex.
You can assume you are given a list of nodes and two adjacency lists: Enter[v] which contains all the edges entering node v, and Exit[v] which contains all the edges leaving node v.
I ... |
What I know is that $W = \lim V$ for some $V$ if and only if $W$ is the language of some deterministic buchi automata, namely that of $V$.
So, to attack this problem I tried to come up with some language of the form $U^\omega$ which cannot be determinized. But I keep failing trying to come up with something like this.
... |
A naive greedy algorithm tries to find an optimal solution based on the best solution so far, hence it may get stuck in local optima.
To avoid this problem, we may keep track of the best $n > 1$ solutions (instead of the best only). What is the name(s) of this algorithm?
Surprisingly, I can't seem to find the answer fr... |
I ran into this exercise problem from Introduction To The Theory Of Computation by Sipser. Given a context free grammar:
$ S \rightarrow SS \ | \ T \\ T \rightarrow aTb \ | \ ab $
I have to show that the grammar is ambiguous. So I have to find at least two leftmost derivation of a string. I have tried a lot but have fa... |
In the following loop
for i = 1 to n
doSomething O(1)
for j = 1 to k
doSomething O(1)
Is the runtime still $O(nk)$ even with the expression in the outer loop? Because if I change the order of the loops and $n \neq k$ then doSomething is executed a different amount of times.
|
You are given a rectangular board of known size, e.g. 20x20 cm. Some 1x1 cm pieces are missing. Your task is to cover this board with a maximum number of 2x2 cm tiles (an example is attached below), while it's not allowed to cover missing tiles. Currently, I solve it using the following greedy algorithm:
for x in N:
... |
I find it hard to find reductions that only work on one side:
A is mapping reducible to B, but B is not mapping reducible to A.
what could be an easy way to find such two languages A,B ?
I tried Atm,Htm,EQtm,Etm,RegTm, and many others, and whenever I found that A is reducable to B, I also found that B is reducable to A... |
The algorithm I am looking for has the following requirements: Input is a set of strings. You are looking for a string containing all input strings. The resulting string should be as short as possible. At least shorter than just concatenating all input strings if possible.
Examples:
Input: a ab bc
Output: abc
Input: a... |
In order to find Big O for a recursive algorithm, it is needed to know the stopping criteria of that algorithm. For the recursive algorithm to find Factorial of a number it is very easy to find the stopping criteria.
int fact(int n)
{
if((n==1)||(n==0)) return 1;
else retrun n*fact(n-1);
}
And we can make a ma... |
The CURE algorithm is a method of clustering data. An outline of it can be found here on slide 5: https://www.slideshare.net/ellepiu/cure-clustering-algorithm. I personally learnt it from this video: https://www.youtube.com/watch?v=JrOJspZ1CUw, where the algorithm is explained at 7 minutes.
This is my understanding of ... |
In the paper "PRIMES is in P" the following is said (page 1):
Let PRIMES denote the set of all prime numbers. The definition of prime numbers already gives a way of determining if a number $n$ is in PRIMES: try dividing $n$ by every number $m \leq \sqrt{n}$ — if any m divides $n$ then it is composite, otherwise it is ... |
I am doing problem 1.g.
My Approach is to first create a NFA that accepts this string i.e. all strings having 110. Then converting it into DFA and then complementing it. I have the answer what should I get however my NFA to DFA conversion doesn't work. I don't know why. Can anyone guide me. Thanks. Here is my NFA. Note... |
I recently started to learn about machine learning. I have created a feed forward neural network (ffnn) and a recurrent neural network (rnn) to predict user ratings of movies. I am using a subset of 2000 users and their ratings of the "Netflix Prize" dataset.
The ffnn as well as the rrn have an accuracy of ~40% - 45% o... |
I'm studying Complexity Theory. Many times i found written that in complexity theory every problem come in pair, that is a search version and verification version.
But why this happens ? What establish this ?
|
Theory of computation often involves nondeterministic models of computation. Some examples include nondeterministic finite automata (NFAs), nondeterministic pushdown automata (PDAs), and nondeterministic Turing machines. Real computers, however, are deterministic (or at best, randomized).
What is the point of studying... |
Im studying Complexity Theory and i have a question.
What principle establishes that every NP problem can be solved by a deterministic turing machine in a exponential time ?
|
I am currently looking into timed automata for a project.
I am thinking about a timed automaton where a clock only advances when the automaton is in a certain state.
However, my little knowledge in the domain makes me wonder whether somebody already defined timed automata like that.
As an example:
I.e. I have a timed a... |
If the body of a simple for loop has time complexity $O(n)$ and it is
executed $n-1$ times what is the time complexity of the complete loop?
I am trying to figure out the correct answer to this question for my upcoming exam. My reasoning is that if the body of the loop is executed $n-1$ times and its complexity is... |
$O(n) = \{n, n^{2}, n^{1000000}, 2^{n}, ...\}$ [Source A], [Source B]
Say $t_{n} \in O(n)$
By formal definition $t_{n} \leq k \cdot n$ [Source C]
But how can this be? Say $t_{n}$ is actually $n^{2}$, then $t_{n} \leq k \cdot n$ is just false. Would it not be more logical to have $t_{n} \geq k \cdot n$ as a formal de... |
Let's say I'd like to search a database and I have a function $f$ such that $f(x) = 0$ for all incorrect entries and $f(x) = 1$ for all target entries.
The crux of Grover's search seems to be that there exists a way to construct a quantum operator $\hat{f}$ in a way that it takes a superposition of states as input and... |
A similar question has been asked here, but this one is more complicated and has more constraints.
I'm trying to find an algorithm to solve the following (real-life) problem:
A customer has $M$ amount of money each month that he wants to invest according to her preferred asset allocation.
Example
60% stocks
20% bonds... |
This is a very simple question, but I cannot find the answer anywhere, mostly because I don't know how else to ask about what I'm looking for. I have a homework assignment that has to do with pumping lemma, which asks me to use the pumping lemma to prove that the language given is not regular.
{x₁#x₂#x₃|x₁, x₂, x₃ ∈ {a... |
Can anyone please help me understand the quasi-liveness and liveness properties of petri nets. Suppose that you explain that to a person with 10 years old.
For my part, i have the following definitions.
- quasi-liveness petri net: its mean that every transition in the net can be enabled at least one time for specific m... |
Consider a sequence $s$ of $n$ integers (let's ignore the specifics of their representation and just suppose we can read, write and compare them in O(1) time with arbitrary positions). What's known about the worst-case time complexity of producing a sequence of all distinct elements in $s$, in any order?
By randomized ... |
In Vizirani's textbook says in page 332,
Gap preserving reductions are weaker than their L-reductions [...] one of the motivations for the PCP theorem was that establishing an inapproximability result for MAXSAT would directly yield inapproximability results for all Max-SNP-hard problem.
Now my question is: Why Gap p... |
(This is a question of information theory, data compression and entropy, so I believe it fits CS forum)
Does the fact that the computer itself is a part of the universe make it logically impossible for the computer to contain the information of the whole universe?
I want to know if it's possible to simulate the whole u... |
I have $k$ unit vectors in $\mathbb{R}^k$. Can I efficiently identify a set of $2n+1$ vectors $v_1, \dots v_{2n+1}$ such that $\sum_{i< j} v_i\cdot v_j < -n$ for any $n$ -- or determine that no such set exists?
As some motivation, if I have 3 vectors (so that $n=1$), the minimum value of their pairwise dot products if ... |
An $\omega$-word $s \in \Sigma^\omega$ is eventually periodic if it is of the form $s = uv^\omega$ for finite words $u, v \in \Sigma^*$.
I want to show that the set of all eventually periodic words is not buchi-recognizable.
I do not know how to proceed. My attempt was to find a part of the word and then pump it indefi... |
Team A has 2 Spots
Team B has 1 Spot
Player 1: 10 Units when on team A, Can't work on team B
Player 2: 8 Units when on team A, Can't work on team B
Player 3: 9 Units when on team A, 2 Units when on team B
I'm trying to craft an algorithm that will maximize the total units of output between the two teams. I'm representi... |
I've been reading the proof that axis-aligned rectangles are PAC learnable from the book Foundations of Machine Learning by Mohri (Proof pt. 1, Proof pt. 2), and a small technical detail stuck out to me.
The proof goes through dividing the target rectangle $R$ to four rectangular regions $r_i$ (Fig 2.3), each having p... |
There are $2^{2^n}$ possible functions that have $n$ boolean inputs and a single boolean output. Some of these functions have very short boolean logic circuits. Some have longer circuits.
A classic result in circuit complexity is that, if you count the total number of gates needed to implement $f$, most $f$s take $\The... |
Suppose I have an undirected graph that consists only of a cycle. Each vertex has a depth value that must be $1$ greater than its predecessor (i.e. if we reach vertex $F$ from vertex $C$ which has a depth of $2$, then $F$ has a depth of $3$). The beginning vertex has a depth of $0$. I need to show that every vertex mus... |
Say we have a Priority Queue of size 1000 that is implemented using Max Heap.
Now if i want to get the top 5 elements, the most laid back method is to poll the maximum 5 times, resulting in a set of five maximum numbers. The complexity of a poll function using heap is Log N. Hence, retrieving 5 top values or say, K to... |
What is the time complexity of this algorithm? I assume that is $O(3^n)$
n=3
recLoop(int n)
{
for(int i=0; i<3; i++)
{
if(n>0)
{
recLoop(n-1);
}
count++;
}
}
n 0 1 2 3 4
count 3 9 27 81 243
From this, I get $O(3^{n+1})$
If I change my algorithm to:
recLoop... |
For the following code fragment:
i = 1;
s = 1;
while(s <= n) {
i++;
s = s+i;
printf("x");
}
How can we go about proving the time complexity of this code is $\Theta(\sqrt{n}))$?
Usually, I use sigma series analysis to figure the time complexity but I am having trouble turning this code into series notation... |
I'm not sure if my logic is correct when it comes to the algorithm for decision problems. The concept is confusing me when I fail to distinguish its answer from that of a proof.
For example:
Given two finite automata $M_1, M_2$ that operate on a common alphabet, find an algorithm to show that:
$$L(M_1) \subseteq L(M_2)... |
What are advantages of closed hashing over open hashing?
I know the difference between those two but can't figure out why would closed hashing be better in any way.
Thanks.
|
Basically, when given an Undirected graph, the problem of getting maximum cycles is known.
This case is quite different.
The graphs I'm dealing with are made by converting geometric polygons to vertices and edges, so vertices relative position matters, and there are weights on the edges representing the distance betwee... |
I have a set of locations, around 100, I want to divide into groups.
I say these locations are in a graph because the geometric proximity (straight line distance) doesn't matter to me, and I have a matrix of the distance (non straight line distance) and time, that would take to travel from any location to another. Eith... |
I am trying to prove by induction that if
$$\hat\delta_d(q_0, w) = \hat\delta_n(q_0, w)$$
I know by practicing inductive proofs of the $\hat\delta$ for DFAs, that on the basis of the definition of $\hat\delta_d$
for any $q \in Q$, $\hat\delta(q, \epsilon) = q$
for any $q \in Q$ and $a \in $ the language of the DFA, ... |
I was thinking yes because $0 \leq \sqrt{h(s)} < h(s)$ but I'm not entirely sure.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.