instruction
stringlengths
35
29.1k
I am extending a gcc plug-in which should be able to detect branches within a loop, which can be run by speculation (run all branches in parallel and decide later what result to keep). The question is how to find the structures in the graph which are suitable. For now the plug-in is only able to work with loops which h...
Just as I asked in the title: if my algorithm has complexity $O(n!\times n)$, can I just write $O(n!)$, or I have to keep it like $O(n!\times n)$?
Let $G= (V,E)$ be a given directed weighted graph, and $s,t$ two specified nodes, so that there is no negative cycle reachable from $s$, and $t$ is reachable from $s$. We're looking for the shortest s-t-path. By regarding this problem as a special flow network, we can express this using linear programming as follows :...
I'm trying to prove that unless $\mathsf{P}=\mathsf{PSPACE}$, there is no unary language which is $\mathsf{PSPACE}$-hard. Assuming there is an unary language $A$ which is $\mathsf{PSPACE}$-hard, it doesn't seem reasonable to solve $A$ in polynomial time. How can this be proved then?
I have just began with my course of complexity and computability and I need your experience to help me progress !! Something is not clear for me: It is asked to determine if L1 is decidable or not, below the language is an answer given by a student. And I'm not agree with it... The Rice theorem is given as follow : ...
I'm working on this lab where we need to apply a lossless predictive coding to an image before compressing it (with Huffman, or some other lossless compression algorithm). From the example seen below, it's pretty clear that by pre-processing the image with predictive coding, we've modified its histogram and concentrat...
I was instructed to create a pushdown automaton described in the title. Basically, the pushdown automaton accepts strings of the form $x\#y$ where $x$ and $y$ are strings of 1s and 0s such that there must be at least one difference and at least one similarity between $x$ and $y$. Here is the meaning of one similarity. ...
I was skimming this recent paper and I was struck by the following statement: two processes are equivalent with respect to weak bisimilarity if and only if they satisfy exactly the same set of HML formulas I have trouble believing it. I reason that: weak bisimilarity does not account for tau-transitions and therefor...
The problem is as follows: Consider a connected, undirected, and weighted graph $G = (V, E, w)$ and an integer $0 < k < |E| - |V| + 1$. Describe and analyze and efficient algorithm to remove at most $k$ edges from $E$ such that the resulting graph $G' = (V, E' \subseteq E, w)$ has a maximal weight minimum spanning tre...
Consider a datatype whose objects will be sequences of elements that has the following two methods prepend($x, T$) which will insert an element to x to the beginning of the sequence T search($T, i$) which returns the ith element in the given sequence T is a linked list. prepend takes $1$ step. Search takes $i$ steps Su...
Consider a datatype whose objects will be sequences of elements that has the following two methods prepend($x, T$) which will insert an element to x to the beginning of the sequence T search($T, i$) which returns the ith element in the given sequence T is a linked list. prepend takes $1$ step. Search takes $i$ steps Su...
I am aware of the fact that, since the concept of "effectively calculable function" is not rigorous or formally definable, the Church-Turing thesis may not be proven by symbolic or formal reasoning alone. My impression, though, is that under the domain of physics, philosophy, cognitive science or other disciplines, we ...
I am trying to find the upper bound on time complexity of the recursive function defined by the following equation: $$Q(t) = \sum^{N}_{i=1} q_i \big(g_i^{\frac{1}{m-1}} + Q(t+1)^{\frac{m}{m-1}}\big)^{\frac{m-1}{m}}\quad \forall\, t = 1, \ldots,T-1.$$ Here, $0\leq q_i\leq 1$ are probabilities where $\sum^{N}_{i=1}q_i =...
Suppose I have a directed acyclic graph where each vertex $v$ represents a task with a certain execution time and the edges represent precendence constraints between the tasks. I.e. task $v_i$ has to execute before task $v_j$ if there exists an edge $(v_i,v_j)$ between those two tasks. I have $x$ threads that can execu...
For my studies on economy, I work on prediction of judicial decisions. I don't really understand the interactions between several concepts: predictive analytics machine learning case-based reasoning rules-based reasoning At the moment, I understand that predictive analytics is an area of statistics that deals with e...
Preface I asked a question before where I was looking to understand the complexity class of the following problem: Given a range of integers $\{a,a+1,...,b-1,b\}$, find a subset of size $k$ such that the sum is equal to $s$. I had found a $O(k)$ algorithm as hinted at by the accepted answer. After playing around with...
I know that HyperLogLog can approximate the distinct elements count of a huge multiset but I was wondering if it was possible, using a method I saw mentioned on an IRC channel, to get an exact answer while still using significantly less space than a traditional approach. Would the following work to compute the exact (n...
I'm studying for my final exam and come up with this exercise with no idea how to find the production rule of this grammar. I need help. Thanks all of you! :)
given the linear program: minimize $x+y$ subject to, $ax+by \leq 1$ $x,y \geq 0$ I need to find real numbers $a,b \in \mathbb{R}$ such that the program (a) is infeasible, (b) is unbounded, and (c) has a unique optimal solution. Since we are asked to minimize the sum of two non-negative numbers the solution for all $a,b...
Consider a datatype whose objects will be sequences of elements that has the following two methods prepend($x, T$) which will insert an element to x to the beginning of the sequence T search($T, i$) which returns the ith element in the given sequence T is a linked list. prepend takes $1$ step. Search takes $i$ steps Su...
I have directed graph (maybe with cycles), and some resources in vertices (let's say gold). I can transfer gold between vertices only in direction of edges. The task is to minimize maximum value of resources in vertices (e.g. make optimal redistribution of gold). For example, Optimal distribution for this graph is fol...
I'm currently working on a Constraint Programming problem which I find difficult to model. Here 's the definition of the problem : " Given a specification of a Boolean function f(x1, ..., xn) in the form of a truth table, to find a NOR-circuit (meaning only NOR gates) satisfying the specification that minimizes depth (...
Say I have a set of numbers, for example {1, 2, 3, 4, 5}. Is there an algorithm that allows these numbers to be put into a consensus ordering based on a ranked vote? For example, if 3 people vote and their votes are [1, 2, 3, 4, 5], [2, 1, 3, 4, 5], and [1, 2, 3, 5, 4], then the consensus ordering would be [1, 2, 3, 4,...
I understand that the language: $\operatorname{SPACE-TMSAT} = \{⟨M, w, 1^n⟩ : \text{DTM $M$ accepts $w$ in space $n$}\}$ is in PSPACE since it doesn't use more than $n$ space. But to prove that it is PSPACE-complete, we need to do the reduction from any other PSPACE language to it. If we assume the language to run on a...
I'm having a hard time understanding this question. Can each declaration have more than one scope or can a declaration have more than one scope? If it's the later it would be: Declaration Scope int a = 1; B1 int b = 1; B1 int b = 2; B2 int a = 3; ...
Would a Turing Machine that cannot move left, but can move right or stay put recognize only regular languages? And how does it compare to a machine the can do the same, but also move left?
I have two pseudorandom generators $G_1$ and $G_2$ from $k$ bit to $2k$ bit. I have another PRG $G_3$ from $k$ to $2k$ bits. Now I buildup a new function from $k$ to $4k$ as follows: Let $x$ be $k$ bit then apply $G_3$ on it on $x$. Then let output by $y$. Apply $G_1$ on first $k$ bits and $G_2$ on last $k$ and join ...
Say we have an open shop scheduling problem with following constraints : No wait-time between operations of a job Multiple job types (meaning each job type has different set of operations eventhough their intersection might not be empty) No wait-time between each operation on the same machine (machine must not be idle...
Alright, so this is a fairly interesting problem I have but also slightly difficult to explain so I will try my best. There are two runners on a line that goes from $x=0$ to $x=100$. The two runners start at $x=50$. The runners are then given an array of coordinate pairs that they must visit. The catch is, the coordina...
Context: I am working with a tree-like data structure. I would like every node in the tree to have an integer hash value that is the result of combining the integer hash values for the node's children. Additionally, I'd like to be able to replace one of the node's children in constant time (i.e., not doing a full recom...
I am writing various "program analysis" (aka static code analysis) algorithms. I am looking for ideas for metrics to measure how well my algorithms "understand the code". Some ideas i have so far : classic points-to analysis - ability to determine (during compile time) pointer aliases and allocation sites early object ...
It is known that the problem of fractional set cover can be rephrased as a linear programming problem and be approximated using the multiplicative weights method, for instance this lecture note shows how to do so. The running time depends on the "width" of the problem, which equals to the number of sets in the unweigh...
The recurrence I have is $T(n) = 2T(\sqrt{n-1} + 2) + 1$ I don't know how to solve it. I didn't find much on the internet with square roots in recurrences especially with constants inside of it. I'm supposed to find the height of the tree but I have no idea how. I need to solve this recurrence only using trees. And I c...
I have looked for an answer for this question which seems trivial, but I didn't find any. Can a Turing machine, given a word $w$, calculate the length of the word?
I'm looking for someone who can tell me which algorithm this is and help me to clearify what the variable mean. $g_j$ : the shortest path length from $1$ to $j$ $t_{i,j}$: the length from $i$ to $j$ $\mathrm{SCS}$: successive set $S$: Start node, $G$: Goal node \begin{align} &f_G = 0 \\ &f_i = \infty, \forall i...
https://stanford.edu/~rezab/classes/cme323/S16/projects_reports/shoemaker_vare.pdf Why do we use blossom contrast in maximum matching? The examples that I have seen can easily be solved by just iteratively finding a augmenting path and complementing it. I am talking about edmond blossom algorithm. Edit: http://demonstr...
Is the language of words containing same number of 101s and 010s regular? If yes, how can I design a DFA for it? In general, is the language of words containing equal number of strings which one is "one's complement" of the other one is regular (like the language of words containing equal number of 01s and 10s which is...
I am trying to model the following problem correctly as a min-cut network flow problem. I have $n$ books and 2 boxes. I also have books that I know must go in one of the two boxes. In addition, each book has a certain profit if I put it in the same box with another book. So for instance, if I pair book $i$ with book $j...
I've developed a Monte Carlo tree search algorithm in checkers. Here is my question. What should be the value of $C$, the exploration parameter in the following formula described in Monte Carlo Tree Search (MCTS)? $$ S_i=x_i+C\sqrt{\frac{\ln (t)}{n_i}}$$ General consensus is that a value of $\sqrt 2$ should be used, bu...
In this paper, the author seems to suggest that theta sketches(a variant of kmv) outperforms hyperloglog in cardinality estimation on the intersection of n way streams. Set Intersection. multiKMV can be tweaked in a natural way to handle set intersection and other set operations. I am having a hard time understanding h...
The problem (copy-pasted from this question on cs.stackexchange): Given a connected, directed graph $G=(V,E)$, vertices $s,t \in V$ and a coloring, s.t. $s$ and $t$ are black and all other vertices are either red or blue, is it possible to find a simple path from $s$ to $t$ with more red than blue vertices in polynomia...
Given an array of numbers $a_i$ with length $n$, such that $0<a_i<30$, how can we find the number of subsequences that the product of numbers is perfect square. I have tried to find a dynamic programming approach but had no success so far.
Am I correct that the given solution is implying that the string with a single b, "b" is accepted by this NFSA? If so, I don't understand how "b" can end up in the accepting state.
It is mentioned in Which languages are recognized by one-counter machines? that a one-counter machine can accept $\{a^n b^n c^n\mid n\geq 0\}$. Can someone please explain how this is done?
Different machine has different efficiency on different tasks, like: | T/M | M1 | M2 | M3 | | T1 | a11 | a21 | a31 | | T2 | a12 | a22 | a32 | | T3 | a13 | a23 | a33 | So, Machine $M_1$ needs $a_{11}$ time on finishing Task $T_1$. Each machine can process one task everytime. Each single task cannot be splited up....
L = {x in {0,1}* | x has an equal number of 0s & 1s} Based on the recursive definition of regular languages, isn't it possible to form a single regular language set over the binary alphabet {0,1} by doing the following? concatenating 0's and 1's to form each of the binary strings satisfying the condition, resulting in...
I was tasked with finding a way to decide the language $A=\{0^k1^k \mid k\ge 0\}$ in $O(n\log n)$ time, and then to implement it on a deterministic Turing machine with one tape. Additionally, I was asked to check if it is possible to reduce the time from $O(n\log n)$ to $O(n)$ if using a determinstic Turing machine wit...
Suppose you have an undirected graph $G = (V, E)$, known to both Alice and Bob, Alice gets an independent set of $G$. Bob gets a Clique $B ⊆ V$. Is there any algorithm in $O(\log^2 n)$ bits that finds whether $ A ∩ B = Ø $? This is a well known communication complexity problem called CIS problem that was described by Y...
I want to solve $T(n) = 2T(7n/10) + O (1)$ using the substitution method. I think the solution should be $T(n) = O(n\log n)$, but I am having trouble constructing a proof by substitution.
Why sizeof(int) and sizeof(int *) takes different value in a system? I mean generally size of integer is 4 B, but size of integer pointer is 8 B. But why they cannot take same value, although their return type is same?
I am asked to give a table of 8 elements that are to be sorted by the following algorithms and to produce their best cases. 1) Selection sort 2) Bubble sort 3) Insertion sort 4) Fusion sort If I give an already sorted table ex: {1,2,3,4,5,6,7,8} shouldn't it already be the best case for all of them? If I can be conside...
It seems to me that a tree or a heap is a concept and not a concrete implementation of some other abstract data structure. For example a heap can be implemented with a table. Then why it is not considered abstract?
A complexity class $\mathbb{C}$ is said to be closed under a reduction if: $A$ reduces to $B$ and $B \in \mathbb{C}$ $\implies$ $A \in \mathbb{C}$ How would you go about proving this if $\mathbb{C} = NP$ and the reduction to be the karp reduction? i.e. Prove that if $A$ karp reduces to $B$ and $B \in NP$ $\implies$ $A ...
How to justify the role of blossom in Edmond's blossom algorithm for maximum matching? odd cycles also can be covered in augmenting path.
Assume that we measure the complexity of an algorithm (for some problem) by two parameters $n$ and $m$ (where $m \le n$). What is the formal interpretation of the following claim: there is no algorithm that solves the given problem in $o(m + \log{n})$? In particular, does it mean that an $O(\log{n})$ algorithm is possi...
i have a question based on a question i saw exists on the site, but with wrong information in it and no answer there, so i am reposting it with valid information(cited wrong from the book). on page 207 of the book "introduction to the theory of computation", there's a proof that $A_{TM}$ is not decidable. the proof is...
Suppose we have a CNF formula $F$ built on the set of literals $L=\{x_1,\neg x_1,\cdots,x_n,\neg x_n\}$ where each variable is used in at least one clause of $F$. Consider a permutation $\sigma$ of $L$ such that $\sigma(F)$ is logically equivalent to $F$ i.e. $\sigma(F)\equiv F$. Does it hold that $\forall x\in L, \si...
I'm a newbee learning DFA minimization. And I found that(strangely) Brzozowki's algorithm cannot give me a minimized DFA on this example: In this DFA, $S_0$ and $S_1$ are nondistinguishable and should be merged after minimization, but they are not. The process of minimization is like this: I tried to find out why by ...
Define an operator $\pi(\cdot)$: for a language $L$, $\pi (L)$ is the set of all prefixes of strings in $L$ with length at least half of the original string. Prove that if $\mathsf{P}$ is closed under $\pi$ we have $\mathsf{P}=\mathsf{NP}$. This is a homework question I had. My current sketch is: for a language $L_1 ...
Let $L = E_{TM} = \left\{ \left<M \right> | M \text{ is a TM and L(M)} = \emptyset \right\}$. Does $L$ accepts the empty word $\varepsilon$? In other words, is $$\varepsilon \in L$$ I'm a little bit confused by this. My intuition says it doesn't since the empty set rejects every input.
For data compression, every codding that I've seen is binary. It means we convert a language with $N$ symbol size to a language with $M=2$ symbol size. For example, in Huffman coding, the goal is to find a binary coding ($M=2$) for English language ($N=26$). If $M$ is not equal to $2$ and have a value larger than $N$...
Is there a well known and proven algorithm to find the TOP (finite) limit of a set of points, which are time based metrics? I'm looking for an existing implementation, in order not to invent the wheel of something which already exists. This is what I have in mind, but it is a bit hard to configure the right parameters,...
I was wondering if the following language belongs to NP class and if its complimentary belongs to NP class: \begin{align} C=\left\{\langle p,n\rangle\mid\right.&\ \left. p \text{ and $n$ are natural numbers}\right.\\ &\left.\text{ and there's no prime number in the range}\left[p,p+n\right]\right\} \end{align} could yo...
I'm having real trouble tracing some pseudocode for insetion into a Binary Search Tree. I need to understand this in order to be able to teach it, but I think there are flaws in the material. For example, CALL FindInsertionPoint(NewDataItem, Index, Direction) is only meant to have one parameter according to the descri...
I am performing segmentation using opencv, but the segmented image has regions with breaks and also the border isn't smooth. How can I handle this problems?
I am learning algorithms to solve Maximum Flow problem by reading the CLRS book and confused by the following figure: That is: A flow in a residual network provides a roadmap for adding flow to the original flow network. If $f$ is a flow in $G$ and $f'$ is a flow in the corresponding residual network $G_f$, we de...
We assume that time of solving the problem $=f(n)$$\mu$s. Now we have to calculate how big problem we can calculate for each time periods. So there are: $\lg n, \sqrt{n}, n, n\lg n, n^2, n^3, 2^n, n!$, How to calculate size of the biggest problem during those times periods?: 1s, 1min, 1h, 1 day, 1 month , 1 year, 100 y...
I am trying to find a mapping reduction from $A_{TM}$ to $\overline{CF_{TM}}$, but I can't seem to find one. Definitions: $$\begin{align*} CF_{TM} &= \left\{ \langle M \rangle \mid \text{$M$ is a TM and $L(M)$ is context-free} \right\} \\ A_{TM} &= \left\{ \langle M,w \rangle \mid \text{$M$ is a TM and $w \in L(M)$} \r...
In "Introduction to Algorithms" by C. E. Leiserson, R. L. Rivest and C. Stein (ISBN: 978-0262033848), p. 264 they state this: I get everything but the last part stating $h(k) = 67$ >>> r = 17612864 >>> bin(r) # r's binary representation '0b1000011001100000001000000' >>> int(bin(r)[: 14 + 2], 2) # extract 14 most sign...
Recently I have been interested in Computer Vision and I am now experimenting with OpenCV in Python. I have done some research but haven't really found what I am looking for. Therefore I try to give it a go my own way. My objective is to have an image where a 3D object is situated in. Of this object I would like to dra...
Perhaps this is the wrong exchange, so if there is a better place to post this please tell me! The DataMatrix encodes diagonally in a sort of zig zag pattern, as shown below. Why don't they encode horizontally or vertically, like how it's done in QR Codes? If they did this it would appear to eliminate the need for con...
In an unweighted graph, we can find Multiple Source Shortest Paths using the Breadth-First Search algorithm by setting the distance of all starting vertices to zero and pushing them into the queue at the beginning of the algorithm. However, I'm wondering if we can use the same technique to solve Multiple Source Shorte...
Haven't written a proof in years, not sure how to describe an algorithm like this ? Let us what we have a graph. like this below: 1). How to describe edge removal of{ (0, 1),(3,4), (1,2) }done in linear time ? Basically, we don't want any edges that shortcuts our visit as every vertices need to be visited. Here is s...
I have the following feeling (I wouldn't even call it a conjecture yet) which I'd like to ask whether it's true in some form. Take the class of all programs running in polynomial space. Surprisingly or not, they can still output an exponentially large output: at each step of their running they may output something, and...
Prove that $L = \{ xy \in \{a,b\}^* \mid |x|_a = 2|y|_b \}$ is not regular. I have already tried to prove it by using the pumping lemma and reduction to absurdity, but have been unsuccesful on both. Could someone please help me? I tried to use the pumping lemma with the word $w=a^{2p}b^p$. It is easy to see that for...
I'm writing a paper for some software that uses combinatorics to generate large result sets. I would like to describe that if I put in $n$ elements, I will get in return $2^n$ elements. Is there a software metric that describes "data growth" for an algorithm or do I simply write "the data grows exponentially"? btw: The...
I'm trying to implement recursive types into my programming language. I've implemented extensible rows and was hoping to add some recursive typing in order to get something like this or self within a record (thus imitating objects). Recursive types would only occur in record definitions, like record IntObject: val: i...
Can somebody please suggest some procedure for All-to-All broadcast on a balanced binary tree? Assume that only the leaves of the tree contain nodes, and that an exchange of two m-word messages between any two nodes connected by bidirectional channels takes time ts + twmk if the communication channel (or a part of it) ...
I was reading Algorithms 4th Edition by Sedgewick et al. and I found this statement when discussing about the analysis of mergesort: The number of compares is at most n and no less than $\lfloor n/2 \rfloor$. The code they gave for the merge() routine is shown below: private static void merge(Comparable[] a, Comparab...
I have searched but didn't get any exact difference between RAM and a buffer. If both are used for temporary storage, then why they are named differently while both having same property?
We are given a tree of N nodes from 1 to N where node 1 is the root of the tree. For each node i from 1 to N, you have to find the numbers of nodes which are in the subtree of i and are at distance equal to height of subtree of i. Distance between a & b = total number of edges in path from a to b,height of subtree = ma...
I recently came across this term "Turing complete" in my study of morphogenesis models. When I looked up, it said that a turing complete machine can simulate a universal turing machine. When I looked up for its relationship with recursive enumerable languages, I couldn't find anything substantial. My question is: Wi...
Let's assume that we have clauses $(l_1 \lor l_2 \lor l_3), (\neg l_1 \lor \neg l_2 \lor l_4), (l_1 \lor l_2 \lor l_5), (\neg l_1 \lor \neg l_2 \lor l_6)$, where both $l_1$ and $l_2$ are complementary literals for the clauses. If we apply the resolution technique for $l_1$ we'll get clauses $(l_2 \lor \neg l_2 \lor l_3...
Consider the following program in "mutable style": x=1 x=f(x); x=f(x); We can rewrite this in "immutable style" without changing the higher-level structure of the program: x1=1 x2=f(x1); x3=f(x2); We turned it into an immutable style program by only making "local changes": We simply took the mutable variable $x$ and ...
So I have an input of the type: Node parent but the problem is that the nodes and parent aren't given in a specific order starting from root, and I want to build a Trie but I can't because of this aspect, I thought about using a queue with Trie nodes, and when their parent appear I will pop them from the queue, but t...
Im trying to learn about and set up Turing Machines (TMs) the simplest ways using the simplest definite rules. I am using my previous knowledge on simple Cellular Automata to do this. I want to write the computer code, but first I have to get some understanding of the restrictions and possibilities of TMs. Firstly i de...
Prove or disprove: If the language $L$ is such that for every context-free language $L_0$, the language $L \cap L_0$ is context-free, then $L$ is regular. I haven't managed to prove this, but I'm pretty sure there is no counterexample.
I have a problem with the following optimisation problem: In total there are $n=100$ items. A quality level $L_i \in \{0,1,2,3,4,5\} $ must be selected for each of these items. The greater $L_i$ is, the greater weight $w_i$ and its value $v_i$, starting with $w_i=0$ and $v_i=0$ for $L_i=0$. Furthermore, $w_i$ depends...
I can't work out the solution to the following exercise: We have $2n$ vertices grouped in $2$ clusters of equal size. The probability of having an edge between $i$ and $j$ is $p$ if $i$ and $j$ are in the same cluster and $q$ otherwise. This is a simple SBM with $2$ clusters. The problem ask to show that if $(p+q) << \...
There's this question on LeetCode (link): Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution exists, return -1. For example, with A = "abcd" and B = "cdabcdab". Return 3, because by repeating A three times (“abcdabcdabcd”), B is a subs...
I am trying to prove that language $E_{DFA}$ is decidable using multiple executions of $A_{DFA}$ (not using the proof in Sipser's book "Introduction to the Theory of Computation"). Can I just use the given $M$ as a decider? $M =$ "On input $\langle B,w \rangle$, where $B$ is a DFA and $w$ is an empty string ($L(w)=...
We have proved that the language $ L = \{\omega\omega \mid \omega \in \{0,1\}^{*} \} $ is not a CFL, and we did so by using pumping lemma. And the proof is clear to me. But I thought of the following CFG: $ G = (\{S, S_{1} \},\{0,1\},R,S) $ where R has the following rules: $$\begin{align*} S &\rightarrow S_{1}S_{1} \m...
If I have to check a Left Recursive grammer for LL(1) then should I check it after removing left recursion? For example:- S-> (L)|a L->L.S|S If I check after removing Left Recursion then the above grammer is LL(1). But if I do not remove left recursion then above grammer is not LL(1). which one is the right answer?
We have given tree with $N$ nodes and $N-1$ edges, such that each edges is assigned positive weight. We need to find path of length between $L$ and $R$ inclusively, with maximum cost. Cost of a path is defined as a median of all costs of edges that lie on the path. Let's define two types of costs of path between two n...
Although it may sound trivial... I was going trough the definitions for Red Black Tree in the book "Introduction to Algorithms" and I still cannot understand, why this is not a RBT? B / \ B B / \ / \ n n n n Comparing to the properties of a RBT: It should satisfy all of them...?
I am writing a function to find the intersection between two sets. The non-functional requirements of the assignment include avoiding "side effects". function intersection(a, b) { return helper(a, b, []); } function helper(a, b, c) { if (a.length == 0) { return c; } if (b.contains(a[0])) { return help...
Suppose we have a simple Bayesian network with two rows of nodes: $x_1, x_2, \ldots, x_n$ and $y_1, y_2, \ldots, y_n$. Each node $x_k$ takes a state of either 0 or 1 with equal probability. Each node $y_k$ takes state 1 with probability $p_{k,0}$ if $x_k$ is state 0 and probability $p_{k,1}$ if $x_k$ is state 1. Is ...
Is it true that $A \leq_k B \land B \in \mathsf{coNP} \implies A \in \mathsf{coNP}$? If so, how would you go about proving it?
Suppose that $S=\{1,2,...,n\}$ and we are given an integer $r\leq n$. An $r$-combination of $S$ is obtained by selecting $r$ distinct integers out of the $n$. We order all $r$-combinations for a given $r$ lexicographically. Call the rank of an $r$-combination its rank in this ordering. I am interested in finding a $r$...
I would like to convert 0,347 and 0,9828 to binary, how can I do that? I know that sucessive multiplication by 2 can do this, but this method seems very painful and even ineffective since the size of count. This is for a question, and I think that sucessive multiplication is needed. But, in 0,347, I did more than 20 mu...