instruction
stringlengths
35
29.1k
The transfer of control is often completed through some type of software interrupt instruction. These special instructions result in the CPU to save the current state of the machine and transfer control to a function in the operating system. They are like a cross between an ordinary subroutine call instruction and a ha...
I need to write a regular expression for the following set of strings on Σ = {a, b, c} in which the number of b’s is even, and contains abcba as a substring. So far, the even number of b's can be constructed using like this: (aUb(aUc)*bUc)* or (cUa)*b(cUa)*b(cUa)* to add the substring abcba, do I just attach it to ...
I was looking at an example here: https://blog.parasoft.com/finding-memory-leaks-in-c #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { char *string, *string_so_far; int i, length; length = 0; for(i=0; i<argc; i++) { length += strlen(argv[i])+1; string = malloc(...
We are given an array of weights $W$ (all weights are positive integers), and we need to put the weights inside bins. Each bin can hold a maximum of Max_val, and each weight is at most Max_val. The variation is that the ordering of weights should not be changed, that is, $W_i$ should be inside a bin before $W_j$ is ins...
In wiki, it is shown that the time complexity of matrix multiplication and matrix inverse is similar. But people always to argue it is easier to do matrix multiplication rather than inverse. Is this claim true? Maybe we need to consider various computation platform, CPU or GPU.
At the moment, I'm making a comparative analysis between two different neural networks for a class. The problem they are both trying to solve is detecting tables on documents. Below is an example of one: One of the algorithms I am analyzing is a fully convolutional network. The way the algorithm works is that it goes ...
Consider applications A1, A2 .. AN having properties P11, P12,... PN1, PN2.. Also consider buckets B1, B2 ... BN where each property needs to be mapped. We have the following constraints - total number of properties >> number of applications total number of properties >> number of buckets number of buckets ~= number...
For Dijkstra’s,i can find shortest paths from source to all vertices in the given graph but how can i calling the algorithm |V| times taking each vertex as a source and store all tables ??? For example : What is the shortest path from 1 to 4? You need to print the value and the exact path vertices starting from 1 and e...
I'm going through 'Operating Concepts' by Silberschatz, Galvin and Gagne (The Dinosaur Book) and it mentions the Second-Chance Algorithm (not enhanced) as an improvement on the FIFO replacement algorithm. My question is, is there ever a case where this algorithm would perform better than, say, the Least Recently Used ...
If space is of primary concern, how could we improve on adjacency matrices and adjacency lists for representing a graph of nodes and undirected edges in memory? Throughout academia we learn adjacency matrices and lists but in the real world we encounter graphs of sizes that exceed the capabilities of these representati...
I need help figuring out the runtime of the following pseudocode. I believe it is O(|E| + |V|), but I'm not totally sure... graphFunction(graph): q = Queue() for vertex in graph: q.enqueue(vertex) while q is not empty(): v = q.dequeue() for every outgoing edge of v: ...
I just answered this question on StackOverflow, which asks for an efficient algorithm such that given a nonempty hashtable, the algorithm should return a pointer to an arbitrary nonempty entry in the hashtable. My answer was quite casual and I am not confident if my proof was correct. I am rephrasing the problem statem...
How to check if $L = \{c^ka^nb^n \mid k>0 \wedge n\geqslant0\} \cup \{a, b\}^*$ is regular ,where $L_1 = \{c^ka^nb^n \mid k > 0 \wedge n\geqslant0\}$ is clearly not regular and $L_2 = \{a, b\}^*$ is... ?
If an array $A[1 \ldots N]$ is represented using a segment tree having sets in each interval, why does a range query $[L\ldots R]$ returns at most $\lceil \log_2{N} \rceil$ sets (or disjoint intervals)? If came across this statement while reading this answer. To quote: Find a disjoint coverage of the query range using...
I'm writing my thesis and i have built a RPI cluster, containing 10 nodes which consists of RPI model 3b. I've them connected to two gigabit switches. I don't know the CAT of the cables. They are not connected to the Internet, they just live in their private network. Further more, i've calculated the theoretical perfo...
Let us $\Sigma = \{0,1\}$ and $f: \Sigma^* \rightarrow \Sigma^* \in FP$ for which is valid that $\exists k: \forall x \in \Sigma^* : \lvert x \rvert ^ {1/k} \leq \lvert f(x) \rvert \leq \lvert x \rvert ^ k$. Thus, we can say that the function $f$ is one-way function. We have language $L = \{ w \; | \; \exists z \in \Si...
I want to check whether a formula in finite LTL is valid on a finite, linear trace. For infite traces I would create a Kripke structure of the trace and a Büchi automaton for the negated formula, and check if the intersection is empty. Would this also work with a finite trace and formula in FLTL? I already tried addi...
Let $Q$ denote the number of queries. I have a $25 \times 25$ matrix in each cell of an array of size $n$. Let us denote this array by $A$. It's a special matrix, more specifically, all elements are $0$ are $1$ and only on cells adjacent to the main diagonal and on the main diagonal itself, allowing faster multiplicati...
It seems intuitive that any natural problem that is NP-hard on trees, should be hard on graphs that are not trees. But perhaps this is wrong? Question: Is there some natural decision problem on graphs that is NP-hard when we are promised the graph is a tree, but in $P$ when the graph is promised to not be a tree. Thoug...
I know that there are several problems for which a small change in the problem statement would result in a big change in its (time) complexity, or even in its computability. An example: The Hamiltonian path problem defined as Given a graph, determine whether a path that visits each vertex exactly once exists or not. ...
I am implementing an online platform, where third-parties sell virtual goods to clients on a subscription basis. Let's take for example ebooks as a virtual good in this case. How can the third-parties trust my platform? How can they know that I don't cheat with the number of subscriptions I report back to them? Do any ...
I have a question about Linear Discriminant Analysis (LDA) for the purpose of Dimensionality Reduction. So I understand for the algorithm to calculate for $k$ projection vector(s) you need to determine the eigenvector(s) that corresponds to the top $k$ eigenvalue(s). But can anyone explain what you do with those eigenv...
I have a question. Please be nice; I come from the corporate world and my knowledge of computer theory is around a college freshman level. My understanding from many popular-level sources (like Scott Aaronson's P vs NP for dummies blog post, or this New Yorker article) is that the P vs NP question asks whether a proble...
Consider you have a permutation of $1$ to $n$ in an array $array$. Now select three distinct indices $i$,$j$,$k$, there is no need to be sorted. Let $array_i$, $array_j$ and $array_k$ be the values at those indices and now you make a right shift to it, that is $new$ $array_i$= $old$ $array_j$ and $new$ $array_j$= $ o...
I am trying to find the best time complexity of an algorithm that calculates the weights of all the nodes on a graph. The weight of the node is defined as the sum of the weights of the edges adjacent to it. I can argue that the algorithm is similar to the one which would calculate the degree of all the nodes and that c...
I'm studying his paper and I was wondering how the community reacted to it. Yes, Average Case Complexity has come a long way since then, but I want to know if it was directly influenced by it.
I'm pretty new to the PDA topic. How do I construct an NPDA for the language $$L= \{w : n_a(w)+n_b(w) = 2n_c(w)\}.$$ I've tried all the possibilities, but I still somehow end up accepting all words.
The Problem I have a set of edges (a, b), where a and b are nodes in a directed, acyclic graph (DAG). The number of edges is guaranteed to be the number of nodes - 1. I am looking for an algorithm that finds a sequence of nodes [n_1, ... n_n] so that the sequence contains all nodes in the graph, and that all edges (n...
I have a hash table that uses zobrist hashing to calculate the hash for various positions. The hash table is used to look up various transpositions. For some positions I do not want to allow any transpositions, but I still want to store the position in the hash table. So I'm trying to make the position's hash unique by...
What are the obvious benefits of transforming variables with long tail distributions? To extend it more, why the machine learning algorithms will perform better afer such a transformation?
Construct a PDA for the language described by the following CFG: $$ S \to [S] \mid \{S\} \mid \Lambda $$ How can I develop a pushdown automaton for this language?
I want to express the asymptotic time complexity for the worst case scenario of sorting a list of $n$ strings, each string of length $k$ letters. Using merge-sort, sorting a list of $n$ elements requires $O(n\log n)$. Comparing two strings of length $k$ has a cost of $O(k)$. Therefore, the cost would be $O(kn\log n)$. ...
I was doing problems in "Leetcode" and found a problem that I could not solve. Given a non-negative number $n$ and two non-negative numbers $a$ and $b$, consider every number $i$ such that $a \leq i \leq b$ and among those find the maximum value of $n \& i$ where $\&$ means bitwise and. I could only solve when $a=0$ by...
I want to ask that what is the time complexity of this function (triple nested loop) .Kindly analysis completely so that I can understand. function loop_nested(n) r := 0 for i := 1 to n - 1 do for j := i + 1 to n do for k := 1 to j do r := r + 1 return(r)
I tried to solve the recurrence relation $T(n) = 6T(n-1) + n^3$ using the tree method, and figured out that the root will be $n^3$, the second level will be $6^1(n-1)^3$, the third will be $6^2 (n-2)^3$, and so on. The formula as I understood it is: $\sum_{i=0}^n 6^i(n-i)^3$. After entering this in Wolfram, the result ...
I have an algorithm which is meant to solve the following computational problem: Input: Sequence of positive integers Output: A Sub-sequence of some desired length derived from original Sequence such that the sum of the sub-sequence's elements are the minimum sum possible The Algorithm I have to solve this problem is i...
Given that x objects (repetition allowed) can be arranged into y configurations, and that the population size is N, I am uncertain as to whether the size of the search space is |S| = |(y^x) * N| or |S| = |(y^x)^N|. |y^x| comes from basic combinatorics: it is the number of ways to arrange |x| objects into |y| configurat...
Wikipedia states on the page of the halting problem, "For any program f that might determine if programs halt, a "pathological" program g called with an input can pass its own source and its input to f and then specifically do the opposite of what f predicts g will do." Suppose we have 2 neural networks, approximating ...
I have an algorithm that visit all the nodes on a graph in distributed computing , the initiator is one site only , I want to change it so that the initiator can in the end of the execution know the nodes that have more than 3 neighbours , So the initiator is one site and the result expected is the list of the nodes th...
I need to prove, that the $\#k-colouring$ graph problem is $\#P-complete$. I want to construct the reduction from $\#3SAT$ problem, so $\#3SAT \leq \#k-colouring$. The reduction between the counting problems consists of two parts. The first one maps instances of the first problem to the instance of the second problem (...
The teacher explained to us this algorithm for deleting a node in a binary search tree, but I can't understand how it works when the node to be deleted has only one child (I already know how it works theoretically). Algorithm: abc_delete(T, z) // z is the node that must be eliminated { if((z.left == NULL) && (...
Suppose we have a function f :: a -> b and a function g :: b -> a such that f . g = id. You might say that g is the "inverse" of f (and vice versa). Could we then pattern match on something like f x on the left hand side by replacing occurences of x with g x on the right hand side? For example: -- Here, (- 3) is the "i...
If a string(w) is accepted by an NFA, then corresponding to w, can there be multiple paths each starting from the start state and ending at an accepting state?
Basically what I know is that 8086 can address up to 1 MB of locations which are divided in 4 segments(code, data, extra and stack) 64 KB each. But 64 KB * 4 is 256 KB, which doesn't add up to 1 MB(1024 KB). So what about the rest of space.
I read on Wikipedia the following: Since NP-complete problems are in NP, their running time is at most exponential. Is that correct? I thought a problem is in NP-complete if: the problem is also in NP (i.e. accept verification in polynomial time) Every problem in NP can be reduced to it in polynomial time. These tw...
We know that: $k^n = o(n!)$ $n! = o(n^n)$ where $o$ refers to "little o notation" (i.e. bounds that are asymptotically not tight). With that in mind: Are there any defined or academically established classes for problems with complexity of at most $O(n!)$ and $O(n^n)$? What is the set relationship for these classes...
Someone told me this and I would be interested to know if it is true: In the ieee 754 format approximately half of the positive numbers are in the interval [0, 1]
This is the problem that I have to solve: given a node in a binary search tree, find the node with the smallest key that is greater than the key of the given node.. The algorithm that is often given is this one: bst_successor(x) { if(x == NULL) return NULL; if(x.right != NULL) ...
Suppose we have a symmetric matrix $A \in \mathbb{R}^{n \times n}$ that has $n-2$ equal eigenvalues and the other two are distinct. Question: What would be the complexity of its inversion? On the one hand, if all eigenvalues are the same, then the matrix is equal to $aI$. Therefore, the inversion is $O(n)$. On the ot...
I'm having a lot of problems trying to make a Turing Machine that accept that language, is it even possible to make it? and if so, how can I proceed to make the Turing Machine?
If we have a Turing machine with various $\delta(q_i, a_i) = (q_j, a_j, Direction)$ where Direction can be L or R(denoting the movement of head), can we encode it uniquely to some natural number(which can later be decoded to give us back the deltas) ? It doesn't matter if all the natural numbers map one-to-one to all t...
Why do we need at least 2 Code Words of the max length in optimal Codes? Any why do they just differ in their Prefix? Could someone give me more insight into this? Have to proof that for a given optimal Code C with max length L there are at least 2 Code Words of max length that just differ in their prefix. I have nothi...
Consider a problem where a "robot cleaner" is placed on a room modeled as a grid. Each cell in the grid can be empty or blocked and all accessible cells are connected, meaning, all empty cells will be accessible by the robot regardless of its starting position. We are told that the robot cleaner can only take one of fo...
How can I prove that the following problem is NP-complete? I have a spherical container in which I have to introduce $n$ identical spheres. All of the little spheres have to be inside the container and they can't overlap each other. The idea is to minimize the container's ratio. I know that this is a packing problem bu...
I am trying to read a paper. I can’t understand the difference between data flow and control. Maybe control flow means OS's or hardware's steps taken for execution of statements whereas data flow stands for passage of data as a result of execution of statements. Link of paper is https://www.usenix.org/system/files/osdi...
Suppose that Alice has $n$ places to hide the gold $v_1, ..., v_n$ and that Bob knows the probability of each place. Bob has to ask Alice a series of yes/no questions to find the gold. I have done it this way: We order the places by probability highest to lowest. Repeat the following: Divide them by two so we have tw...
I'm wodering about the relationship between the theory that studies irrational/transcendental numbers and computer science. For example, I found this paper (but was unable to get the full text) Pseudo-random number generator based on irrational numbers I found the paper because I started looking for a RNG that uses the...
If we have say,key=‘0110‘ and =‘1100‘, how will ⊕key mod 2 be calculated and what will be the answer equal to?
I need to find an algorithm for the following problem. Any idea to which kind of algorithm to look for as starting point is welcomed. Should I look for a graph algorithm? Combinatorial problem? Mathematical or dynamic programming? Objective: I have a set of 48 classes with 25 students each. I need to divide each class ...
This same question has been asked here so many times by several people. This is a problem which was asked in an entrance exam. And I am having difficulties in digesting the correct answer of this problem. Why is my approach incorrect? Here is my approach: The divide part of the merge sort recursively divides the list o...
I have a doubt about the Unit Type in the context of Type Theory and its use in different case scenarios. To start with, a Unit Type can be seen as a nullary Product Type, namely Unit, with one only value term which is the empty tuple, (). Also, there exist a unique map from any type to the Unit. Now, it happens that t...
In the static RMQ problem, one has to answer queries about the minimum in a range of a fixed array. A classic variation allows updates of the form $A_i \leftarrow x $. My question is : How fast can we update if we must answer queries in $O(1)$? I can think of a solution which works in $O(\sqrt{n})$ per update : We can...
I got 2 decision problem that I need to answer if they are in P or they are NP complete: 1.Just like subset sum: given the integers or natural numbers ${\displaystyle w_{1},\ldots ,w_{n}}$ does any subset of them sum to precisely ${\displaystyle W}$? but now instead of $W$: does any subset of them sum to $W'$ su...
In Practical Foundation of Programming Languages by Harper There have been many attempts by advocates of dynamic typing to distinguish dynamic from static languages. It is useful to consider the supposed distinctions from the present viewpoint. Dynamic languages associate types with values, whereas static languag...
I have an Independent Set problem, in which I have to check if given graph has a IS of given size $k$. I've already written a Vertex Cover algorithm a while back and I hope I can reuse it here. Those algorithms are closely related, since if graph $G = (V, E)$ has IS of size $k$ iff it has VC of size $V - k$. So am I ri...
Regarding static typing and dynamic typing, Practical Foundation of Programming Languages by Harper says: There have been many attempts by advocates of dynamic typing to distinguish dynamic from static languages. It is useful to consider the supposed distinctions from the present viewpoint. Dynamic languages asso...
I'm new to Haskell and have some general questions. Question 1: The Haskell expression (\x -> \x -> x) is the same as the λ-term λx.λx.x The type of this expression is p1 -> p2 -> p2. What does this mean? Question 2: λyx.x is shorthand for λy.λx.x. In Haskell (\y x -> x) is shorthand for (\y -> \x -> x). Do (\x x -> x)...
I have a dataset of 100 ID's, each ID with only a single unique face image. How can I develop an effective face recognition system to recognise only these faces? I was thinking Deep Learning but the dataset is so sparse. It would be 100 classes each with a single data point (the image).
Let $A_j=\{(a^i_j,b^i_j)~:~ 0 \leq i \leq n,\text{and } a^i_j,b^i_j \in \mathbb{Z}^+\}$ Given sets $A_1,\ldots, A_{p}$ and a positive integer $k$, the problem is to check whether there exists one element $(a^{i_j}_j,b^{i_j}_j)$ from each $A_j$ such that $\sum_{j}^{} a^{i_j}_j \geq k$ and $\sum_{j}^{} b^{i_j}_j \geq k...
I have the following context-sensitive grammar: $$ \begin{align*} &S \to xSy \mid a \mid b \\ &Xa \to aa \\ &Xb \to bb \\ &Y \to a \end{align*} $$ I know what it does, as it always ends in $a$ and is preceded by 3 $a$s or 3 $b$s. I'm just not sure how to write this in set notation and would appreciate any help. Would i...
Suppose I have a system of linear equations. Using Gaussian elimination, I can determine whether a solution exists, and even find a valid solution. During the elimination, I can combine rows together, to produce new rows with different number of variables. Is there a method to find all possible rows that contain exactl...
The problem of finding the longest path in a graph is known to be not be possible in polynomial time, that I am aware of. I am also aware that using DFS or BFS can give the shortest distance between a given origin and destination in a graph. Is it possible to find a longest path from a source vertex to a destination ve...
Does $n+n^4$ grow faster than $n^2+n^3$? If so, why?
$$ T(n) = T(n-a) + T(a) + cn $$ Now the solution says that the height of the tree $(h)$ is: $$ h = \left \lfloor n/a \right \rfloor $$ And I don't understand why. Maybe I didn't understand the withdrawal formula as needed.
I'm attempting to practice for an exam and I'm having some trouble on one of the practice problems. The problem asks to identify a variety of language as regular grammar, context-free grammar, context-sensitve grammar, or unrestricted grammar. It also asks that if the grammar is regular or context-free, to write out th...
I'm practicing for an upcoming exam and am being tripped up by a review problem. The problem gives the following grammar: $$S \rightarrow AB\$$$ $$A \rightarrow \epsilon | a | (T)$$ $$T \rightarrow T, S | S$$ $$B \rightarrow b$$ As far as I can tell, the only nullable symbol is $A$. It is the only non-terminal whose pr...
I have 2 ways of solving Independent Set problem of fixed size $k$ for graph $G = (V, E)$: - Vertex Cover algorithm running in $O^*(1.47^{V - k})$ (optimized recursive algorithm) - Clique algorithm running in $O({V\choose k})$ (simple enumerate subsets of $V$ and check algorithm) How can I determine which one has a low...
I want to prove that $L(G) = \{01; 11110; 10101; 000\}$ is regular. Is it correct if I write there exists a regular expression, which is: $(01|11110|10101|000)$? How can I also prove it using a DFA?
Can we formalize the operational/denotational semantics of a Turing Machine? Is there any formalization in literature?
A multithreaded program P executes with x number of threads and uses y number of locks for ensuring mutual exclusion while operating on shared memory locations. All locks in the program are non-reentrant, i.e., if a thread holds a lock l, then it cannot re-acquire lock l without releasing it. If a thread is unable to a...
Suppose I have a matrix $M$ over $GF(2)$ with rows that represent a system of linear equations: A xor B xor C = 1 A xor B xor D = 1 X xor A xor Z = 0 etc... For a new external row, I want the ability to tell if it is a linear combination of the rows of the matrix, or not. I could do this by computing the augmented ma...
I was reading radix sort in Introduction to Algorithms by CLRS . And it gave the following Lemma with its analysis I understood the proof of the Lemma but confused on the part where they try to minimize $\left( b / r\right) \left( n+2^{r}\right)$ . While choosing $r$ the first case was $b < \left\lfloor \ln \right\rf...
I am looking for some interesting applications of regular expressions. Can you name any unusual, or unobvious, cases where regexes find their application?
I recently completed a problem in which I was asked to generate a parse tree for the expression $+ \, 5 \, * \, 4 \, 3$ using the following grammar and rightmost derivation: $$Expr \rightarrow + \, Expr \, Expr \, | \, * \, Expr \, Expr \, | \, 0 \, | \, \dots \, | \, 9 \,$$ While I have no trouble taking the derivatio...
You are given a string S containing lowercase English characters. You need to find the length of the largest subsequence of S that satisfies the following pattern: X1,X2,X3...Xn,Xn,...X3,X2,X1 where Xi is some character of S. The only constraint is that no adjacent character should be the same except Xn, that is Xi != ...
As far as I've understood it, referring to this system as an 8-bit system points out that one can access 8 bits of data in one instruction. While I understand that we're not saving vast amounts of time by calling it "one byte" instead of "eight bits", is there a particular reason why the latter is/was preferred?
Let k be a positive even integer. Given a list of (k choose k/2) k-sequences, each with an equal number of 1's and 0's, is distinctness decidable in logspace if we're only allowed to read the input once? In more detail: Let a sequence have k bits. Let each sequence have an equal number of 1's and 0's. There are (k choo...
I'm trying to figure out Time function and Big O of a nested loop code, public static int example5(int[ ] first, int[ ] second) { // assume equal-length arrays int n = first.length, count = 0; for (int i=0; i < n; i++) { // loop from 0 to n-1 int total = 0; for (int j=0; j < n; j++) // loop from 0 to n-1 ...
If a new technology is invented for storage devices, which is the same as or speeder than RAM (bandwidth&lanecy), is it possible to make RAM obsolete and consider the storage device as the main memory? if that happened data and program would run directly from the storage device, or the RAM or its concept (especially as...
So let's say I'm baking a cake and it has a few ingredients (including multiples): ingredients = {sugar, sugar, baking powder, chocolate, flour, egg, egg} I can go to a bunch of different stores to buy the ingredients. Each store has a different collection of ingredients to offer: store_1 = {sugar, vanilla extract, ol...
When you consider Cook reductions, then decision and optimization versions of the problems are polynomial time reducible to each other. Focusing on Cook reductions, there exists a natural Karp reduction from the decision version of a problem to optimization version. Is the converse also true?
Consider the following problem: You are given a finite set of numbers $(l_k)_{k\in \{ 1, ..., n \}}$ such that $\sum_{k=1}^n2^{-l_k}<1$. Describe an algorithm to find a set $(l'_k)_{k\in \{ 1, ..., n \}}$ such that $\forall k \in \{ 1, ..., n \}:l'_k\le l_k$ and $\sum_{k=1}^n2^{-l'_k}=1$. (For what it's worth, this i...
I have the following problem that I'm unsuccessfully trying to solve: I have a directed graph with node demands. Unlike circulation with demands, these node demands do not "subtract" from the flow - the nodes merely demand that there would be a flow of strength k flowing through them. The graph is acyclic, however, it ...
Let $Σ = \{0, 1\}$ and let $A, B ⊆ Σ^*$ be languages. Prove that if $A$ is NP-hard, $B$ is in P, $A ∩ B = ∅$, and $A ∪ B ≠ Σ^*$, then $A ∪ B$ in NP-hard. How can I go about proving $A ∪ B$ is NP-hard given the conditions? Any help would be appreciated.
I started to learn AI and I'm trying to solve the following problem like a search problem and I'm wondering which search algorithm would be the best in this case. Please give me at least some tips, I would be very thankful. Problem statement: $n$ vehicles occupy squares $(1, 1)$ through $(n, 1)$ (i.e., the bottom row)...
I am trying to model some set operations which are only well-defined if one is a subset of the other. The way the sets are constructed, I'll have a series of constraints of the form $x \subseteq y$, including the two sets in question and some other ones too. I won't know anything about individual element membership, so...
Let $G=(V, E)$ be an unweighted, undirected, and connected graph. Given two start vertices $s_1$ and $s_2$ and two end vertices $t_1$ and $t_2$ is there a path from $s_1$ to $t_1$ and $s_2$ to $t_2$ such that the closest number of edges between the two paths is at least $k$? Two paths are $k$ close if the minimum of th...
def calculate_error(m, b, point): x_point, y_point = point y = m*x_point + b distance = abs(y-y_point) return distance print(calculate_error(2, 0, (5, 5))) I ran the code above and it worked. But I do not understand why it doesn't work when I tried setting point = x_point, y_point instead?
I can't figure out how to find a good asymptotic approximation for the following recurrence relation: $$T(n) = T(n/2) + T(n/3) + 1.$$
Given an undirected, unweighted, and connected graph $G = (V, E)$, what is the minimum amount of time it takes for party $X$ to go from $s_x$ to $t_x$ and party $Y$ to go from $s_y$ to $t_y$? At each unit of time, $X$ and $Y$ can either move to a vertex adjacent to their current position or not move at all. $X$ and $Y$...