instruction
stringlengths
35
29.1k
In a question I've been given a 5x5 matrix that I'm told represents a weighted graph, and no other information. Here is an example: 0 4 5 2 2 3 0 3 3 1 1 3 0 5 2 2 4 4 0 2 2 3 2 5 0 My question is, how does this represent a weighted graph? I think that each number at position [i,j] in the matrix represents the length ...
The Semantic Web defines standardised logic under the OWL DL standard. Programming languages such as OCamel and TypeScript support type inference and algebraic types. What are the difference between the 2 logic "structures"? Are they equivalent in terms of being able to implement one in the other and vice versa? Refere...
Suppose that $m=O(n^{c+1/2})$ for some real $c>0$ and $x=O(\sqrt{\log m})$. Are the following two computations valid? I understand that I'm abusing notations a bit to get at the desired results. Computation 1 \begin{align} f(x)\leq \exp(-x^2/2)&=\exp(-O(\log m))\\ &=\exp(-O(\log O(n^{c+1/2})))\\ &=\exp(-O(\log n^{c+1/2...
I am writing a routine to store an $M$-by-$N$ sparse matrix in a balanced binary tree. The insertion routine calls a comparison function to determine where a new matrix entry $(i,j)$ should be inserted in the tree. I am defining the ordering of the matrix elements simliar to how C handles a row-major ordered dense matr...
$$1MBytes =1024*1024*8$$ $$256k*1bit=256*1024$$ $$1MBytes = \frac{1024*1024*8}{256*1024}=32$$ Now my question is that for converting 1MByte to bit level we need 1024*1024*8 but 256K is not converted the same way why (256*1024*8)bit? why we don't multiply with 8 at last since it is kilobyte than byte than bit.
I was working through a few problem sets and came across this question Suppose there is a connected planar simple graph $G$ with $v$ vertices such that all its regions are triangles (a cycle consisting of three edges). Question 1: Into how many regions does a representation of the Planar Graph $G$ Split the plane? In...
I have reduced subset sum problem to set partition problem but do not know whether it is correct and so I need your help. MY METHOD In subset sum problem we have to find a subset $S_1$ of set $S$ so that it sums to a number $t$ and in set partition problem we need to find a subset $X_1$ of set $X$ such that summation o...
In Practical Foundations for Programming Languages, on page 138 (page 156 of the pdf), it says: Requiring solutions to all type equations may seem suspicious, because we know by Cantor’s Theorem that an isomorphism such as $X \cong (X \rightarrow \mathbf{2})$ is set-theoretically impossible. This negative result t...
For my study I am supposed to develop an dynamic programming algorithm which solves the following simplification of the Knapsack problem in $O(v^*n^2)$ time ($v^*$ is the maximum value of all elements): Let there be given $n$ elements $1,...,n$, a maximum weight $W$ as well as a weight & value function: $w: \{1,...,n\...
Given this graph, what is the minimum perfect matching? What do you do, when there is an uneven number of vertices?
I'm trying to show Amplification works for randomized algorithms, and for randomized approximation algorithms. Amplification for randomized algorithms: Given a randomized algorithm with time complexity $f(n)$ and error probability $\frac{1}{4}$, show there is an algorithm that solves the same problem, but with $O\lef...
"Composition of Composition" (i.e., (.) . (.)) in Haskell), has type (a -> b) -> (c -> d -> a) -> c -> d -> b. Apparently, this is an instance of fmap, i.e. a functor between two categories. The question is: what is the domain and the codomain of this functor? How do we interpret this functor in terms of functional pro...
I have the following code in Python: def is_unique(string): if len(string) <= 1: return True if len(string) > 128: return False char_set = defaultdict(lambda: False) for char in string: if not char_set[char]: char_set[char] = True else: return F...
Is there a formula for determining the minimum number of colors to color a map with n counties such that no adjacent county have the same color?
I've read about it in a few places and I'm not sure I get it. Are the philosopher's allowed to act simultaneously? Do they each take 1 action simultaneously, then go on to their next action?
I want to optimize a SVG path made entirely of lines. Given a list of lines, each made of two 2D points connected together, I want to find an equivalent list of polylines. For example: M10,10 L20,10 M20,10 L20,20 becomes M10,10 L20,10 L20,20.One line ends where there other begins, it can become a polyline. M10,10 L20,...
What this "⊃" superset means? What do I need to prove here. Can someone, please, explain in English? Do I need to do a cross product? Plus, in textbooks and online I only see "∩" "∪" these kinda symbols. What this symbols "⊃" means? Let M = (K, Σ, δ, s, F) be a deterministic finite automaton. Let M' = (K, Σ, δ, s, F'...
Given a string $S$, I want to find the prefix string $P$ of shortest length, such that the original string $S$ can be generated by concatenating copies of $P$ (where overlapping is allowed). For example, if $S = atgatgatatgat$, I want to find $P = atgat$; $P$ is the smallest prefix of $S$ that can be concatenated (in t...
Despite there being relatively frequent discourse regarding the usage and effectiveness of various node centralities when analysing the influential spreaders of a graph, I have thus far struggled to find any formal treatments of such discussions. For example, betweeness centrality is theoretically well-defined and is p...
I was wondering if there is an obvious way to 'name' the ${n \choose k}$ subsets of size $k$ of the integers from $1$ to $n$. So I am looking for a bijection from the subsets of $\{1,\ldots, n\}$ into $\{1, \ldots, {n \choose k}\}$ that can be computed in $O(1)$ at best. The most trivial way for this would be to use a...
I am trying to devise an algorithm in which given the length of a path that satisfies the constraints of the Traveling Salesman Problem, I can find the path. Currently, my only solution is to find a cost matrix of every possible path and brute force adding them up until I get a solution that equals the length of the p...
How can I show that the expected pairwise square euclidean distance between points in $X$ is $Θ(d)$? Where $X$ is a $(x_1,...x_n)$ of points generated uniformly at random in the unit, d is d-dimensional cube , $x=(x(1),...x(d))$ the generic point has its -th component $x(i)$ chosen uniformly at random in$ [0,1] $indep...
This is with respect to user-level threads where the kernel only knows about the process as a whole, and threads are created and maintained in the user space. Each thread has its PC, registers, stack and thread control block. To my knowledge, updating PC (or any system register) or access of the code segment can only b...
My assignment is to prove that the language $L = \{ a^{4n} b^m \mid n > m >= 0\}$ is not a regular language. My first attempt was to prove that if if you set $a^l$ and $b^{l-1}$ you'd have an equal #a and #b if you "pump down" your $v$ so that it is $v^0$, so that the condition $n > m$ is no longer fulfilled. Then I re...
I have this algorithm Algorithm (A[1..n]) for i <- 1 to n do if (A[i] < 0) then A[i] <- 1 * A[i] End if End for I have to find the total number of assignment in the worst case, but I'm a little bit confused, do I say I have 2 or 1, one for the assign A[i] in the statement and second...
I need help understanding the language L above. These are my understanding: - w = uu is a concatenation of u - La(1*01*) can be expressed in regular language i.e. r1 = 1*01* so La(r1) - also we have regular expression property of concatenation: L(r1r2) = L(r1)L(r2) So base on my understanding the language L can b...
Can someone tell me what binary NP-Hard exactly means. My understanding was that if the problem is encoded in binary and if the problem is binary NP-Hard, its complexity of solving is NP-Hard. Is this the correct interpretation? I also wanted to know, if binary NP-Hard also says something about Strong or Weak NP-Compl...
The problem is (integer) duplicate removal, which can also be perceived as producing the image of an evaluated function (of integers): Given a sequence $S_\text{in}$ of $n$ integers, produce a sequence $S_\text{out}$ of elements such that any element in $S_\text{in}$ also appears in $S_\text{out}$, and all elements i...
I have been having a hard time understanding whether the set $S = \{ M \mid |L(M)| = 5 \}$ is semidecidable or not, where $M$ is a generic Turing Machine and $L(M)$ the language accepted by such TM, which consists of exactly five strings. Because $S$ is a property of the accepted language (there exists a TM that recogn...
I have to find the efficiency class of this algorithm b = 3 a = 4 for i = 4 to n^2 if (i mod 2 == 0) a = a+2 else b = b*3 end for I solve it like this, first I find the time for executed a then b and the total is the addition, is it right? I'm not sure if I have to do it like this or not, I l...
I am interested in an intuitive proof for "any binary tree with $n$ nodes has $n-1$ edges", that goes beyond proof by strong induction.
The dominance law states that x + 1 = 1 If we go by that logic, does that mean that x' + 1 = 1? Please just tell me if it's a yes(as I think that this is the answer but I just want to clear my doubts) and maybe provide a little explanation if it's a no. Thanks!
$r_1=\Lambda+(a+b)^*b$ $r_2=(b+aa^*b)^*$ $r_3=b+\$+aa^*b+(b+\$+aa^*b)(b+aa^*b)^*(b+\$+aa^*b)$ For this FA, which i think of as accepting "$\Lambda$ or anything ending in $b$", i came up with $r_1$, then i used FSM2Regex which gave me $r_3$ which i simplified into $r_2$ using regex simplifier. now $r_2$ seems better t...
I am trying to implement the nearest insertion TSP heuristic. However, I am wondering if it matters which node I insert into the subgraph first. For example, should I start with one node; calculate the distance between this node and the other nodes; and sort the other nodes by this distance? Then, I will insert the cl...
We are given array $A$ of $N$ integers each in the range $1 \leq A_i \leq 2^{30}$, that is we can write each integer with at most 30 bits. The target is to compute $\sum_{1\leq i \leq N,1\leq j<i} ( A_i \text { xor } A_j )^X$. $X$ is either 2 or 3. $N$ can be up to $50000$. I know that this can be solved in $O(N^2)$ b...
I'm struggling with the following question: Let $\langle a_0, a_1,\dots,a_n\rangle$ be a sequence of real numbers, and let $ M = \max\{a_0, a_1, .... a_n\} $ and $ m = \min\{a_0, a_1, .... a_n\} $. a. Prove that there are two numbers in the sequence $x,y$ such that $ |x-y| \leq \frac{M-m}n$. b. Write an algorithm t...
So I was browsing online looking for the general structure to proving a DFA has a minimum of $n$ states for some $n$ and most of them use contradiction. However, I'm having a hard time understanding why the proof of proposition 5 works in proving the statement. My understanding of the proof is that we assume there's a ...
Problem: Given $N$, find the smallest number divisible by $N$ whose sum of digits is equal $N$. For example: $n = 1$, answer is $1$ $n = 10$, answer is $190$ There is some dynamic programming algorithm, but I can't find it. It is sequence https://oeis.org/A002998.
Given a parameter $k$ and an array (not sorted) of length $n$ return all values which repeat more than $\lfloor n/k \rfloor$ times in $O(n \log k)$ time. I've managed this in $O(nk)$ time, but can't figure out how to do it in the required performance.
I am new to automata. And learning to find concatenation of two FAs. But this one has confused me I know how to do concatenation but I am confused that in FA 1, what does x1 means? Is it mean final state or does it mean both initial and final state because it is on the start?? Just clear me on this that what is initi...
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...