instruction stringlengths 35 29.1k |
|---|
I consider simplified Pacman game:
movement is discrete (on the grid),
ghosts move deterministically based on difference between their and Pacmans coordinates,
ghosts move every second turn,
ghosts always chase Pacman, never reversed,
the maze has no exit, success is when Pacman collects all the dots.
The most natura... |
The C memcmp function (and strcmp) does a comparison similar to the function below for comparing integers:
int compare(const int a, const int b) {
if (a > b) return 1;
if (b > a) return -1;
return 0;
}
Microsoft information for their strcmp says:
The strcmp function performs an ordinal comparison of st... |
Code for finding $\phi$(n) is
int phi(int n)
{
int result = n; // Initialize result as n
// Consider all prime factors of n and subtract their
// multiples from result
for (int p=2; p*p<=n; ++p)
{
// Check if p is a prime factor.
if (n % p == 0... |
Assume the $\mathcal{F} = \{\, f_{s} \,\}_{s \in \{\, 0,1 \,\}^{*}}$ be a family of computable functions, where $f_{s} \colon \{\, 0,1 \,\}^{|s|} \rightarrow \{\, 0,1 \,\}^{|s|}$.
Let $F_{n}$ be a distribution of functions $f_s$ where $s$ is uniformly distributed over $\{\, 0,1 \,\}^{n}$, and let $RF_n$ denote the unif... |
I'm new to the concept of loop invariant and I'm trying to figure out the loop invariant for a program that returns if an integer is prime and, if not, one possible factorization.
My intuition is that as a loop invariant condition we need i in the range [2,floor(sqrt(n))] and then n mod i !=0 implies n is prime
bool Is... |
We're studying Heuristic in my Theoretical CS class, more specifically Greedy-Algorithms for the Traveling Salesperson Problem. The first one is the "next neighbor heuristic", where you start at any given point and connect it with the nearest point and then connect that to the next nearest one until all points are cove... |
Most descriptions of modern RNNs present a "folded" characterisation, that is to say, a single cell with a loop back to itself transmitting the hidden state from one step to the next. However, in implementations the RNN is computed "unfolded", so a new cell is created for every step of the sequence up to some maximum s... |
In his paper Computer Machinery and Intelligence, Turing addresses some arguments against the ability of a computer to pass the Turing test, such as the Theological Argument, the Mathematical Objection and the Argument from Consciousness. I wonder what is the current status of this debate; are there strong counterargum... |
I understand that using a bad case for subset construction as provided through an example in the book - Introduction to Automata Theory, Languages and Computation, we can definitely have an NFA with $n+1$ states, and get a corresponding minimal DFA with $2^n$ states due to the power set logic.
But, my question is, is ... |
I guess this is kinda like asking if 3 (or more) rectangles are collinear.
The question is, given n rectangles on the 2D plane (given as the rectangle's top-left corner coordinates and it's width/height), does there exist a line that goes through all of them?
Notes:
The rectangles' sides are perpendicular or parallel ... |
The following question is from the book "Introduction to Algorithms" By Cormen and three other authors.
$26.2-10$
Show how to find a maximum flow in a network $G = (V,E)$ by a sequence of at
most $|E|$ augmenting paths. (Hint: Determine the paths after finding the maximum
flow.)
I find this question confusing because t... |
I am trying to understand how the Z-combinator (Y-combinator for applicative order languages) definition came about. As Python is applicative I am using Python for this.
So I know Python's evaluation order is applicative. But I seem to be overlooking something in how applicative order works. To compensate for applicati... |
Let $X=\{x_1,\ldots,x_n\}$ be a finite set of alphabet and $X^\ast$ denote the set of all words (including empty word) over $X$. Clearly, $X^\ast$ is a regular language.
Is there a subclass, say $C$, of deterministic context-free (DCF) languages over $X$ such that if $L \in C$, then $ X^{\ast}LX^{\ast} \in C$ and the g... |
In a geographical graph, where each edge's cost is equal to the physical distance between its nodes, one can be tempted to manipulate the cost of some of the edges, to make it a bit lower, in order to introduce preferred paths.
So that, in the following graph, the final route would be the one in green instead of the on... |
Since a processing core with hyperthreading enabled is presented as two or more cores to the operating system, it can run completely different processes with different, isolated virtual memory spaces. There must be a mechanism that guarantees process address space isolation. How is it done in Intel hyperthreaded CPUs w... |
I have been looking through different websites and forums but I can't seem to find any post about the similarities between bubble sort and selection sort. Can someone help me plese?
Thanks
|
i am trying find the Cost of an algorithm. it contains break statements. is there any cost of break and Continue statement in a Algorithm?
|
I know that the time required to check if there exists an edge between two nodes in an adjacency matrix is $O(1)$ because we can access it directly (i.e: $M[i][j]$). However, I didn't really get why time complexity in an adjacency list to check would be $O(|V|)$, where $V$ represents the vertices. Shouldn't it be $O(|E... |
Looking at the kernel function (Gaussian, polynomial. chi-squared, etc) how do we figure out that changing which value will cause overfitting? In my perspective, if we increase (for example) the variance term in Gaussian kernel expression, bias increases and overfit decreases. Is my understanding correct? Can the same ... |
Given two sets of items
$A = { a_1, .., a_N }, B = { b_1, .., b_M },$
and assuming a connection weight $w{_i}_j \ge 0$ between any possible pair $(a_i, b_j)$ that contains one item of each set, how can I identify the set of pairs $S$ that maximizes the sum of all involved weights: $\sum_{S}w{_i}_j$, under the condition... |
In my theoretical computer science class and we were covering "Heuristics". In it we covered "Greedy Heuristics" for the "Vertex Cover Problem", "Interval Scheduling" and the "Traveling Salesperson Problem".
In it we covered the "Nearest Neighbor", "Closest Pair" and "Insertion" heuristics approach to solve the TSP Pr... |
Thanks a lot for your help.
I want to understand what really causes what I suppose to be a deadlock:
I have standards objects, let's call it 'Words' that contains 3 letters and a key; (it doesn t really matter for my problem)
I have a container (list) of Couples, where a Couple simply is: 2 Words and 1 couple-Key.
I ha... |
My textbook has a problem to find the regular expression that describes the set of all strings of 0's and 1's whose number of 0's is divisible by 5 and whose number of 1's is even.
I can write a regular expression for each condition
a. $0^*(10^*1)^*$
b. $1^*(01^*01^*01^*01^*01^*)^*$
I am having trouble understanding h... |
I'm hoping for examples that aren't too abstract or useless in day-to-day programming, though not with a lot of hope, since in Bartosz Milewski's book, it is stated that generally speaking, the category Set is good enough, but mentions polymorphic functions and there not being a set that includes all sets as being one ... |
An edge cover of a graph is a set of edges such that every vertex of the graph is incident to at least one edge of the set. I am interested in finding the minimum edge cover of a tree such that each vertex is incident to an odd number of edges. Is anything similar studied in Computer Science?
|
I'm trying to help my daughter with her CS assignment on hashing. She has an input list of about 4000 English words, each 5 letters long. The prof has limited her to 4000 output buckets (digests? -- it's been a long time since I did this stuff). And the output from the hashing function is an int modulo 4000.
Her naive ... |
L is the language of all turing machines that its computing time on all inputs is O(n^2).
my thoughts is that the language is in CO-RE / RE. the language cannot be accepted because in order to make sure that there is no word W such that M halts on it after n^2 steps, you need to scan all words in the universe - infite ... |
First we generate a key,
$$k \leftarrow \{\, 0,1 \,\}^{n}$$
And we construct two PPT algorithms $A$ and $B$ as follow:
$$A_{k}\left( \cdot \right) \colon y_{A} \leftarrow k, \text{ return } y_{A}$$
and
$$B_{k}\left( \cdot \right): y_{B} \leftarrow \{\, 0,1 \,\}^{n}, \text{ return } y_{B}$$
For fixed $k$, let $D_{A}$ b... |
In page $4$ of this paper, Lemma 2.1 claims to establish a reduction from $k$-$SUM$ to $k$-$Clique$ problem:
For any integers $n,c,d,p \geq 1$ such that $p ≥ 3n^{\lceil
> c/d\rceil}$, there is a set of $s = 2^{o(d)}$ mappings
$f_1,\cdots,f_s:[−n^c, n^c] → [−p/3, p/3]^d$ and $s$ target vectors
$t_1,\cdots,t_s \in [... |
Let $\textit{G(V,E)}$ be an undirected connected graph with distinct costs on its
edges. Initialize $\textit{T}$ to be any spanning tree of $\textit{G}$. Consider an
algorithm which replaces an edge $\textit{e}$ in $\textit{T}$ by an edge $\textit{e'}$ not in $\textit{T}$, if $\textit{e' < e}$ and replacing it sti... |
I am trying to prove that a certain problem is $NP$-complete. The problem is that in a given order of elements like $(a>b>c)$, $(c>d>b>a)$, there will be inconsistencies. From these orders, you can conclude that $a>a$, which is an inconsistency. Removing all inconsistencies by removing the fewest amount of orders is th... |
We have a map of a branching river without any islands (tree of confluences, see picture), there are piers on the river bank ( not necessarily on the confluences). We are given the distances between individual confluences and distances between piers and confluences on any particular river segment.
How would we algorit... |
Given input sequence $x_1,...,x_n$, find the longest contigous subsequence $x_i,... x_l$ where each pair $(x_j,x_k)$ satisfies that $|x_j - x_k| \le p$.
I have come up with simple $\mathcal{O}(n^2)$ solution.
I'm sure there is a better way so I'm looking for $\mathcal{O}(n)$ or at least $\mathcal{O(n \log n)}$ solut... |
I'm reviewing my background in Algorithms and DS design. Specifically I never went through the van Emde Boas Tree. Though I can undestand the proto-vEB with related picture. I'm struggling to understand the actual data structure. I have no clue how the "min" and "max" members are actually used, I'm not talking about th... |
Contruct a Turing Machine that halts if and only if the tape it is on contains at least two '1's.
My attempt:
The gist of this turing machine is that it has to check all of the cells, and since it is infinite in both directions, one way of indexing it is a follows
Thus it has occurred to me to write a pseudocode for... |
Let us consider the lambda calculus expression .
$ (\lambda func.\lambda arg$ $( func$ $ arg)$ $\lambda x.x)$
Now $\lambda x.x$ is seen as an argument . How to decide which bound variable should the value of the argument go to ?
The books I am going through suggest that in this kind of case when there is one argument a... |
In a question, it is given that L is a finite language over the unary alphabet and L+ is not regular.
We know that L+ = LL*
Since L is finite, it must be regular because all finite languages are regular.
If L is regular L* is also regular.
Then how can be L+ not regular? It is the concatenation of two regular languages... |
Polar codes, invented by Arikan, with low encoding and decoding complexity. But the minimum distance of polar codes is not great. The normalized minimum distance goes to 0 with the block size. Yet, the existing decoding algorithms for polar codes can asymptotically achieve channel capacity.
Generally, a code with minim... |
There is this "folklore" result that gradient descent on a non-convex function takes $O(\frac n {\epsilon^2})$ steps to get to a point whose gradient norm is below $\epsilon$ and with SGD this takes $O(\frac {1}{\epsilon^4})$ steps.
Can someone share a reference where this is proven?
I am aware of the recent refer... |
Is there a cipher that well suited for preschool-aged children to work out on pencil and paper, to learn concepts of block chains?
It must have the following requirements:
Able to be easily verified
a. For example, Joe submitted red, but Suzy submitted blue. Everyone knows Suzy is right...somehow. (Color-specific resu... |
Let $A$ denote a set that contains a relatively large number of different strings. Let $S_i$ denote these strings.
Let $B$ denote a set of sets such that each subset contains a (relatively small, usually not greater than 100) number of different strings. Let $B_i$ denote these subsets.
The problem is the following:... |
Sorry if this is the wrong place to ask, was unsure...let me know if it belongs some where else.
So i am trying to work out a way to write an algorithm to place a series of small circles of a set radius (all the small circles have the same radius), inside a larger circle.
The small circles cannot overlap each other or ... |
I'm reading through CLRS again and I was wondering if there's a formal justification or construction of the accounting method, explaining why it works. For some reason it seems to me that CLRS basically expose the method explaining the intuition behind it, but it doesn't seem rigorous to me.
Also is it correct to say t... |
I have a sum:
$$S = \sum_{i=1}^n{\lfloor a/i \rfloor i^2},$$
where $a$ is a constant.
Is there a way to speed this up? That is, can we avoid iterating overl all $i$s, possibly calculating it in logarithmic or better time, something manageable when $a$ is big, n = a/2? I tried lots with pen and paper, but I cannot see ... |
I'm studying a declarative programming language (Prolog) and in thinking about how certain things are programmed at a low level, a question came to me:
are programming languages ultimately procedural ?
|
What is the goal of the SAT Problem?
Check if it is possible to have output '1'?
Above + find the right combination of inputs for that?
Witch one?
Cheers
|
i am new to analysis of algorithm . i am having an if condition.
If (I !=j AND A[i]==A[j])
i am counting the operations as
i) accessing element from Array A[]
ii)compairing i!=j
iii) compairing a[i]==a[j]
according to me this statement is performing 3 Actions. is it so ? if not than please clarify... thanks
|
in order for M to belong to L, it must halts on all inputs after 5 steps exactly. is the problem not decidable ? how can it be proved ? I could not succeed in doing a reduction from Htm as the attempt to count M(w) steps failed.
update:
apparently the language is in R. can anyone provide a proof?
|
With reference to chapter 17 of CLRS, (Amortized analysis). I'm trying to understand the differences between the accounting method and the potential method.
Let's start with standard analysis of the stack, three operations supported namely $\text{push}(x), \text{pop}(),\text{multipop}(k)$ the cost of this operations is... |
I have a collection of objects, with certain properties (let say 3 - zone, type, owner) only having a small predetermined possible set of values (like enum).
This is just a simple (javascript) array of gaming cards (think "magic the gathering"), that could be in different zones (deck, hand, grave, play), and they could... |
I've got a numeric matrix with 72 rows and 2 columns where the first column is the index value and the other column has sequence from 0 to 5 repeated 12 times. The dataset is like above:
1 0
2 1
....
6 5
7 0
....
72 5
I add the dataset graph
I would like to use machine learning with a clustering algo... |
I have a list of nodes l = [1, 2, 3, ... , n] and a list of tuples p = [(1, 2), (2, 3), ...], where the latter represents which pairs of nodes have an edge between them.
I would like to write a function that takes the above as input and returns a subset of the powerset of l where each set has nodes which construct a co... |
I need to prove the following:
reverse(append(zs, z)) = Cons(z, reverse(zs))
Where:
sealed abstract class IntList
case object Nil extends IntList
case class Cons(x: Int, xs: IntList) extends IntList
def append(xs: IntList, x: Int): IntList = xs match {
case Nil => Cons(x, Nil)
case Cons(y, ys) => Cons(y, appe... |
I'm studying some papers related to graph partitioning (GP). It is well-known that the GP problem is NP-Complete. Based on my understanding, it means that there is no polynomial time solution to solve this problem, or there is no optimal solution for that.
The following paper mentioned this fact in its introduction:
"... |
From my understanding of the proof that halting problem is not computable, this problem is not computable because if we have a program P(x) which computes if the program x halts or not, we got a paradox when giving P as an input to the same P, having: P(P), trying to decide if P halts or not using P itself.
So my quest... |
I understand that for every regular language, there exists an equivalent regular expression. However, can that be used in the opposite direction? Does every regular expression have an equivalent regular language? Or is the set of regular languages a subset of regular expressions?
If this is not the case, is there a goo... |
Which notation can be used for expressing how many times that function or subroutine called during a run of a program?
Example program pseudocode:
$
a \gets 0 \\
\textbf{While } a \neq 5 \textbf{ do} \\
\quad \textit{function1()} \\
\quad a \gets a + 1 \\
\textbf{end}
$
$g: functions \rightarrow \mathbb{N}$ and for th... |
Given positive intgers $N$ and $S$ i need to count in how many ways $N$ can be decomposed as sum of $S$ positive integers not greater than $\frac{N}{2}$:
$$ N = x_1 + \dots + x_S, ~~~~ 0 \leq x_i \leq \frac{N}{2} $$
Two partitions are considered distinct if any of the summands has distinct values in them. For example, ... |
In object-oriented programming, dot notation is used when accessing the properties or methods of a class:
Dog dog
print dog.name
>> "Fido"
dog.walk()
>> Walking the dog now...
What is the origin of that syntax and why the . to notate it? It must date to some early object-oriented language, but I couldn't find mention ... |
I am currently working on the following problem that involves developing a dynamic programming algorithm for finding the length of the shortest fully bracketed expression (FBE), $y$ that contains a given string $x = x_1x_2...x_n$. An FBE is defined as a string over the characters (,),[, and ] that is either
the empty... |
I'm playing around with finite field arithmetic and implementing it in a little library. I'd like to be able to handle arbitrary finite fields given their size and characteristic. I don't want to write down a prime polynomial for every given possible finite field though. How can I generate a prime polynomial of a given... |
I am wondering whether the Shortest Hamiltonian Path (SHP) problem is NP-Complete, because I couldn't find a way of solving it in a polynominal time. if it is NP_Complete, it will be so kind of you to give me the proof or the relevent papers,thanks a lot
the problem explanation: Given a directed,weighted graph with n ... |
I want to change the original TSP problem as follows: the cost to visit a city is not related to the previous city that it visited just now, but only on its position in the sequence. Is the problem of finding the minimal cost tour still NP-complete?
|
I've written a model which utilises deferred evaluation for many aspects of its feature but in one instance of its use it is mixed with threaded eager evaluation for things that are expected to be used at some point.
Is there a term for mixing lazy and eager evaluation, possibly when mixing with threading?
|
I'm trying to implement counting sort in Haskell for a list of type (Int, String). I've been trying to do it according to Wikipedia's description.
After some attempts, I gave up, because the Wikipedia description makes heavy use of mutation in different places throughout the algorithm, which I just don't know how to tr... |
While writing array index in an algorithm $a[i]\gets v$ is conventionally used. Is the notation $a_{i}\gets v$ also used ?
If the algorithm uses struct or equivalent, some notation is required for property access. In some occasions $p(s)$ is used where $p$ is the property. Using $s \rightarrow p$ messes up with the as... |
The following algorithm is supposed to compare two strings $S_1$ and $S_2$ ("/\" for empty string):
X = S1
Y = S2
E = true
// (1)
while X != /\ and Y != /\ and E == true
if head(X) == head(Y)
X = tail(X)
Y = tail(Y)
else
E = false
// (2)
if !(X == /\ and Y == /\)
E = fa... |
I have a few questions regarding slotted-ALOHA. Assume a network have 25 users and transmission request probability = 0.25.
1) What is the throughput and what is the probability that a user will successfully transmit a frame after three unsuccessful attempts? I have managed to calculate the throughput as 0.00627. But t... |
Given a biased coin whose probability for Heads is 0.67 and Tails is 0.33, write an algorithm which will print the Heads and Tails with this probability.
I am not able to proceed with the problem. What should be my approach ?
|
We have sequence that we got from topological sort, but because the graph may not be connected in all cases, we should sort this sequence with another factor.
We should output permutation of numbers from $1$ to $n$ such that we also have graph $G$ that is without cycle and might be not connected and array $A$ of intege... |
Given an huge iterator (millions of random elements) and asked to obtain the top 10 elements in descending/ascending order.
What is an efficient way or algorithm to do this?
NOTE: The iterator size is to huge and cannot be all loaded into memory and in-place sorting done. (I need a different approach)
I have a simple ... |
Let us consider the following lambda expression :
$ (\lambda func.\lambda arg$ $( func$ $ arg)$ $\lambda x.x)$
so $ (\lambda func.\lambda arg$ $( func$ $ arg)$ $\lambda x.x)$
can be seen as $ (\lambda func.(\lambda arg$ $( func$ $ arg))$ $\lambda x.x)$
and will be in a form $ (\lambda x$$.M) N$ form.
As such this can... |
What do Computer Science mean when they use the Term Elementary Operations?
|
The main question is the following:
When designing a system supporting atomic broadcast, can it be proved theoretically that the performance & scalability dimensions (i.e. latency, throughput, dataset size) of the system are limited by the performance of a single node?
To give an example:
A system based on partitioned-... |
I just need to know the truth or falsity of a simple statement.
Let $L_1$ be a context-free language over an alphabet which contains some number of characters $\Sigma$, as well as a single, special metacharacter “|”. Suppose that every string in $L_1$ contains exactly one metacharacter. Let the left half and right half... |
I would like to know the computational cost of using/accessing a dictionary.
This should depend on the length of the dictionary. Say a dictionary $D$ has $n$ elements.
What would be the cost of accessing one of those elements in terms of simple floating point operations (addition, subtraction, multiplication, division... |
Suppose I have a lot of data on conversations between humans and chatbots (human text, chatbot text, times, media used for chat, etc), and I want to be able to detect anomalies in these conversations. For example, an anomaly would be if the chatbot was supposed to help customers with navigating a website, but the websi... |
I meet a problem. I can find a sub-optimal solution, but cannot find an optimal one and cannot prove its NPC hardness.
The problem can also be described as follows. Given a sequence $X=\{x_1,x_2,...,x_n\}$, a partial order $<$, where $x_i <x_j$ means that $x_i$ must be in front of $x_j$, and a new item $x_k$ as well as... |
Many people on different articles suggests that if an optimization problem has a greedy solution, the underlying structure must have matroid property.
I was trying to understand this. So far, I was able to prove that for,
Maximum sum of m integers among n integer.
Minimum spanning tree.
However, The classical g... |
Let AP = {a; b; c}.
Consider the following regular safety properties:
(a) P1: If a becomes valid, afterwards b stays valid ad infinitum or until c holds.
(b) P2: Between two neighbouring occurrences of a, b always holds.
Construct an NFA Ai for each property Pi such that L(Ai) = BadPref(Pi).
Hint: You may use a symbol... |
I have a file with a list of non-overlapping trapezoid covering the entire 2D space (they are adjacent if they share a segment of finite length not a point).
The trapezoid are 4 points polygons which in this case are allowed to have only 90, 45, 135 degrees angles. This means their sides are parallel to x,y axis or til... |
I've recently been trying to learn to program in python but I’ve been experiencing this overwhelming feeling of a desire to understand the underlying structure behind everything I’m doing. I want to be able to understand how computers work from the ground up, how hardware and software relate to one another and develop ... |
Suppose I have a 3-SAT formula in CNF with $ m $ clauses on $ n $ variables,
$$ F = C_1 \wedge \dotsb \wedge C_m, $$
with each clause $ C_i = l_{i_1} \vee l_{i_2} \vee l_{i_3} $ and each literal $ l_k \in \{x_1, \bar{x}_1, \dotsc, x_n, \bar{x}_n\} $.
Define the cost $ E $ of each assignment $ \mathbf{l} = (l_1 \dotsb l... |
So first of all I've a software which basically locks/encrypts a folder with a given password. Afterwards it's almost impossible to open the folder without entering the password through the software.
I locked some of my much needed files and accidently forgot the password.
So my question is, is it possible to retrive t... |
So I am currently going over the ResNet paper and trying to understand the output dimensions of each of the layer, and it seems that I am already stuck on the first layer and its output dimension.
If I understand correctly, the size of output of a particular layer can be calculated as (ORIGINAL_SIZE - FILTER_SIZE) / ST... |
How can I get started at finding a recursive/dynamic solution to the problem?
For example, how many adjacent swaps is at least needed to convert the given string abaaccbabaabcab (representing all other characters as c) to one without any instances of "ab"? It's elusive for me to come up with a way of breaking the probl... |
I am currently following the proof, found here, that Rado's function
$$
\Sigma (n) = \max \{ \text{# of 1's that may be written to a tape by an n-state turing machine} \}
$$
is non-computable. Within this proof, they say that there exists a Turing machine $M_F$, which we say has $n$-states, that writes $F(x)$ 1's to th... |
Can anyone please help me to understand what the complexity of checking whether
$$
f(x) \equiv g(x) \hspace{3mm} (\text{mod } h(x), n)
$$
might be? This notation denotes that $f(x)$ is congruent to $g(x)$ in the quotient polynomial ring $\mathbb{Z}_n / h(x)$.
I am basing this question on my attempt to understand the co... |
I have seen numerous proofs (such as this) that the Halting problem is in the class of NP. However, the Halting problem is non-computable.
Does it make sense to discuss the complexity of computing a function that cannot be computed?
|
The Y combinator expression is as follows:
$$ Y \equiv \lambda f .(\lambda x .f(xx) )) .(\lambda x .f(xx) ) $$
Now , if I am not wrong , then this expression can be reduced by seeing this as the argument:
$ .(\lambda x .f(xx))$ hence would lead to the consumption of first bound variable giving:
$$ (\lambda x .\l... |
Write an algorithm to determine if there's a set of > n/4 balls of the same weight. The algorithm cannot exceed O(n log n) time.
One way I was thinking about this was using divide and conquer. My original algorithm was as follows:
findSet(S) #S is the set of n balls
If |S| = 1, return the lone ball
If |S| = 2 o... |
My professor assigned us to read Thompson' Regular Expression Search Algorithm paper. I am struggling to understand the third stage of the compiler. The first two stages are as follows:
Check that the RE is syntactically correct
Convert RE to reverse polish form
The paper states "the third stage is at its heart a p... |
given a weighted undirected graph with $N$ vertices $(N \leqslant 500)$ we start from vertex $S$ and wo go to $M$ and then we go to $T$ and then we return to $S$.
each edge in graph has weight $a_i$ at the beginning but after the first time we pass any edge that edge weight will become $b_i$. ($b_i \leqslant a_i$)
the... |
where $L_{1} \cup L_{2} \cup L_{3} = \sum^{*}$ and
$L_{1} \cap L_{2} = \emptyset$ and $L_{2} \cap L_{3} = \emptyset$ and $L_{1} \cap L_{3} = \emptyset$
is it possible that $L_{1}$ is decidable, $L_{2}$ is recognizable but not decidable
and $L_{3}$ is not recognizable?
If so please give an example, if not why?
By recog... |
Given is a set of $n$ items: $x_1, x_2\ldots, x_n$. Additionally, we have a non-symmetrical evaluation function $f(x_i, x_j)$ that gives a cost value of two items. Note that $f(x_i, x_j)\neq f(x_j, x_i)$.
We want to find a list $y$ containing all items from $x$ exactly once such that the total cost of $y$, given by $F... |
Given an array with n rational numbers, element in is array called popular if it have appeared at least in 51% of the indices.
I have to design an algorithm that finds such element in O(n) worst case complexity time, that if there is one.
The only ideas I have is to use hash tables but the complexity time is O(n) in av... |
is there an approximate algorithm that takes as input: an weighted undirected graph $G = (V,E,W)$ and an integer $k > 0$ and outputting: a subgraph $g'$ with $w(g') \geq k $, and $|g'|$ is minimum. For example
in this graph, with $k= 65$, the solution is $g'=\{2,4,5 \}$
|
I have a rough idea of what coalescing in terms of memory access by threads is, but now, when learning about compilers, the term coalescing also appears when talking about register allocation.
In my book, it is just briefly mentioned, that coalescing for register allocation is just merging nodes from the graph (I assum... |
So in a recent algorithm contest I was given a task to create an algorithm that could construct a rectangle out of n triangles.
The information that is available to me is:
Width and height of the rectangle
Coordinates of all three corner points of each triangle
All triangles have to be used that are given
Triangles ca... |
How can we know that a specific ILP problem is solvable in polynomial time or not given the constraints?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.