instruction
stringlengths
35
11.4k
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?
What could be the basic examples (or the one that we are familiar of) of static and dynamic RAM? My Thoughts: First of all $\color{RED}{\text{RAM}}$ is something whose contents will be lost if power is removed Now, in $\color{green}{\text{Static RAM}}$, the contents of the memory do not change with time and they hold...
I am having a hard time understanding maths behind a 1x1 convolution and how is it actually performed. Assuming that I have a 6x6x32 input to my 1x1xK convolution layer similar to the one presented in this video and shown below. I understand that I would take a 1x1x32 slice from the input ( blue in the image below), bu...
I would like to extend ECMAScript by adding new keywords and syntax to it, for example: |variableName| stipulates a special kind of variable which I would like to be able to include in a normal ECMAScript line of code, for example: |variable1| = 1 + 1 |variable1| = |variable2|.length - 3 a more complex one would be: @...
The programme returns the number of digits of an integer $n>0$. I still have some difficulties to understand the difference between the loop invariant condition and what the loop should actually does. Clearly, we loop until the number is greater than 0. Is this the loop invariant condition? I know that by definition, ...
As a student of mathematics I used to accept the argument that the existence of the empty set followed from the axiom schema of comprehension, so long as we could prove the existence of at least one set: if a is any set, then we can derive the existence of {x:a | bot }. I would then argue using the axiom of infinity th...
I have seen this question here, Closure of Turing-recognizable languages under homomorphism But actually this question answers the question of "What is the relation between homomorphism and concatenation?", so I still have a problem of how to show that the collection of Turing-recognizable languages is closed under hom...
Problem: Given a string $s$ and a DFA $D$, compute the longest subsequence of $s$ such that the subsequence is accepted by $D$, or report that no such subsequence exists. This problem has a runtime of $O(qn)$ where $q$ is the number of states of the DFA, and $n$ is the length of the string. This problem is supposed to...
The number of possible min-heaps containing each value from {1,2,3,4,5,6,7} exactly once is: My approach went like this: fixing 1 in the root for the remaining 6 elements we can choose 3 of them and then make a full node(node with two children). For a given set of 3 nodes we can arrange them in 2! ways i.e the children...
for a class project we have to count the number of collisions from inserting words from a plaintext document into a hashtable. I read that using prime numbers for table sizes can offset the collisions resulting from a poor hashing function. Do I have to create a poor hashing function to demonstrate the effects of table...
I am working on a problem where I need to binary search on a given array and there can be updates for a given index. As the updates can occur frequently, I need to do it as efficiently as possible. Could you please suggest an appropriate data structure which would update the element in O(log n) and allow me to perform ...
$\sum$ is the Alphabet of three infinite languages $L_{1},L_{2}$ and $L_{3}$ where $L_{1}\cup L_{2} \cup L_{3}=\sum^{*}$ and $L_{1} \cap L_{2} = \emptyset$, $L_{2} \cap L_{3} =\emptyset$ and $L_{1} \cap L_{3} = \emptyset$ is it possible that $L_{1}$ is Decidable, $L_{2}$ is Turing Recognizable but not Decidable and...
I am trying to dig further into machine learning and I am making a program to play a game as a start. I have created a game that is based on the mobile game Flappy Bird and can be generalized to the following: Actions $A = \{\text{no action}, \text{tap}\}$ States $S \subset \mathbb{R}^3$ such that $s \in S$, $s_1$ ...
Suppose $G$ is a random graph on $n$ vertices where each edge appears with probability half. Suppose someone looks at the resulting graph and chooses an arbitrary subset $W$ of vertices of size $k>\sqrt{n}$. How do the eigenvalues of the induced subgraph $G[W]$ behave? In other words can we say that for every $W$ of s...
I am going through the following introduction to lambda calculus : http://www.cse.chalmers.se/research/group/logic/TypesSS05/Extra/geuvers.pdf At page 12 , the following has been asked to prove $ \exists $ $ G $ $ \forall X $ such that $GX$ = $GG$ This means to find a function which takes a function as an argument an...
How can one design a regular expression for given string in title ? Also how can we draw DFA of that regular expression? I've tried many expressions but couldn't succeed, please help.
Is it possible to create $O(1)$ memory consuming algorithm, which is generating non-repeating pseudo random numbers? I can remember numbers in the hash set and it will be $O(1)$ time, but the set will grow as numbers generated as $O(N)$. Is it possible to do $O(1)$? UPDATE Narrowing the question: we have parameter $N$....
I'm recently learning the part of I/O buffering of operating system and according to the book I use, When a user process issues an I/O request, the OS assigns a buffer in the system portion of main memory to the operation. I understand how this method is able to avoid the swapping problem in non-buffering situation....
I am taking a course on natural language processing that assumes the students have some background on theory of computation. I dont, but have read up till chapter 3 of the book "Speech and Language Processing by Jufrasky". I therefore understand the following regular expressions and regular languages operations on reg...
i'm currently converting this NFA: into DFA, however it's a bit confusing and my result so far ended with: However, this doesn't seem right to me, and i would love to hear if im on the right track or not
To be specific, the problem is formalized as follows. Given a set of integers $\{a_1,\ldots,a_n\}$, determine whether there exist non-negative integers $x_1,\ldots,x_n$ such that $a_1x_1+\cdots+a_nx_n=0$ and at least one of $x_1,\ldots,x_n$ is positive. Note this is not a duplicate of this problem. In that problem, th...
How can we make a DFA for given condition in title from alphabets {0,1} (binary). What can be the regular expression for this? My calculated expression is (a+b)*a(a+b)(a+b) , please correct me if i'm wrong and help find the correct expression and it's DFA.
I am trying to come up with a matchmaking algorithm based on player ratings for my game, and I am pretty sure the algorithm I have is not the best (or maybe doesn't even work), but have no idea how to improve it. Suppose that I have 5 players, ABCDE, and I want to create a 2v2 match. Each party of 2 have their own rati...
Let's define the sequence of $k$-Fibonacci numbers as $$ F_i = 2^i, ~~ 0 \leq i \leq k-1 $$ $$ F_i = F_{i-1} + \dots + F_{i-k}, ~~ i \geq k $$ I have a problem which requires to compute $n$-th $k$-Fibonacci number modulo $10^9 + 7$ efficiently. $n$ can be as large as $10^6$, $k$ can have any value between $1$ and $n$, ...
The proof is given in the below: If $A$ is decidable, the enumerator operates by generating the strings in lexicographic order and testing each in turn for membership in $A$ using the decider. Those strings which are found to be in $A$ are printed. If $A$ is enumerable in lexicographic order, we consider two cases. If...
I am learning about compilers at the moment and in my textbook it is briefly mentioned that UD/DU (Use-Def, Def-Use Chains) a way of saving information from the reaching definition is. It is just said that, when a variable is used, it has a list of the reaching definitions. The problem that I am having is, that I am no...
Given a complete graph $G$, an arbitrary graph $H$, and a positive integer $n$, are there subgraphs $A_1,\dots,A_n$ of $G$ (not necessarily disjoint) such that their union is $G$, and each of them are isomorphic to $H$? This is a problem which I believe is NP-complete, but I am unsure if it is actually so. Any id...
What are the advantages of using FPGAs over GPGPUs? It seems like GPGPUs have the best of CPUs and GPUs combined.
I am learning how to minimize a DFA. One helpful approach is the Myhill-Nerode Theorem, which explains: Draw a table for all pairs of states (P,Q) Mark all pairs where P is a final state and Q is not a final state. If there are any unmarked pairs such that [delta(P,x), delta(Q,x)] is marked, then mark (P,Q) Combine ...
From what I learned, viola jones needs images with faces upfront. Tilting the head a few degrees to each side can botch the algorithm. Is it possible to take an image, take a several rotated copies of it and run the algorithm on each one? This limitation sounds like only a minor neusense to me. Is there a stronger reas...
Let L1 and L2 be two non empty regular language. How can I show that the following expression is correct with an example ? $\bigotimes$ denote the transducer cross product. $L_1^+ \bigotimes L_2^+$ contains $(L_1 \bigotimes L_2)^+$ ============================================================================ Thanks PHP...
By analytic proof, I mean mainly resolution and also other valid syntactical manipulations of the set of clauses, old and new. So this is a search over problem space rather than solution space. The question is: Is there a family of instances of SAT that doesn't have polynomial-size analytic proofs of their satisfiabili...
I'm reading Rosen's Discrete Mathematics and Its Application, at Page 212, it's about the "Big-O" notation using in computer science. This is the description in the book: And here is my reasoning: Since there wasn't a program with "negative" steps, I only consider the case $n>0$. With $n$ is $O(2^n)$, there exist two ...
In my textbook, it presents the theorem, "A language L is accepted by some DFA if and only if l is accepted by some NFA". My textbook explains that the "if" portion of the proof is given by the subset construction and theorem if $D=(Q_D, \sigma, \delta_D, {q0}, F_D)$ is the DFA constructed from NFA $N=(Q_N, \sigma, \de...
I was learning about heaps, and came to know that the worst case time complexity of heap sort is Ω(n lg n). I am having a hard time grasping this. My reasoning is as follows: 1. Build a max-heap out of the unsorted array, say A. (O(n)) 2. Exchange root of the heap (max element in the heap) with the last element of ...
I need to approximate the sine function without internal libraries. I used Taylor series in 0 to solve this, but my program works for some values, but for others awful results. The program gets x value, unit (degrees or radians) and how many words we want use for the approximation. For values like 1 rad, 5 words resul...
I have a virtual world with a grid filled with squares (x by y). There are entities that can do: 1. move 1 step in the four cardinal directions 2. eat food 3. fight another entity of a different type 4. mate with the same type of entity to reproduce (create one more of that type of entity) The objective is to obtain ...
Let's consider finite grid of points with size of $N$ by $M$ and set of $x$ points ($x$ is small number, up to 10, $N$ and $M$ are big numbers, up to 30000 )). Each of the $x$ points is described with 2 values $(x_i, y_i)$. We want to count the size of set $y$ such that $y$ includes all the points in the grid that are ...
It is known that finding an independent set (or a clique) of size at least $k$ in a graph is $W[1]$ hard, so it is unlikely that there is $f(k)\cdot n^{O(1)}$ time algorithm for finding an independent set of size greater than equal to $k$. I was looking at the complementary problem - "Whether or not removal of at most ...
What is an algorithm that can find the best possible matches given a set of data. I have read up on stable roommates problem and or stable marriage problems. However, from my understanding, these type of algorithms only output a specific match (pairings) and not a set of possible matches. For example, say we have a gro...
First, I am aware at least one or two similar questions have already been asked on stack exchange, but I've gone through the answers they got and didn't find one that was satisfactory for my case. The question itself is as follows. Suppose I have a sum $X=\sum_{i=1}^{n}{X_i}$ of mutually independent indicator random va...
I'm a high schooler who has been self-learning graph algorithms for a month or two now. I was wondering why the distance array in Dijkstra's algorithm is initialized to infinity (INT_MAX in C++) when it could just be set to a negative number? Since Dijkstra's isn't even used for negative numbers, why isn't the distanc...
I know that there are some languages that are unambiguous but not context-free (this is a good fact). Is there any kind of formalism for describing unambiguous context-sensitive languages? Even better yet, is there a parsing algorithm for unambiguous context-sensitive languages?
Let's say there's a cloud computing service that allows people to run arbitrary programs and get the results. The idea being that your machine is too slow, and you don't want to overwhelm it. If your program is something like "factorize 15672965357291016", then it's a perfect candidate for this service, because you can...
Let $\Sigma$ be 0,1,2. I am interested in the language of all strings $w$ such that the sum of $w$ characters (where the char 0 is treated as the number 0, the char 1 as the number 1 etc) is divideable by 5. Obviously this is a regular language, and I can also find a simple linear grammer. My idea for a regular expres...
I saw a similar question to this one here but it's not quite the same as mine: Is every algorithm's complexity $\Omega(1)$ and $O(\infty)$? I've just started a course in data structures and introduction to algorithms and there's a question on a homework assignment whose answer is a little unclear to me: Given $f:\mathb...
Fermat's Little Theorem states that if an integer $n$ is prime them $$ a^n \equiv a \pmod n \hspace{10mm} (*) $$ for any $a \in \mathbb{N}$ My question is, is it correct to say that testing $(*)$ for some given $a$ has complexity $\Omega (n)$, since we would have to calculate $a^n$ which would require $n$ (multiplicati...
The following algorithm is supposed to compare two strings $S_1$ and $S_2$ ("/\" for empty string): X = S1 Y = S2 E = true // (1) S1 = S2 <=> X = Y and E = true while X != /\ and Y != /\ and E == true if head(X) == head(Y) X = tail(X) Y = tail(Y) else E = false // (2) S1 = S2...
A trie can answer a query for all items with a certain prefix in $O(m + \log n)$ time, where $m$ is the number of matches and $n$ is the number of items. A trie also supports $O(\log n)$ insertion and deletion and takes $O(n)$ space. Now suppose each item has a score. I am looking for a data structure that can answer a...
I'm trying to understand "A Systematic Approach to Canonicity in the Classical Sequent Calculus" by Kaustuv Chaudhuri, Stefan Hetzl, Dale Miller. The article discusses a property called "canonicity" with respect to a logic (or perhaps just specifically for sequent calculus?). As far as I can tell, they don't directly p...
Given two integers $n$ and $k$, I want to compute the exact value of the binomial coefficient ${n \choose k}$. Here $n$ and $k$ are given in their binary representation, meaning that the size of the input is about $\log n + \log k$. How fast, in big-O notation, can we compute ${n \choose k}$? One can compute this in ti...
Suppose there is a communications channel between two parties. Suppose I want to send information through this channel, but I want to make it look like noise. Ie, I don't necessarily want to encrypt it, though I'm not prohibiting encryption - the point is I want to be able to transmit information to someone else such t...
I need help with figuring out an algorithm from a generated numbers in a table. I was half way solving this question and I have already got the sequence for N=6, but I'm still stuck at writing the actual algorithm
I'm reading Operating System Concepts by Avi Silberschatz(9thE), in chapter 11 File-System Interface, when the author explains the concepts of file, he states that The information about all files is kept in the directory structure, which also resides on secondary storage. Typically, a directory entry consists of the...
Background: I was trying to detect a face solely on the bases of features and the confidence of the features found. I am using a method to identify the features along with the response (confidence). Stronger features have higher responses. I was trying to identify rotations of face. So, I was thinking about using ellip...
Let $T=(V,E)$ be tree and each edge has a positive scalar weight. I need to print all paths in the tree and then sort the weight of edges in each paths. it needs $O(n^3\log(n))$ time. To solve this problem we can rooted the tree in a leaf and print all vertices by preorder algorithm and in each step we insert the new...
So I have a problem, and it's an assignment from school. This is a figure made out of matchsticks. The goal is to find the optimal location to light up the figure so that it burns in minimal time. You can only light it up at integer positions (C,B) but not A. Different matchsticks may have different burn times. My app...
Let $G(V,E)$ be a graph and each edge e∈E has a positive length $\ell_e$. The radius of the graph is $rad(G)=\min_{v∈V}\max_{u∈V}d(u,v)$ where $d(u,v)$ stands for the shortest path between $v$ and $u.$ Now let we are allowed to increase the edge lengths by total increasing equal to B so that the radius increases as muc...
In our language design book, it is mentioned that GC sweep can be integrated into allocation, such that when you call malloc for example, you sweep until you find a fitting object, which you then return (i.e. sweeping is not a different procedure). It, however, also mentions that this is only viable when the objects al...
I am reading the book "An introduction to statistical learning with applications in R". I am reading Logistic Regression and I don't understand why when it's compared to linear regression model, the author said that "the problem with this approach: for balances close to zero we predict a negative probability of default...
Let $\{x_1, ..., x_n\}$ be a set of $n$ distinct variables, and suppose given a finite set of $m$ inequalities such that, for all $1 \leq i \leq n$, the $i$-th inequality is of the form: $$y_i + a_i \leq z_i + b_i$$ where $y_i,z_i \in \{x_1,...,x_n\}$ are variables and $a_i, b_i \in \mathbb{Z}_{\geq 0}$ are non-negativ...