instruction stringlengths 35 29.1k |
|---|
Let's say there is a NFA with $n$ states with an alphabet consisting of $x$ symbols. I convert it to an equivalent DFA. Can I say that the number of states in the equivalent DFA is $x^n$?
|
Given a planar graph G with $N$ nodes, 4 colors are enough to color each node, so that adjacent nodes have different colors.
Let $k > 4$. Is there an algorithm to color the nodes with $k$ colors, so that the colors are distributed the most equally possible?
In other words:
Let's call $c_1, ..., c_k$ the colors. We defi... |
I started reading on Probabilistic algorithms and Monte-Carlo algorithms. Since a Monte-Carlo can only give a certain answer for either True or False, I was wondering if it's conceivable that for the same problem, there exist two opposite Monte-Carlo Algorithms capable of giving a certain answer. (By opposite, I mean o... |
In D. Paterson's book, Computer Organization and Design, Fifth Edition, there is a paragraph that says
Instruction fetch: The top portion of Figure 4.36 shows the
instruction being read from memory using the address in the PC and
then being placed in the IF/ID pipeline register. The PC address is
incremented by ... |
In binary search, we need an array of integers for it to search for an element. Also, many other sorting algorithm sorts array of integers.
But in real world, we may search for a name of an employee in a database, title of a post etc. So how does binary search actually works in such cases? Is the data converted and sto... |
I am going over some practice questions for the Major field exam and it asks:
A processor with a word-addressable memory has a two-way set-associative cache. A cache line is one word, so a cache entry contains a set of two words. If there are M words of memory and C cache entries, how many words of memory map to the... |
I could not think of a way to concisely write down my question clearly, but I'd like to ask, from Sipser's book, $ALLCFG$ is an undecidable language (where $ALLCFG$ means that $G$ is a $CFG$ that generates $\sum ^*$).
In his textbook, there is a polynomial reduction from $\bar{{ATM}}$ (complement of $ATM$, where $ATM$... |
Does the following set of production rules produce a regular language or not?
$S \to AB \mid b $
$A \to SB$
$B \to AS \mid a$
I have generated following words with above grammar
$b , baa , baaaa , baaaaaa, .....$
$bbaba , babab , bababaa , bbbabba ,.....$
But I am not able to create a language using it.
Is this gram... |
I know different parts of this circuit, just I have a problem with that part that I circled in picture.
I want to know the function of that part.
If you have useful information about it, please share it with me.
Thank you so much.
|
How come O(n) + O(logn) = O(logn)?
When talking for example about an algorithm that has two operations. One of them takes O(n) and the other O(logn) and in the end we say that the total complexity is O(logn). It doesn't make sense to me since n is bigger than logn.
|
I am new to automata and learning to make regular expression for languages. But I have been stuck on this one.
Suppose we have a language L, Language of all strings that has exactly 1 triple “b” defined over alphabet set Σ = {a, b}
Now after several tries, I came up with this
(a* (ab)* (ba)* )* bbb (a* (ab)* (ba)* )* b... |
Suppose I write a program as below:
int main()
{
int a = 3;
int b = 4;
return 0;
}
Suppose the computer stores the address of 'a' as 0x00104. How does it associate 'a' with 0x00104?
|
I took an algorhytm course on coursera and there some optional questions for student enrichment. I can't solve the following task:
Decimal dominants. Given an array with n keys, design an algorithm to find all values that occur more than n/10 times. The expected
running time of your algorithm should be linear.
And ... |
Can somebody tell me how to solve this problem?
|
I haven't found a good enough answer by googling. Here's what i know:
TG's can have more than one initial state
In TG's, Edges/transitions can be labelled with strings
In TG's, it is not necessary to show transitions for all letters
Notes:
I am talking about plain TG's, not GTG's and DFA's only not NFA
Only thing i... |
I am wondering, is it is possible to create a regular language from a non regular language if we add or remove finite number of words from it?
say L is irregular, if we add or remove finite number of words can we create a regular language?
i might be mistaken, but since all regular languages are finite - if we add a fi... |
It holds that if SAT could be solved in poly time, one can also find in poly time the assignment that satisfies most clauses of the original formula.
Does anyone have any idea how to show this?
Let's assume we have algorithm A to decide in poly time if a given formula could be satisfied or not. How one can use this to ... |
$r_3=r_1r_2=(a^*b)^*(a+ba)^*bb(a+b)^*$ comes out to be $r_3=r_2=(a+ba)^*bb(a+b)^*$ when i generate the resultant FA and its regex after concatenation i.e. it doesn't include $r_1$
Details:
Consider these two FA
$FA_1$
$FA_2$
if $r_1,r_2$ and $r_3$ are regex for $FA_1,FA_2$ and $FA_3$ respectively where
$r_1=(a^*b)^*$... |
I'm trying to design a DFA in a 4 digit language, for example L(a,b,c,d) or L(1,2,3,4) that accepts strings with the last character being already repeated before.
Everyway im trying, i get so many transitions im literally lost in them...
So, for example, abbdb is accepted (because b is showed again at least 1 time) but... |
So I'm watching Stanford's algorithm lectures and I'm on Kosaraju's algorithm. In the lecture, the algorthm was given in 3 steps: calculate the graph with all arcs reversed, run dfs on reversed graph, run dfs on original graph. Then an optimization was given, which was to instead of using the naive implementation of re... |
I am looking for an unrestricted grammar which generates the following language:
$\{ a^1\#a^2\#a^3\# \dots \#a^k \mid k >0 \}$
That is, words like $a\#aa\#aaa\#aaaa\# \dots \# \text{$k$ times '$a$'}$.
|
Is it possible to find minimum dominating set on a tree $G$ using a greedy algorithm?
|
For regular languages $A,B\subseteq\{0,1\}^*$, is
$$L_2 = \{x \in A \mid \exists y \in B : |x|_1 =|y|_1 \}$$
regular, where $|x|_1$ means the number of appearances of 1 in the word $x$?
i need to demonstrate $L_2$ automata.
Thought about using the multiplication automata, not so sure.
|
I've written an algorithm to find duplicate integers in a sequential list of integers, but I'm running into issues when trying to calculate it's worst case complexity.
Given a sequential list of integers the algorithm is as follows:
1. get the length of the list of integers, assign to list_length - O(1)
2. while list_l... |
I'm doing a polynomial time reduction from problem A (known graph problem) to problem B (funky and specific longest path problem). There is a lot of demands on how problem B is supposed to be solved. However, the input of problem A does not give me enough information to be able carry out all of these demands that probl... |
The value in the parenthesis of language expressions signify how many next symbols are needed to make a decision.
For example, without reading a symbol from the input, we cannot decide in LL(1) grammars which rule must be applied for derivation.
In this point, Some thought like that occurs: we can make a decision with... |
I got an ILP Model where $c_i$ represents the starting time for a visit$_i$.
$c_i$ is already constraint by a number of constraints, one is $c_i > 0$.
I have now outside of my model 0 or multiple desired intervals for the visit$_i$, lets call them $dStart_{ik}$ and $dEnd_{ik}$ where k represents the k-th desired interv... |
I'm trying to analyze an algorithm that looks like this:
def foo(L):
for n in L:
for x in range(n):
...
What would be its time complexity? First I thought $O(n)$, where $n$ is the number of elements in $L$, but that seems a little optimistic given that numbers can become very large. Then I thou... |
I am starting a raw food diet and would like to properly plan it, and thus, would like to create a program that takes a list of available raw food, and finds the best combination of foods (multiples allowed) with the lowest total price.
Does anyone have any advice as to how to approach this problem? Is there a certain ... |
This question concerns the classes P and N P . If you are familiar with them, you may skip the definitions and go directly to the question.
Let L be a set. We say that L is in P if there is some algorithm which given input x decides if x is in L or not in time bounded by a polynomial in the length of x. For example, t... |
I have a hard time to find the goal of having $co-NP$ problems.
$NP$: Is there a Hamiltonian path in this graph?
We need to bring a certificate, and the verifier checks the certificate in polynomial time. However, finding such a path might not be done in polynomial time. It may need searching the entire problem spac... |
I recently started studying about approximation problems in the complexity class that I'm taking. I feel like some of the definitions in this subject presented in my course and that I came across online are somewhat inaccurate and confusing.
Specifically, the concept of gap problems wasn't completely clear to me. It wa... |
What are other algorithms that use the divide-and-conquer paradigm aside from merge sort and quicksort?
|
i have a theoretical questions, and was wondering if you could help me with it so i could understand the material better.
1)suppose we have some language L over $\Sigma$, can we know if L is regular if all of it equivalence classes of relation $R_L$ is finite?
2)and what about L*? is it finite? i mean the cardinality i... |
I am dealing with deterministic parity automata and state space reduction (not minimization).
If we define $\equiv_L$ to be the equivalence relation that sets two states equal iff starting from those states the automaton recognizes the same $\omega$-language, merging those states is in general not an operation that pre... |
Say I have the following statement:
If $f(n) = O(s(n))$ and $g(n) = O(r(n))$, then $f(n) - g(n) = \Theta(s(n) - r(n))$.
What would be a counterexample to this?
|
The task is to show that given algorithm has STOP property and to find its computational complexity function.
$\alpha:$ $n \ge 0$
void fun(int n) {
a=0;b=n+1;
while ((a + 1) != b) {
p = (a + b)/2;
if (p ∗ p > n)
b = p;
else a = p;
}
}
I have already proven its parti... |
I need an algorithm which generates a random matrix with spectral radius equal zero.
The only solution I have so far is to generate two vectors $v,w$, normal onto each other ($v\perp w$), and then take the product $vw^T$. But this is numerically not very stable, and the resulting matrices have spectral radii in the or... |
What is the power of a Turing-machine that cannot write?
So it can still read and go back and forth on the tape, but it cannot write.
I am wondering what this would be equivalent to in the computational hierarchy.
I suppose this would be a finite-state automaton, but it can go left and right along the input: does that ... |
There are several periodic tasks (Period, Execution time),
e.g.:
A = (20, 9)
B = (12, 4)
C = (4, X)
What methods/tests can be used for finding the maximum execution time X for which the task set will be schedulable by Rate Monotonic.
|
I start with a matrix, lets say 4x4. So I want the N top scores, with the sum of one element of each row. For example:
M[4][4] = {
(13, 8, 5, 3),
(11, 9, 7, 4),
( 8, 6, 2, 1),
( 6, 5, 4, 1)
}
So the top 6 scores of that matrix will be:
top_scores = {
(13, 11, 8, 6), // 38
(13, 11, 8, 5), // 37
... |
Let $G$ be an undirected connected weighted graph, and let $T$ be a minimum spanning tree of $G$ with edge weights: $w_1 \le w_2 \le ... \le w_{n-1}$.
Now let $T'$ be some other spanning tree of $G$ (doesn't have to be minimum) with edge weights: $w'_1 \le w'_2 \le ... \le w'_{n-1}$.
I need to prove\disprove the follow... |
This is what I have:
$$(1^*011^*011^*)^*\,.$$
But I don't think this is accounting for an odd number of zeros, like "$10101010101111$". I think I have the right expression that satisfies no 2 consecutive zeros and even number of zeros. Can someone help? Thanks!
|
I recently came across this language:
$L=\{<TM>| \text{TM accepts recursively enumerable languages}\}$
It was asked in the question to find out whether language L is decidable or undecidable.
As far as I could reason out, language L is the set of all recursive enumerable languages or set of all turing machines.
But I... |
I'm trying to find the CNF of the $(p \rightarrow q) \rightarrow p$ and $\lnot (q \wedge (\lnot p \rightarrow q))$, and afterwards proving it's validity. As i'm new to CNF i wanted to ensure i've found the right CNF before trying to move on, so for $(p \rightarrow q) \rightarrow p$:
the normal from is:
$p \rightarrow q... |
Currently going through a video on Counting Minimum Cuts by Tim Roughgarden.
$(A_{i},B_{i}) = \big((A_{1},B_{1}), ..., (A_{t},B_{t})\big) \forall i \in \Bbb{R}$
$P\big((A_{i},B_{i})\big) \geq \frac{1}{\begin{pmatrix} n \\ 2 \end{pmatrix}} = p$, which I interpret as the lower bound on the probability of having at least... |
Suppose a problem A reduce to problem B and reduction is done in $O(n^2)$ time.
If problem B is solved in $O(n^3)$ time then what about the time complexity of problem A?
Approach:
A is reduced to B . Here reduction is done at polynomial time.
Here B is solved in polynomial time. So A should also be in polynomial tim... |
Seems very trivial but I'm confused which one of these correctly define transmission time.
Time taken by a message to reach receiver.
Time taken to push message on the link by the sender.
Which one is correct one?
|
Let $L_1$ and $L_2$ be two decision problems.
Is there an algorithm deciding whether $L_1 \leq_P L_2$, that is, whether $L_1$ is reducible to $L_2$ in polynomial time?
|
This should be a simple question, but I am a little bit confused.
A proof on page 556 of Algorithm Design says:
"Let $e=(u, v)$ be any edge of $G$. The graph $G$ has a vertex cover of size at most $k$ if and only if at least one of the graphs $G-\{u\}$ and $G-\{v\}$ has a vertex cover of size at most $k-1$."
But when I... |
Minimum number of components in graph where we have 69 vertices and 43 edges. I think the best way is to create a path? One path and the rest would be isolated components. Since in path we use only one edge for 2 vertices. Correct?
|
I'm working on solving an algorithm problem defined as follows (important parts in bold):
Your task is to construct a building which will be a pile of n cubes. The cube at the bottom will have a volume of n^3, the cube above will have volume of (n-1)^3 and so on until the top which will have a volume of 1^3.
You are g... |
I've been looking into weighted matching in bipartite graphs and am currently looking at maximum matchings in weighted bipartite graphs. As I've been reading and poking around at different books and papers, I've noticed that the Hungarian/Kuhn's algorithm tends to get mentioned a lot as a solution/approach. My sticking... |
Example: If it takes $O(n^2)$ to solve A and it takes $O(n^3)$ to reduce A to B.
So, it is certain that that B is at least as hard as A and takes at least $O(n^2)$ time to be solved.
Can we say something similar for reduction time and B such as B takes at least $O(n^3)$ time to be solved?
My thoughts: I think it has n... |
Suppose a given piece of work can be done at two processors. One at r and another at v. The job can run only at one processor at a time.
r = R1, R2 ... Ri, ...Rn
v = V1, V2,... Vi, ...Vn
There is a time penalty to switch between r and v, which is a constant say k. But I will have to maximize the total work done with... |
...Knowing whether a Turing machine will ever output your name on the tape. The language is the set of all TMs that print your name. Reduce from HALT TM.
I had this problem on my exam. From my understanding, the halting problem involves a program with some input, and that program will either output yes or no as output... |
This is about scheduling. I have N tasks of different length and I have to schedule them into M days. Indeed, each day has a max capacity (usually they are the same). Parameters are tight in the sense, that the sum of taks' length is exactly the same as the sum of day's capacity, e.g. tasks of total length 150 must be ... |
Let $G$ be an undirected and connected graph. Let $T$ be a spanning tree of $G$ with edges weights: $w_1 \le, w_2 \le ... \le w_{n-1}$ which are responing to the edges. $e_1,e_2,...,e_{n-1}$.
Now I assume that there exists a spanning tree of $G$, let's call it $T'$, that has a path from node $u$ to node $v$ with all ed... |
What is the best algorithm for this?
We are given an array of positive integers and we want to minimize the total cost of recursively adding together all the integers to one integer, two integers at a time. The cost of each addition is the sum of the two integers, and this sum adds up cumulatively. After each addition,... |
I've been writing a 3-SAT solver for fun and comparing its performance against the solver pycosat. My solver vastly outperforms pycosat in two special cases, where I solve by doing simple, obvious checks, which pycosat doesn't seem to do (based on the time it takes to solve these cases).
I presumed that these checks wo... |
I tried few cases and found any two spanning tree of a simple graph has some common edges. I mean I couldn't find any counter example so far. But I couldn't prove or disprove this either. How to prove or disprove this conjecture?
|
I came across a question stated as $L = \{wxwy \mid w \in \{0,1\}^* , x,y \in\{ 0,1\}^* \}$ is regular and I have no problem understanding it.
However I thought what could happen if the language is modified to $L = \{wxw \mid w \in \{0,1\}^+ , x \in\{ 0,1\}^* \}$.
In my opinion the above language is regular and it repr... |
It seems intuitive that there's no list data structure which has $\mathcal{O}(1)$ worst case time complexity for random access and a worst case complexity better than $\mathcal{O}(n)$ for insertion: if insertion is allowed to affect only a small part of the list, then there's no way for it to always keep the entire li... |
consider following persudocode:
i=0
while(i< k):
uniformly pick u,v in V
if(uv in E):
remove uv form E;
i++;
let $T$ be the number of iteration of this process,
I know how to compute the expectation, but what is well bound for
$P(|T -E[T]|)$? And is this process independent?
|
I'm studying programming languages (more specifically type systems) and came across a concept I couldn't quite wrap my head around: soundness and completeness.
I'm taking a class, and according to my instructor:
Soundness is an analyzer's ability to prove the absence of errors. If a program is accepted by an analyzer,... |
I was learning about segment trees and came across this:
We have an array arr[0 . . . n-1]. We should be able to
1 Find the sum of elements from index l to r where 0 <= l <= r <= n-1
2 Change value of a specified element of the array to a new value x. We need to do arr[i] = x where 0 <= i <= n-1.
A simple solution ... |
I have undirected and unweighted graph, in which I would like to find the shortest path between two entered nodes. There is also a set of forbidden nodes. How to find the shortest path, if I am allowed to visit at most one node from the set of forbidden nodes?
|
It should be a very easy question, but I am a little bit confused.
According to party optimization post, the Maximum-weight Independent Set for trees can be found in the poly-nominal time using Dynamic Programming (the Algorithm is also explained on page 562 of the book Algorithm Design). Now, imagine that we want to t... |
I understand how the control, data and instruction buses form the system bus in von Neumann architecture but in the context of Harvard architecture, my textbook refers to "parallel data and instruction buses". The Wikipedia article for Harvard architecture also refers to an instruction bus: "TMS320 C55x processors, for... |
Is there any way to model the big M method for continuous variables?
Something similar to this but $B, C \in \mathbb{R}_{\geq 0}$ and $A\in\{0,1\}$.
Due to the precision problem, when the $B$ and $C$ are close I do not get the correct answer.
Let $p_{i,j} \in \mathbb{R}_{\geq 0}$, for $i=1,\dots, n, j=1, \dots, m$. As ... |
\begin{align*}
S&\to AACD\\
A&\to aAb\\
C&\to aC\mid a\\
D&\to aDa\mid bdb\mid\varepsilon
\end{align*}
I think that this grammar is infinite so it is not possible to convert it into cnf. Am I correct ?
|
Considering a cactus graph $G = (V, E)$, defined as:
A graph is a cactus if every edge is part of at most one cycle.
There is a way to calculate the number of cycles in this graph given only $n= |V|$ and $m = |E|$?
I did some examples before posting this, but now I think I got somewhere.
If $G$ is connected, $m = n-1... |
Using probing, is it possible for for a hash table's load factor to exceed 100%? I don't too much about Hash Tables. Is this possible?
|
The Problem
I have a set of sets of time intervals (hour, minute, day of the week). I want to select exactly one interval from each of set, and I want to minimize...
the number of pairwise intersections,
the total number of days,
the total time,
minus (the average start time), and
the average end time.
The number of ... |
I'm having trouble with proving the following, and my attempt and confusion is mentioned further below.
PROBLEM STATEMENT:
For a string $w = a_1 a_2 a_3 a_4 a_5 a_6 a_7 \dots$, define $third(w) = a_3 a_6 a_9 \dots$
Then, for a language $L$, define $third(L) = \{third(w) : w ∈ L\}$.
Show that if $L$ is regular, then $t... |
Consider the Minimum Spanning Tree Problem on an undirected graph
G = (V, E), with a cost ≥ 0 on each edge, where the costs may not all
be different. If the costs are not all distinct, there can in general be
many distinct minimum-cost solutions. Suppose we are given a spanning
tree T ⊆ E with the guarantee that for ev... |
In college, we've seen some general formulas to compute the decimal value a of a binary representation $a_{N-1} \dots a_2 a_1 a_0$ in two's complement, $N$ being the number of bits.
For $a \ge 0$ we've seen $a= \sum_{i=0}^{N-2} a_i 2^i$, which seems correct to me if I work it out.
But for $a < 0$ our book says $a=-2^{N... |
I read that there are 4 types of rotations:
Left rotation
Right rotation
Left-Right rotation
Right-Left rotation
What are the corresponding abbreviations: RL,LR,RR,LL? Is there a reference how to rebalance AVL trees?
|
Given:
A set of available customers $c_1, c_2, \dots, c_n$.
A set of available foods $f_1, f_2, \dots, f_m$.
Each customer will choose a subset of the available food.
Problem:
Find the maximum number of customers that can be chosen, such that no two customers share the same food.
Question:
How to reduce the indepe... |
In our lecture notes about many-one reduction we showed that the following statements hold:
$$ L, L' \subseteq \mathbb{N}\space and \space L\leq L'$$
$$(I)\space L' \in RE \implies L\in RE$$
$$(II)\space L \notin RE \implies L'\notin RE$$
Now I was wondering if this would also be true if you'd reverse these statements ... |
I know the Floyd-Warshall, and I also clearly understand the proof of running time of $O(V^3)$ of F-W algorithm. However, consider this algorithm:
Let $dp[i][j][n]$ denote the shortest path from $V_i$ to $V_j$ using at most $n$ vertices. Use $dp[i][j][n] = \min_{V_k\text{ adjacent to } V_i} (e_{ik}+dp[k][j][n-1], dp[i... |
If a grammar has the same variable multiple times, is it the same as adding a $\mid$ between them? For example, is
$$\begin{align*}S &\to bB \\
S &\to \varepsilon \\
B &\to cB \\
B &\to \varepsilon \end{align*}$$
equal to the following?
$$\begin{align*}S &\to bB \mid \varepsilon \\
B &\to cB \mid \varepsilon \\
\e... |
I came across this question in a test and I had to answer whether it is true or false.
DFA with single final state has the same powers as DFA with more than one final state.
I was confused by what definition of "power" have they used. Generally, we always use power as a term to represent the class of languages a mach... |
I have trouble understanding how to apply the master theorem in the following problem:
$$T_2(1) = 1; T_2(n) = 4T_2(2^{\log \lfloor \frac{n}{2}\rfloor}) + \sqrt{n} \text{ for } n > 1.$$
My professor first rewrote this problem as
$$ T_2(n) = 4T_2(\lfloor \tfrac{n}{2} \rfloor) + \sqrt{n} \text{ for } n > 1, $$
which I d... |
Suppose I have an AVL tree with a pointer to the minimal element. I'd like to conduct a search for some key x, which is the $k$-smallest key in the entire tree.
I can do this by "climbing" up the tree's left branch, comparing x with the current key. As long as
(x > curr.key) && (x > curr.parent.key)
I keep climbing ... |
A binary matrix of nxm is given, you have to toggle any column k number of times so that you can get the maximum number of rows having all 1’s.
for eg, n=3, m=3,
1 0 0
1 0 1
1 0 0
if k=2, then we will toggle column 2 and 3 once and we will get rows 1 and 3 with 1 1 1 and 1 1 1 i.e. all 1’s so... |
The following is Dijkstra's algorithm for finding the shortest path in a graph. I know something wrong happens if I replace d[u] + weight(u,v) < d[v] with d[u] + weight(u,v) <= d[v]. What would be an example of the algorithm working incorrectly with that replacement?
def dijkstraShortestPath(G,s,t):
d[v] = Infinity f... |
I'm currently following a course and we have to prove that a restricted version of the 3-SAT decision problem where each literal appears at most once is solveable in polynomial time.
I think such a problem is always satisfiable since we can just assign any sub-expression the needed truth value without it interfering wi... |
Consider the following predicate formulas.
$F1: \forall x \exists y ( P(x) \to Q(y) ).$
$F2: \exists x \forall y ( P(x) \to Q(y) ).$
$F3: \forall x P(x) \to \exists y Q(y).$
$F4: \exists x P(x) \to \forall y Q(y).$
Answer the following questions with brief justification.
(a) Does $F1$ logically imply $F2$?
(b) Does $F... |
CS community!
I'm more of a practical programmer than a computer scientist, so I need your help to find a solution (or at least point me into the right direction) to an extremely practical problem related to cooking food in the oven.
Problem
I have N ovens and I have multiple various ingredients to cook in them.
Each i... |
The following is a natural language description of a first order theory from Worboys. Only Axiom 11 and the Theorem 4 are written in mathematical notation.
Theory 1
Aland, Bland, Cland, and Dland are countries.
Eye, Jay, Cay, Em, and Ell are cities.
Exe and Wye are rivers.
City Eye belongs to Aland.
City Jay belon... |
I need to group cars (and their passengers) with other cars, and I don't know how to approach this problem.
If I have, for example, 3 cars. Car A with 7 seats and 2 passengers (3/7 because of the driver). Car B, 2/2. Car C, 1/3.
The most wasteful clustering would be [A, B, C]. But car C has room to pick up the driver a... |
From Wiki - Superscalar processor:
(Line 1): superscalar processor is a CPU that implements a form of parallelism called instruction-level parallelism within a single processor. In contrast to a scalar processor that can execute at most one single instruction per clock cycle, a superscalar processor can execute more t... |
Suppose that we have a grammar with the following rules:
$$S \to Aa\ |\ b\ |\ \varepsilon\\
A \to Ad\ |\ c$$
From looking at it I already know that $First(S) = \{b, \varepsilon, c\}$. My question is:
How to determine $First(A)$?
For instance, by looking at the rule $S \to Aa$ we know that $First(S)$ must include $Fir... |
I want to construct a DFS and a BFS spanning trees for the graph below. The root is node a. At each step the next edge to be traversed should be the cheapest one.
DFS:
My understanding that to the construct this DFS where each next is the cheapest one, the resultant spanning tree would be:
{(a,c), (c,h), (h,g), (g,f... |
Systems of formal logic generally have inference rules that
require certain expressions to be syntactically the same
in multiple steps. Typically two steps are involved, as
for modus ponens, where the rule works with two steps of
the form "A" and "A => B", where A and B are arbitrary
boolean terms. Such systems also ... |
Take:
KP recurrence relation
$ max { [v + f(k-1,g-w ), f(k-1,g)] } $ if w <= g and k>0
CCP recurrence relation
$ min {[1 + f(r,c-v), f(r-1,c)]} $ if v <= c and r>0
I don't understand (much as I've researched) exactly what the reasoning is behind KP comparing in both cases (take the element/don't take it)... |
I'm taking a programming languages course and had a question regarding the typing rules for a recursive let rec expression in a static typing system.
To be more specific, we're using the textbook Essentials of Programming Languages (3e) - Friedman & Wand.
To give some rough background, here's how the author describes ... |
How does the language $L=\{a^nb^mc^nd^m \mid n \geq1, m\geq1\}$ abstract the problem of checking that the number of formal parameters in the declaration of a procedure agrees with the number of actual parameters in a use of the procedure?
I simply didn't get what each of the variables $a,b,c,d,n$ and $m$ will represen... |
What is the best way of counting the number of multiples of number A that perfectly divides the number B.
This is the sub problem for one of the questions I am solving on codechef.
This is the best I could come up with.
int func(int A,int B){
int res = 0;
int i = 1;
while(A * i <= B){
if(!(B %(A * i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.