instruction stringlengths 35 29.1k |
|---|
So I have the following function:
def lcm(a,b):
x = a
y = b
while x != y:
if x < y:
x += a
else:
y += b
return x
I'm not sure how I will go about finding the loop invariant of this question. I know I have to find some sort of relationship between $x$ and $y$ but n... |
I have the following question and its solution
Here T -> XTX
since T -> X and X->b
S ->XbX
since X->a
S->aba
So,why is option 3 not accepted ?
|
What will happen if we change the DES encryrption algorithm to use the same key in each round ?
How will it affect the encryption - will it only make the encryption same as decryption or are the more effects ? I couldn't find any other possible effects in the DES standard description.
Thanks
|
I had already been given the answer by the TA in class, but I don't understand it. I'm not asking for the answer on a homework problem or anything.
The problem:
The Hamming distance ("distance") of a word w to v of the same size is the number of positions wherein they differ. The distance between a w and L is the small... |
In the following graph, we can traverse entire graph if we select the nodes 0 and 2. I am looking for an efficient algorithm which returns this two nodes. Note that this is neither vertex-cover problem nor dominating-set problem since we don't need to select node 3. We say that, if we select node 0, we can go to node 1... |
I'm working on an algorithm that takes a number of unit coins ([1, 2, 5, 10] for example) and a certain amount of money (13 in this case), and figures out how many ways there are to provide change for it. In the case of this testset the solution is 16.
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,... |
Let $A$ be an event divided into 4 events $A_i$ with the same probability. Why does the quantity of information of $A_i$ satisfy
$$ I(A_i) = I(A) + \log (4)?$$
|
I am having difficulty understanding the distinction between NP and Co-NP.
According to my textbook (Sipser), the HAMPATH problem is in NP. That is, for the language: HAMPATH = { (G,s,t) | G is a directed graph with a Hamiltonian path from s to t}, there exists a nondeterministic Turing Machine M that can decide this p... |
I am following this algorithm example: https://en.wikipedia.org/wiki/Christofides_algorithm#example
The graph:
Calculate minimum spanning tree T:
Calculate the set of vertices O with odd degree in T.
They are the same as "the minimum spanning tree T" as the degree of all vertices are odd.
Form the subgraph of G using... |
Is there anyway to express a Product Buchi game as a parity game? There is no stochasticity in my original turn-based game and a Deterministic Buchi Automaton is constructed for LTL specifications.
|
For a given MAXSAT problem, it is trivially easy to compute the mean number of clauses satisfied for all assignments, or equivalently the expected number of clauses satisfied by a random assignment.
Is it likewise possible to compute the variance of the number of clauses satisfied? And I mean an exact computation, not ... |
I'm not sure if reusing variable is allowed in CNF.
For example, I have this grammar not in CNF. So I have to convert it to CNF.
1. S->abAB|abB|abA|ab
2. A->bAa|ba
3. B->BAa|bAa|ba|Ba|Aa|a
For conversion, I'm using a convention where new variables and terminals are in the form
(V1,V2,V3,...,Vk) for k > 0
Ti where... |
First Let's take a look at the convolution $\displaystyle C _ { i } = \sum _ { j \oplus k = i } A _ { j } * B _ { k }$, and the $\oplus$represents any boolean operation. And we are able to evaluate $C$ in $O(n \log n)$ time, using an algorithm called Fast Walsh Transform, where $n$ represents the length of the binary d... |
I was reading Elad Hazan's book on Online Convex Optimization(http://ocobook.cs.princeton.edu/OCObook.pdf) and am facing difficulty understanding the proof given for the No regret algorithm for MAB (Pg 102-103). It would be great if someone can provide a clarification on this.
The No-regret (sub-linear) algorithm is g... |
I'm going through a tutorial that is using the Game of Life as example code. It has a function in it that finds the neighbor of a given cell. It is explained quickly that "When applying a delta of -1, we add self.height - 1 and let the modulo do its thing, rather than attempting to subtract 1" which would require a bun... |
I am doing some exercises on dynamic programming in order to get familar with this concept.
I've noticed that most of the time it's not difficult to calculate the complexity of a program using dynamic programming since most of the time we are recursively calculating a function $f$.
Let's suppose this function $f$ has ... |
Having two bit strings $x,y \in \left\{0,1\right\}^n$, where $x$ is selected following a uniform distribution but $y$ is not.
Is $z = x \oplus y$ uniform?
|
The Problem:
Given 3 inputs Bounce, Ball drop height, and ball view height.
How do I calculate the number of times the observer can see the ball pass.
So my code gives correct output, but it takes a longer time as bounce approaches 1, how do I make it deterministic in nature.
def bouncingBall(h, bounce, window):
... |
I would like to select an appropriate number of buckets in my hash table for this scenario:
A hash table with collision resolved is required to hold about 10000 records. Each record is to be indexed by the 2-character initials of the customer's name, transformed into integers using the mapping: A=01, B=02,..., Z=26. It... |
I was given a question that is stated that;
Suppose you’re consulting for a bank that’s concerned about fraud
detection, and they come to you with the following problem. They have
a collection of n bank cards that they’ve confiscated, suspecting them
of being used in fraud. Each bank card is a small plastic obje... |
I want to be able to recognise handwritten math numbers using images of the numbers , i was able to do create a ANN model for recognising simple decimal numbers , but i have no idea on how to recognise fractional number.
What kind of ML model do i need to recognise fractional numbers (p/q forms). As i am relatively n... |
Recently while solving programming challenges for the fun of it, I encountered a challenge which left me kind of puzzled and yearning for a proper solution, other than brute forcing. The problem (stated in my own words) is as follows:
In each testcase you are given N (6 <= N <= 10) sticks.
Each stick has length L (1 <... |
In the common model of FSA, the automaton reads the input string once, moving from one state to another after reading each letter in the input string. Epsilon transitions allow moving from one state to another without reading a character. However, the movement over the input string is still unidirectional.
Is there a ... |
A friend of mine and I are trying to teach a bot play a card game (bela)
We are using monte carlo tree search (MCTS) to estimate the probability of winning hand in regards to multiple possible (!important) card configurations.
We are randomizing both plays and possible card configurations. The problem is not all card c... |
Prove/disprove that the class of decidable (resp. partially decidable) languages is closed under symmetric difference. A symmetric difference of sets A and B is the set (A \ B) ∪ (B \ A).
I know that the class of decidable languages is closed under symmetric difference, because it is closed under union, complement and ... |
Having two deterministic functions $G_1, G_2 : \left\{0,1\right\}^\lambda \rightarrow \left\{0,1\right\}^{\lambda+l}$, at least one of which is a secure PRG.
Being $\alpha$ a constant, is it possible to build a secure PRG $G' : \left\{0,1\right\}^{\alpha\lambda} \rightarrow \left\{0,1\right\}^{\alpha(\lambda+l)}$ using... |
The title may be a bit confusing but the problem is this;
Lets assume I have 5 points in 4 groups (in total 20 points). What I want to achieve is;
-> Pick one point from each group (we will have 4 points at the end)
whose pairwise distance is larger than a threshold and
sum of pairwise distances is maximized.
For rea... |
Here is an approximation algorithm that finds vertex cover of a graph.
C = {}
E' = {Edge set}
while E' =/ 0
Let (u,v) be an arbitrarily edge of E'
C = C U {u,v}
remove E' incident on u and v.
return C
A variant: what if instead of removing edges incident on both $u$ and $v$, we removed only $u$. Would th... |
Can addition (or subtraction) of polynomials of degree $< n$ be done in constant time ?
I am quite new to algorithms. I thought about using sorted arrays for storing the coefficients. But the addition of two sorted arrays appears to be $\in O(n)$. However, I am not convinced that this is the best solution. Could some... |
I'm exploring algorithms to compress small strings like the following - every line is to be compressed individually, i.e. even those small strings should get compressed:
ZYXH1|104932,104932,927.6000,200,1,927.4000,1600,1
ZYXH1|104932,104932,3390,1600,1,3389,2700,1
HXDFF|0001739.42;HXDFF:Y|0U010:49:32
ZYXH1|104932,10493... |
Assume the language:
$$L=\left\{w\in\{0,1\}^*\,| \text{ w has odd length and 111 right in the middle}\right\}$$
This is my attempt for constructing a grammar $G$ for this language:
$$G: S \rightarrow A111B,\, A \rightarrow 01B |10B|00B|11B,\, B \rightarrow 01A |10A|00A|11A$$
This process adds random even strings of $\... |
I was recently helping a friend with homework from a dynamic programming class, and this was the question:
Given a set of
n
precincts
P1
,...
Pn
, each containing
m
votes, with n being even. We
want to divide each precinct into two districts, each consisting of
$\frac{n}{2}$ of the precincts. For each precinct, we k... |
I got the following from a web site:
The feature vectors represent each image as a linear combination of
the eigenfaces defined by the coefficients in the feature vector; if
we multiply each eigenface by its corresponding coefficient and then
sum these weighted eigenfaces together, we can roughly reconstruct the... |
The problem is:
Suppose you're given $n$ points in the coordinate plane, and for convenience assume that no two of their $x$ or $y$ coordinates are the same. Design an algorithm that finds the shortest possible distance between a pair of these points. What is the time complexity of your algorithm?
Ofcourse there is a... |
Lemma 4 in How easy is local search by Johnson, Papadimitriou, and Yannakakis, states:
If a PLS problem is NP-hard then NP = P
So assuming L is a PLS problem (polynomial local search problem) that is NP-hard, then every NP problem can be reduced to L.
Usually if $P_1$ is reducible to $P_2$ (being two decision proble... |
Given is the following recurrence relation:
$T(n)=n^2+T(\frac{n}{2})+T(\frac{n}{4})+T(\frac{n}{8})+...+T(\frac{n}{2^k})$
where $k$ is some constant and $n = 2^t$ for some $t\in \mathbb{Z}$.
I'm trying to find an asymptotic bound for $T(n)$.
My work so far:
First, I've tried to guess and prove by induction.
Then, I tri... |
I am confused regarding Binary Search Trees (BST) when an element does not exist in the tree.
For example, to search for element "6", would it take 5 comparisons to search for this element?
My understanding is:
Compare root (Not found - move left)
Compare left node (Not found - move left)
Compare left node (Not found... |
How can I show that $\{a^ib^jc^k|i=0 \lor j=k\}$ is not regular?
I tried applying the pumping lemma but it does seem to have a pumping length of 1?
Alternatively there is the Myhill–Nerode theorem.
Are $\{a^ib^j|i=0 \lor j\in\mathbb{N}\}$ infinite many equivalence classes?
|
I have a problem (A) on undirected graphs that I wish to show is NP-Hard. I can show that there is a reduction from a well known NP-Hard problem (B) to A by constructing an instance of A with a complete graph that solves B.
Since undirected graphs generalize complete graphs, am I safe in saying that A is NP-Hard for u... |
The title should explain my question thoroughly enough. I can't seem to get started anywhere. Intuitively it seems like some kind of brute-forcing would work i.e if the DFA has the symbols $\Sigma$ you would simply be passing strings from $\Sigma^*$ until the DFA rejects. What would even be the time complexity of this ... |
We know that if we have two languages produced by one regular grammar, then any language produced from the union, intersection, and so on would be regular.
What if we have a regular grammar that produces language A and a different regular grammar that produces language B. Then could the closure properties still be used... |
The DNG specification (page 87) describes a simple algorithm for converting a "fish-eye" photo into a regular photo (just several lines of basic geometry).
The transformation is configured using six numbers: $k_0, k_1, k_2, k_3, c_x,c_y$. Does it allow to represent identity (i.e. not changing the photo at all)? In orde... |
We were given an exam question of: Given a flow network G=(V,E) with integer edge capacities, a max-flow f in G, and a specific edge e in E, design a linear time algorithm that determines whether or not e belongs to a min-cut.
From the grading rubric we are told a correct algorithm - I got dinged for not having the cor... |
We have problem X and Y that we know is NP-Complete. Problem X uses graph G as an input and Problem Y uses graph G and constant k as an input.
Problem we are trying to reduce to, which I will call Z, is reasoning whether given a graph G and constant k, does G have X or Y.
I have been trying to solve this problem and an... |
Assuming an algorithm $A$ known to both Alice and Bob.
Alice runs the algorithm and gets a result $R$.
How can Alice prove to Bob that $R$ is the result of the execution of $A$ and not some random value (without having Bob run the algorithm himself)?
The goal is for Bob to perform less calculations checking Alice proof... |
When storing the encoded Huffman bit stream in bytes, in general, either
the final byte gets padded or
a pseudo end-of-file symbol gets used
In the former case, the number of bits padded needs to be stored somewhere, requiring another 3 bits. In the latter, you will lose some efficiency due to the additional pseudo s... |
So this a question from my book and I have to make CFG of this language but I am confused what does it mean when it says
"L contains palindromes that don’t ever have the same character occur twice in a row."
Let $\Sigma = \{a, b, c\}$.
Let $L = \{w \in \Sigma^∗| w = w_1w_2\cdots w_n \mbox{ is a palindrome and } w_i \n... |
The Wikipedia page for vEB trees (specifically the version from 27 September, 2018),
gives the following pseudocode for finding the successor element of x in the vEB tree (of universe of size M):
function FindNext(T, x)
if x < T.min then
return T.min
if x ≥ T.max then // no next element
return M... |
Given a simple undirected graph with no self-loops, $G = (V,E)$, where $V = {1,2,...,n}$, an $n × n$ matrix $A$ is said to be the adjacency matrix of $G$ if $A_{i,j}$ is $1$ if $(i, j) ∈ E$ and $0$ otherwise.
Now, suppose we define a special kind of matrix product for matrices whose entries are only 0 or 1. In this spe... |
So this a question from my book and I have to make CFG of this language but I am confused what does it mean when it says
"L contains palindromes that don’t ever have the same character occur twice in a row."
Let Σ = {a, b, c}
Let L = {w ∈ Σ∗| w = {w1, w2, . . . , wn} is a palindrome, and wi 6= wi+1 ∀ 0 ≤ i < n}.
In ot... |
In practical applications, search algorithms are often strengthened using heuristics. e.g., Deep Blue beat gary kasparov by searching through possible chess moves by "guiding" its search with human-chosen heuristics. These heuristics are not proven to be the optimal heuristics. (they're not optimal obviously).
I am wo... |
For example, in the proof of lemma 6.4.1 in the HoTT book, a function inductively defined over a function is simply applied on paths loop and refl, and then a path between loop and refl is used (presumably by congruence via f) to construct a path between f loop and f refl:
Suppose that loop = refl base. [...] with x :... |
Our course lecture slides divide architectures of distributed systems into:
object based architectures (e.g. typical distributed web application)
resource-centered architectures (e.g. torrents and magnet links)
event-based architectures (e.g. ???)
I do not understand the explanation on the slides and they don't provi... |
Theorem 7.11 in Introduction to the theory of computation 3rth edition says
Let $t(n)$ be a function where $t(n)>n$. Then every $t(n)$ time
nondeterministic single-tape Turing machine has an equivalent
$2^{O(t(n))}$ time deterministic single tape Turing machine.
I can understand that in this proof when we have a ... |
Certain special forms of the SAT problem have solution sets of a special form. For example, given any three solutions to a 2-SAT circuit, their bitwise median is also a solution. Likewise, given any three solutions to an XOR-SAT circuit, their bitwise XOR is also a solution. Lastly, given any two solutions to a HORN-SA... |
I need to prove/disprove the correctness of the following algorithm:
Let G be a simple, undirected and connected graph. The task is to find if the graph contains an odd cycle. The algorithm goes that way. First, you run the DFS algorithm on the graph, since it is connected it will result in a single tree. The for each ... |
To go with $O(n)$, we can use the linear sieve according to that $\mu(n)$ is multiplicative. But it seems that we don't have to work each $\mu(n)$ out and accumulate them together, because I only want to get $\sum_{i=1}^n \mu^2(i)$.
I am interested that is there any solutions that are faster than $O(n)$ to work $\sum_{... |
Here is the problem I have attempted to solve.
Given original principal $n$ and aggregate rate $r$, find the maximum final principal that can be yielded.
Though I know that the higher the compounding frequency is, the higher the final principal will be, a special condition applies:
Intermediate principals are rounde... |
Let $G = (V, E)$ be a connected undirected graph with $n > 4$ nodes $V = \{v_1, v_2, \dots, v_n\}$ and $m$ edges.
Let $\{e_1, e_2, \dots , e_m\}$ be all the edges of $G$ listed in some specific order. Suppose that we remove the edges from $G$ one at a time, in this order. Initially, the graph is connected, and at the e... |
I'm trying to design an algorithm for evenly fitting decimal numbers into a decimal number.
Say I have a set $N$ of decimal numbers ($N_1$, $N_2$, ..., $N_n$) and a target value $Y$. I'd like to see what combination of values of $N$ (values may be used zero to many times) add up evenly to $Y$.
I've accomplished it by s... |
The definition of vertex cover is as is:
Set of vertices such that each each has atleast one endpoint in that set.
In the above example, why can't we consider all vertices as vertex cover since all vertices are endpoints to all the edges.
|
The Problem
There is no easy way to get a permutation with a regex.
Permutation: Getting a word $$w=x_1…x_n$$ ("aabc") to another order, without changing number or kind of letters.
Regex: Regular expression.
For verification:
"Regex permutations without repetition" The answer creates JavaScript code instead of a reg... |
Corollary 23.2
Let $G = (V,E)$ be a connected, undirected graph with a real-valued weight function $w$ defined on $E$. Let $A$ be a subset of $E$ that is included in some minimum spanning tree for $G$, and let $C = (V_C,E_C)$ be a connected component (tree) in the forest $G_A = (V,A)$. If $(u,v)$ is a light edge conne... |
I have a string like this:
11,512,64,23,46,12,67,85,84
And I'm sure it's following these rules below:
Only , and 0123456789 in it.
No number will be bigger than 999, that means they are all 1,2 or 3 digits number.
Are there any simple algorithms that I can have to compress/decompress the data?
For instance, a very s... |
I have a closed 2D shape expressed as a list of points, like that:
[
{0, 5}, <-- {x, y}
{10, 5},
{15, 6},
...
]
The user has a canvas: each time he clicks on that canvas, a point will be appended to the list, and he will see the updated shape on screen.
How can insert the point between two nearest points inst... |
I'm reading the CLRS book and have a question about the following quote from the book.
In order for radix sort to work correctly, the digit sorts must be stable.
Why is stability required? Wouldn't Radix sort still produce correctly sorted output even if there was no consistency in ordering of identical values, sinc... |
So let's say I've implemented an algorithm running in $O(n^2)$ on my 3-tape TM. What kind of time complexity would I expect for a single-tape TM?
I just don't know where to get started...
|
A source emits 5 signals s1, s2, s3, s4 and s5 whose probabilities are as follows: 1/3, 1/3, 1/9, 1/9, 1/9, 1/9. How many prefix codes we can construct on A={a, b, c}? And how many are there with the same performance (efficiency)?
|
I'm trying to minimize the area of a simple (non-intersecting, without holes) polygon by adding points to it, or modifying points of its subset. Let me describe this more formally:
Let:
$P$ be a polygon consisting of points $\{x_1,x_2,...x_n,x_1\}$
$S$ be a subset of $P$, bounded by points $x_j$ and $x_k$:
$m$ be a n... |
Currently doing an Algorithms course in my 2nd year of university (I am a maths student, but thankfully at Warwick University, we have quite a flexible degree). One of the topics we cover is the divide and conquer algorithmic paradigm. Some algorithms we have studied/I have read about are mergesort, max subarray proble... |
It is often stated that the MAX-XOR-SAT problem is NP-hard, and that likewise is the MAX-2-XOR-SAT problem. However, I cannot find a reduction from SAT to either of these problems, nor a proof of NP-hardness. Is one published anywhere?
|
This is an interview question I was asked, which I don't know how to approach. I would appreciate pointers to algorithms I should look up.
You are placed on the real line, and there also are $K$ lions on the real line, which are currently sleeping. You are given the wake up time of each lion. You can walk past a lion a... |
I need to compare each index with one another and associated array value as well.
For example,
for(int i = 0; i < n - 1; i++) {
for(int j = i + 1; j < n; j++) {
if(a[i] > a[j]) { // Condition will be any
swap(a[i], a[j]); // Any action
}
}
}
Inside loops, there is a condition t... |
I am looking for some puzzles like Sokoban or 15-puzzle but more difficult to solve and satisfy the following requirements:
The number of possible moves at each step should be limited, let's say < 10.
Easy to generate a lot of levels (unique instances of puzzle). Let's say > 10**8.
One player.
Ideally has a terminate ... |
Studying for a test in a computer science class and cannot figure out the answer to this question. Any help would be appreciated!
Although the picture shows a directed graph, please treat it as an undirected graph, ignoring all the edge orientations.
|
I am trying to understand the runtime of Pollard's $(p-1)$-algorithm as presented on Wikipedia. There the author writes that it takes $\mathcal{O}(B\log B\log^2n)$ time, but I do not see why.
Here the Wikipedia version:
Inputs: $n$: a composite number
Output: a nontrivial factor of $n$ or failure
select a smoothness b... |
I am trying to complete question and would like to avoid copying answers, but I do not necessarily understand what I am doing.
I am working on the following problem:
Suppose you are consulting for a company that manufactures PC. equipment and ships it to distributors all over the country. For each of the next n weeks... |
Let's say we have given tree of $N$ nodes and $N-1$ edges, each of the $N$ nodes is assigned one integer, either $0$ or $1$. We want to count all paths between two nodes $u$ and $v$ such that on the shortest path from node $u$ to node $v$ there are odd numbers of ones ( or in other words the sum of all integers on this... |
I am trying to learn how to determine time complexity. Sometimes, I see complexity as $\log n + \log n = 2\log n$ but sometimes I see complexity as $\log n\cdot\log n$ which is $(\log n)^2$.
Suppose I need to do two binary searches to find two different elements, in one algorithm. Is this $\log n + \log n$ time, or wou... |
Assume I have the following list of companies:
Apple
Big Apple
Google
Then I have this sample string:
Big Apple is a company that is trying to be the next Google.
Given the list of companies and the sample string above, how can I find the list of companies in the sample string?
If I iterate through the list of comp... |
This was part of my interview questions.
Given a sequence of integers as an array, I have to determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array.
For instance,
For sequence = [1, 3, 2, 1], the output should be
almostIncreasingSequence(sequence) ... |
I've been studying some number theory, and I came across this problem:
Lagrange’s prime number theorem states that as N increases, the number of primes less than $N$ is $Θ(N/ log(N))$.
Consider the following algorithm to choose a random n-bit prime:
1) Pick a random n-bit number $k$.
2) Run a primality test on $k.$
3... |
Given a string of values $AAAAAAAABC$, the Shannon Entropy in log base $2$ comes to $0.922$. From what I understand, in base $2$ the Shannon Entropy rounded up is the minimum number of bits in binary to represent a single one of the values.
Taken from the introduction on this wikipedia page:
https://en.wikipedia.org/wi... |
First I have general question. In a circuit with both logic and D edge flip flop does hold time have to satisfy $t_{hold} < t_{setup}($D-FF$) + t_{pd-min}$(Logic),
or is it enough that $t_{hold} \le t_{setup}($D-FF$) + t_{pd-min}$(Logic) ?
Also i have a question about a specific circuit:
with the following times:
th... |
Consider the recurrence
$$ T(n) = 3 T(n-1) + 10 T(n-2) + 7 \cdot 5 ^ n, $$
with base cases $T(0) = 4$ and $T(1) = 3$.
How do I solve such a recurrence?
|
I want to compute the difference/intersection between two paths. By path I mean a list of points that can be created by the following actions on a graphics context:
move to x, y
line to x, y
Bézier to x, y
How could I do that? What's the best algorithm to compute the difference/intersection between two paths, A - B? ... |
Suppose we're given an infinite stream of integers, $x_1, x_2, \dots$.
a) Show that we can compute whether the sum of all integers seen so far is divisible by some fixed integer $N$ using $O(\log N)$ bits of memory.
b) Let $N$ be an arbitrary number, and suppose we're given $N$'s prime factorization: $N = p_1 ^{k_1} p... |
Given $n$ bins in a row (numbering from $1$ to $n$) and $2k$ balls ($n \ge 2k$), one may put all balls into bins with each bin having at most one ball (there are $\binom{n}{2k}$ configurations). Denote the indices of bins having balls as $x_1, \cdots, x_{2k}$ in ascending order ($x_1 < x_2 < \cdots < x_{2k}$). We defin... |
There are two sorted arrays nums1 and nums2 of size m and n respectively.
Find the median of the two sorted arrays.
Example 1:
nums1 = [1, 3]
nums2 = [2]
The median is 2.0
Example 2:
nums1 = [1, 2]
nums2 = [3, 4]
The median is (2 + 3)/2 = 2.5
Here is my solution:
//Find out the median of two sorted array
public class M... |
I just started learning about linear programming in my class, and I'm having some trouble understanding the MST Formulation Integer Linear Programming (Cutset Formulation).
This is the definition:
$x_{ij}$ is defined to be $1$ if the edge $ij$ is in $T$.
What exactly does the optimum value represent here? Is it the n... |
I am trying to write a recursive-descent parser for untyped lambda calculus. While researching the way of formulating the grammar, I managed to put together something like this:
without left-recursion:
TERM -> APPLICATION | ABSTRACTION
ABSTRACTION -> LAMBDA LCID DOT TERM
APPLICATION -> ATOM APPLICATION'
APPLI... |
I'm given the Bernoulli distribution of a biased coin toss with probability distribution $P_X = \{0.2, 0.8\}$ over the alphabet $\mathcal{A}_X=\{0,1\}$.
I want to sketch the normalized essential bit content $\frac1N H_\delta(X^N)$ as a function of $\delta$ for $N=1000$, where:
$X^N = \{X_1, X_2,\dots,X_N\}$ is the ou... |
I came across a serious doubt regarding the implementation of the Dijkstra algorithm and hence wanted to discuss.
For the given below graph
What should be the Cost to reach Node G from Source Vertex A?
I was getting 2, as vertex E is the last processed vertex and when it was being processed
$E.d=9,(E,G)=-7$ so $G.d=2$... |
How can I prove that this language is regular, possibly by making a finite automata for this: $(ab)^*(cb^n)^*$, where $n\ge1$?
An automaton can easily be drawn for the part $(ab)^*$, but the part $(cb^n)^*$ doesn't seem to be regular because if the Kleene closure is taken $\ge2$ times, then it will be of the form $(c... |
I want to know for what types of graph it is possible to find Hamiltonian cycle in polynomial time. It would be helpful also to show why on some types of graph finding Hamiltonian cycle would be only possible in exponential time.
|
I've heard many times people debate the possibility of a real world computation that is impossible for a Turing machine, especially in the context of a human mind. Implying that the Church-Turing thesis is wrong and that a Turing machine does not accurately model any possible real world computation. To me, it seems tha... |
Administrative normal form is a program intermediate representation in which each immediate instruction has a name. It is used in GHC and OCaml.
K-normalized form is an intermediate representation in which each instruction consists of one assignment and operation. It's used in MLKit, Min-Caml, and GoCaml.
Both A-normal... |
Given two lists of complex numbers, is there an efficient algorithm to choose one element from each list such that the magnitude of their sum is maximal?
|
Nomenclature
The term expressive in the question shall bear the same meaning as in the following sentence:
A Turing Machine is as expressive as Lambda Calculus.
Introduction
While learning Haskell, I had noticed that there are 2 ways to achieve the same effect, namely Pattern Matching and Case Expression. For example... |
so I have spent nearly 5 hours trying to simplify this particular expression but I keep going round and round in circles. I have my hard copy notes to show you where I scribbled for hours and hours to no end. so please can someone please show me how can this be done?
$$(\overline{A}+\overline{B}+E)(\overline{A}+\overl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.