instruction stringlengths 35 29.1k |
|---|
With only using our thinking. What do I have to think about when finding a complement of a Turing machine for example.
L={M∣M is a TM that halts on empty tape after even transition steps}
What's the complement of L would it be:
L={M∣M is a TM that does not halt on empty tape after even transition steps}
L={M∣M is a TM... |
I am wondering how to get started in studying theoretical computer science and how to apply it to my programming. I am fairly comfortable with basic programming, having been programming in mainly C++ but also Java for the past couple of years, so I don't necessarily need an introduction to programming.
What I am lookin... |
I have a b+ tree and i want to find the record associated with a specific key Ki.
So i run the b+ tree search algorithm. If a certain node in the search path is a leaf and K=Ki, then the record exists in the table and we can return the record associated with Ki.
Since the leaf nodes have the same structure of internal ... |
I know for a fact that algorithm A runs in $\Theta(n)$, but how does one derive that?
Algorithm A
i = 1
while i ≤ n
s = 0
while s ≤ i
s = s + 1
i = 2 ∗ i
The inner loop is clearly $O(i)$ (linear time).
The outer loop is clearly $O(\log n)$ (logarithmic time).
A visualitation of the loop in terms of an input ... |
The $\text{SCR}$ representation of a graph $G=(V,E)$ is $C_{G}$ id the following conditions hold:
$C_{G}$ is a combinatorial circuit with memory.
$C_{G}$ has two inputs of length $n$ bits.
$C_{G}$ has $r$ gates, where $r = \mathcal{O}(n^{k})$ for some integer $k$. link
The output of $C_{G}$ is
$$C_{G}(i',j') = 0, \te... |
I am reading about a counter implementation in RISC Architecture. The specification reads,
Sticky overflow bit is set when the counter wraps through zero.
I can infer that the overflow bit is set when the counter reaches maximum value(all 1's) and another increment makes it 0(all 0's). What is the meaning of the st... |
If I have (I-Z) where I is a 3x3 identity matrix while Z is a 3x3 lower triangular matrix, how many subtractions that I should count from this process?
Is it costs K subtractions or (K^2+K)/2 subtractions?
Thank you.
Huda
|
I have a function I'm minimizing. I'm using conjugate gradient descent and the Newton algorithm.
I am experiencing that the Newton algorithm is absurdly faster. Like, it finishes it 5-6 iterations, while the conjugate gradient takes 2000 iterations (and regular gradient descent takes 5000 iterations).
I know what's cau... |
I'm working on a tile based game idea in Javascript. It's a math puzzle game where players move around tiles with numbers on them, and the goal is to connect groups of tiles that have a sum of certain goal number, for example 5 or 7 or 9.
However, I'm stuck on the algorithm to detect these sum groups. I know how to do... |
I was following a discussion on a forum where a person has asked whether the following generates lexical errors or not,
(1) char p="gate;
(2) int /* n;
(3) printf("%d, n);
When I tried to run them on my CPP compiler I got these errors respectively for the following 1, 2 and 3
When I looked them up on the internet ... |
I am preparing for the exam on Theory of Programming class. Now I am trying to solve the task from the sample paper:
Task description starts here
Given the following problem:
A problem is given by its specification:
Let S denote the following program:
Write down the conditions that are sufficient to prove that the g... |
Please, read the whole question before answering, the exact details of the implementation are important.
Suppose that you want to find largest cardinality bipartite matching in bipartite graph with $V = L + R$ vertices ($L$ is the number of vertices in the left-hand side and $R$ is the number of the vertices in the rig... |
I have a lexicographical order on integer $n$-tuples, where $(x,y,\dots) > (a,b,\dots)$ if $x>a$ or if $x=a$ and $y>b$, and so on to the end of the tuple (I called it lexicographic because of its similarity to the natural order on strings of $n$ characters). In this order I have a range, defined inclusively by a pair o... |
I need some help with a problem. I have currently an algorithm. This algorithm gives me a true or false for a variable which I need to iterate( e. g. From 0 to 100} . Till now I solved it with a brute force method. So I just enhance the variable by a factor, enter the variable to the algorithm till I get a true.
This ... |
Given the tuple (list, value):
$$\left(\left[x_1, x_2, \cdots x_n\right], y\right)$$
You may choose two adjacent values in the list to modify the tuple as:
$$\left(\left[x_1, x_2, \cdots x_{i-1}, (x_i + x_{i+1}), x_{i+2} \cdots x_n\right], y + x_{i} + x_{i+1}\right)$$
Iterate until:
$$\left(\left[\sum_i x_i\right], y +... |
In the book Information theory, Inference and Learning Algorithm, in chapter 13, MacKay defines bounded distance decoding
A bounded distance decoder is a decoder that returns the closest codeword to a received binary vector $\mathbf{r}$ if the distance from $\mathbf{r}$ to that codeword is less than or equal to $t$; o... |
I am trying to understand oblivious Turing machines. According to the book of Arora and Barak, a TM $M$ is oblivious if the location of each of its heads at the $i$-th step of execution on input $x$ is only a function of $|x|$ and $i$ for every input $x\in{\{0,1\}^*}$ and $i\in{\mathbb{N}}$.
Here is my understand, supp... |
The numbers in the table below are the result of executing an algorithm that has one parameter N, a non-negative integer, and produces sequences of integers as outputs. For values of N from 0 to 5, the algorithm produces the following sequences of numbers as outputs.
|
I was trying to do some code golf, when I created the following algorithm to shuffle a string:
for(;k-->0;y=s,s="")for(var c:y.split(""))s=Math.random()<.5?s+c:c+s;
To explain better what it does, I've recreated it in Python:
import random
str = "Randomize me!"
print('[',str,']',sep='')
temp=""
for _ in range(len(str)... |
I have a multi-objective optimization problem (NP-complete). To solve it, I've decided to use the genetic algorithm.
I have 3 "areas" of optimization, say parameters a, b and c, so cost function for my problem is C(F) = a + b + c -> min.
I want to somewhat modify the genetic algorithm. In the classic workflow, the init... |
Looking at a "Distributed" algorithm from a textbook on distributed algorithms (e.g. Building a spanning tree, Broadcast/Convergecast.) I found that one can implement it using Golang's concurrency primitives (i.e channels and goroutines)
AFAIK "distributed" means things are happening on multiple machines. But this is r... |
we are given an Array
Array size <= 10^4 .
0 <= A[i] <= 15
We need to partition the array into 4 subsets (each subset can have zero or more elements ). Take xor of each subset and sum those xors.
for example, one subset could have indices 0, 3, and 7, and another subset could have indices 1, 2, and 4
find the max sum.... |
The problem of scheduling lectures in minimum number of classrooms is as follows:
Find minimum number of classrooms to schedule all lecture so that no two occur at the same time in the same room.
The common algorithm that I find in books is:
Sort intervals by starting time so that s1 ≤ s2 ≤ ... ≤ sn.
d ← 0 //number of ... |
These are the instructions I been given :
What does the array look like at each step when inserting "2" into the
following min-heap?
Give your answer as comma-separated numbers, with a space after each
number, eg., 0, 2, 3, 4
The heap starts at entry 1 (second entry) of the array, so begin with
"0,..." for the... |
I am interested in the following question:
Prove that the average length of a codeword constructed by Huffman's algorithm has average length at most $\log n$, where $n$ is the number of codewords.
I'm thinking of a worst case when the full binary tree (generated by Huffman's algorithm) has height $n-2$, but I still h... |
I have searched the web and I have only found the differences between Image Processing and Computer Vison (also in this website too). In addition, sometimes Image Analysis is confused with Image Processing, which is untrue. Reading the Wikipedia article, it makes me thing that Image Analysis is another name for Compute... |
I need to show that the following language, L = {$\langle M \rangle$ | The set of words which M halts on is decidable}, is not recursively enumerable. In the instructions they advise thinking of a reduction that is similar to the one used in the proof for Rice's Theorem in Sipser's 3rd edition (page 243). I couldn't th... |
The fields of applied math and computer science are inundated with optimization algorithms, variations on those optimization algorithms, and variations on those variations.
I'm mainly talking about heuristic algorithms such as evolutionary search, particle swarm, simulated annealing, and their many, many variants.
Is t... |
I tried to solve if a grammar is ambiguous or not.
I know that I have to find a word that can be generate by two different leftmost derivations.
Is there any algorithm to find a word that, if the grammar is ambiguous, can be generated by two different trees?
This question is different.
|
Given an array of size $n$, we have to find the maximum number of multiples of $A[i]$ in the array, where the indexes of the multiples should be less than $i$.
For example, given the array
36 40 16 24 27 12 9 4
We see that element 4 has the highest number of multiples (5) as per the given conditions, so the answer is... |
I would like to prove that the following subset is outside both RE and coRE:
$$A = \{ (p, (d_1, d_2,\dots, d_k)) \mid \text{for each } 1 \le i,j \le k, \; [p]d_i = [p]d_j \}, $$
where $p$ is a program, $d_i$ are inputs, and $[p]d$ is the result of running $p$ on the input $d$.
I was thinking about creating a mapping re... |
I'm studying Computer science and this has confused me for a long time since our professor didn't give any proof.
When changing from 2's complement to the positive value, we can go in reverse (by subtracting 1, then using 1's complement), and that's clear why it works.
But our professor told us another method which is ... |
In Balanced Binary Search Trees on the basis of size of left and right child subtrees, Hannes says:
For example, one can say, a BST is balanced, if each subtree has at
most epsilon * n nodes, where epsilon < 1 (for example epsilon = 3/4
or even epsilon = 0.999 -- which are practically not balanced at all).
The r... |
Consider that a currency system has $k$ denominations $d_0, d_1, ... d_{k-1}$. $d_0, d_1, ... d_{k-1}$ are such that $d_0 < d_1 < ... < d_{k-1}$ and $d_i$ divides $d_j$ for all $0<=i<j<k$. Example: ₹1, ₹5, ₹10, ₹20, ₹40, ₹80. As a cashier at a cash register I need to service $n$ customers, buying things that are worth ... |
Could someone provide a rigorous proof of why $O(n^{log n}) \leq O((\log n)^n)$ is true? I'm trying to do this by induction but it isn't working. Thanks.
|
If we say that the grammar for the language $L = \{ww \mid w \in \{a,b\}^*\}$, is:
$\begin{align}
S &\rightarrow A_1A_2S \mid B_1B_2S \mid Z_2\\
A_2A_1 &\rightarrow A_1A_2\\
A_2B_1 &\rightarrow B_1A_2\\
B_2A_1 &\rightarrow A_1B_2\\
B_2B_1 &\rightarrow B_1B_2\\
A_2Z_2 &\rightarrow Z_2a\\
B_2Z_2 &\rightarrow Z_2b\\
Z_2 &... |
Suppose the given proposition is:
"Zach blocks emails and texts from Jennifer"
Where,
P implies "Zach blocks emails from Jennifer".
Q implies "Zach blocks texts from Jennifer".
So it's P AND Q in logic.
Now we want to find its negation. So what I found as it's negation is:
"Zach does not block emails from Jennifer, or ... |
We are given two numbers N and K.
N <= 10^9.
K<=min{1000,(N*(N-1))/2}
We need to find numbers of permutations of ( 1 to N ) such that inversions are exactly K.
If N was <= 10^3. It would be a simple Dynamic programming question.
https://www.geeksforgeeks.org/number-of-permutation-with-k-inversions/
can we optimize it?... |
I was recently stuck while doing a question, please suggest a way with a code/pseudo code to optimize the following algorithm for finding the maximum good value in an array where a good value of an array element $A_i$ is defined as the total no. of Valid indices $<$ such that $_$ is divisible by $_$. My approach is as ... |
How it can possible
$\ 1/2n^2 -3n = Θ(n^2) $
Why we dont care $\ 3n $ and $\ 1/2 $
|
Here's the start and the vernacular I'm using.
# in class Scene
@staticmethod
def common_ancestor(item1, item2):
if item1 is item2:
return item1
com = Scene.common_ancestor(item1.parentItem(), item2)
if com is None:
com = Scene.common_ancestor(item1, item2.parentItem())
return com
Any... |
I am trying to prove the following problem, but honestly I don't know what "proof" is considered a good proof.
I tried to prove it by constructing an NFA that start with w1 and ends with wk, but I feel something is missing.
I also tried to prove it by showing that w1 ∈ L1, w2 ∈ L2, …, wk ∈ Lk and a ∈ La.
thus Langua... |
Let $BAL_{DFA} = \{<M> \mid M \text{ is a DFA that accepts some string containing an equal number of 0's and 1's } \}$ Show that $BAL_{DFA}$ is decidable.
Generally such questions seem to be solved by constructing a DFA that accepts all strings that have equal number of 0's and 1's and then constructing a DFA that acce... |
Does there exist a normal-form lambda calculus program $f$ such that
$f (\lambda x . x)$ normalizes
For all normal form $e \ne \lambda x . x$, $f e$ does not normalize
|
Can someone help me to write a Turing Machine that decides whether its input sentence is in a particular language or not? This particular
language generates alternating 01's. If it decides the input is in the
language it enters to the halting state 'y', otherwise it enters to the
halting state 'n'.
Example sentence... |
Let's say I have two buckets coloured red and blue, both of which can hold two rocks. I need to divide a set of $n$ weighted rocks into these buckets in such a way as to minimize the total weight of the rocks in the buckets, while filling each bucket to its capacity.
An additional constraint is this: the rocks are them... |
Given a list of "forbidden" words (substrings), an alphabet, and a desired output string length, how would I efficiently sample output strings containing no forbidden word?
For short output strings with few forbidden words, I would use simple rejection sampling. Pick a string (uniformly) with the specified alphabet and... |
I am trying to fully understand the following algorithm from CLRS book:
I like to think that it works similarly to Bellman-Ford algorithm by relaxing all edges once for every vertex in the graph. Then we repeat the process for every source vertex $s \in V$. But then looking at the three nested loops in EXTEND-SHORTES... |
I have this 3 heap max heap that I need to write the array for it, but I'm not sure how. Would it just be
20,18,13,15,11,12,16,10,9,11,13,2,9?
|
It does make sense when we talk about perfect matching in bipartite graphs because there are two sets of points, for example, one set may be jobs and other set may contain different machines. But when we talk about minimum cost perfect matching in general graphs, it is not making any sense for me, what are the nodes an... |
I have a list of patterns, and I need to find the pattern that matches an input string the most. I.e.:
Patterns:
[
'AB1XXX',
'AB2XXX',
'ABXXXX-0080',
'BC1XXX',
'BC15XX'
]
The X character in the patterns is reserved as the wildcard or don't care character. It can be any single alphanumeric character... |
this is a problem which was asked in GATE CS 2010.
This is question statement:
Q: Suppose the predicate F(x, y, t) is used to represent the statement that person x can fool person y at time t. which one of the statements below expresses best the meaning of the formula ∀x∃y∃t(¬F(x, y, t))?
Options:
A: Everyone can fool... |
A homework problem I have asks that I "state" a loop invariant, then "prove" it, then "apply" it. I get state and prove, but my textbook doesn't explicitly state how to "apply" a loop invariant.
|
I am working with a particularly forgiving interpretation of $\Box$ in Modal Predicate Logic. $M, w, g \models \Box \varphi$ iff for every $w' \in W$ such that $wRw'$, $M, w', g \models \varphi$ IF $\varphi$ is defined in $w'$. This mostly means that, for any constant $a$ that is nominated in $\varphi$, if $a \notin D... |
I could not find the answer on the Internet. The case of quadratic programming with constraints is already solved on this forum, see Transforming SAT to Quadratic Programming in polynomial time. But what happens if there are no constraints or if the only acceptable constraint is that the variables are non-negative?
|
I was reading this question; regarding whether $L=A\cup B$ is nonregular if $A$ is. As is rightly pointed out in that answer, there is no simple rule. But what if we imposed the following conditions:
$A \cap B=\emptyset$
$A\neq B^C$ and $B \neq A^C$
The examples I know of where $L$ fails to be nonregular is where $B$... |
I encountered an interesting problem based on tree-data-structure.
We are given a tree which has N nodes, with 1≤N≤105.
Time starts from second 1 and it continues for q seconds.
At each second, the value of each internal node is transferred to all of its child nodes. This happens with all the nodes, except leaf nodes... |
Is it possible for a Turing machine to halt without reading the complete input string. Suppose there is a string "adc" preceded and succeeded by infinite number of blanks. Can a Turing machine halt after reading just "a" and never touching "dc" or any of the blanks. If yes, will this string be accepted or rejected?
|
Given a set of numbers in different representations (we don't know the value of the base in which we are representing) of bases, find the original number (in decimal representation) if it exists or return no number exists.
Constraints given: $2\leq base \leq 36$, No. of numbers given in different representations is N $... |
Is there a theorem / single formula, that describes the often necessary tradeoff between memoiziation (for example that of a certain variable x) and effective computation as written in any common form such as runtime?
(A good purely theoretical startig point to work with could really be a number sequence...)
|
I'm trying to prove or disprove that $\log^{k}(n) \in O(\sqrt{n}), \ \forall k > 0$. By using the free version of wolfram and testing some increasing values of $k$ I get that:
$$\lim_{n \rightarrow \infty} \frac{\log^{k}(n)}{\sqrt{n}} = 0$$
And apparently $\log^{k}(n) \in O(\sqrt{n})$, but by trying to solve this limi... |
Just to be clear, $a$ and $b$ are known, while $p$ and $q$ are unknown prime numbers, both congruent to $1$ modulo $4$. Can we design an efficient algorithm to retrieve $p$ and $q$?
It is a known result that $p$ and $q$ can be written as a sum of two squares in exactly one way, and $n$ can be written in exactly two way... |
Some time ago, I've come across the Two Generals Problem and that it cannot be resolved. Now, recently, I've had an idea how to approach it. IMHO, it is a very obvious way to handle it but I haven't found this way to handle it anywhere and therefore assume my idea is flawed but I can't find the error.
The approach I've... |
Integers can be represented with a pair of smaller numbers. To achieve this I use 2 integer sequences.
Integer Sequence 1
1,1,2,1,2,3,1,2,3,4...
And Integer Sequence 2
1,2,1,3,2,1,4,3,2,1...
This gives me a unique pair of smaller integers for every given integer N
Like So
1={1,1},2={1,2},3={2,1},4={1,3},5={2,2},6={3,1}... |
Let Σ = {0, 1, ⊕, =} and define a language A as follows: A = {x = y ⊕ z | x, y, z are binary integers, and x is the XOR of y and z}. For example string “1011 = 1111 ⊕ 0100” is in A, whereas string “1011 = 1011 ⊕ 1011” is not
How can I show that A is not regular? How should I have the string?
Also, if the binary numbers... |
Write an algorithm that calculates the monthly payment of a bank loan with
a fixed interest-rate. Given the principal amount, the fixed interest rate, the number of
years to pay the loan, you can calculate the monthly payment as:
ℎ =(××#+)/#ℎ
Your program should print the required monthly payment of this loan
|
If cartesian closed categories are the model for simply typed lambda calculus, then can it be said that a monoid is a categorical model for untyped lambda calculus?
|
So in a maximum flow question, say if we have a node which is not $s$ nor $t$, if it has no incoming arc, can we delete it without affecting the maximum flow? What if it has no output arc? How so?
|
I am reading "Introduction to the Theory of Computation" (2ed) by Michael Sipser. In Example 1.35, it says the NFA accepts $\epsilon$, which I understand, since the state can stay at $q_1$ upon input of $\epsilon$:
But in Example 1.38, it shows to be an empty set for $q_1$, $q_3$, and $q_4$:
I thought it should be $\... |
I want to prove, $a^2+b^2=c^2$,there exists only 1 case such that a,b,c are consecutive non-negative integers(3,4,5).
I have no clue to prove this lemma. Please help me to prove this lemma.
|
I know $k-center$ problem is, given $n$ cities with specified distances, one wants to build $k$ warehouses in different cities and minimize the maximum distance of any city to a warehouse.
In this problem, the number of warehouses is fixed to $k$, and the goal is minimizing the maximum distance between any city to it'... |
I am currently working on an app with a map of the city, with markers for each bus. As a feature, the phone should show which bus the user is on.
To achieve this I am working on building a function that consumes a stream of a set of buses and their positions (Stream<Set<Tuple2<BusId, Location>>>), and a stream of phone... |
I have nonambiguous and not LL(k) grammar which defines some language. How can I prove that I can't build some LL(k) grammar for this language?
Grammar:
S -> a b X c d | a X f
X -> b X c | ε
|
A maximal minimum cut is a minimum capacity cut with the largest number of edges.
|
Suppose I have an $N$ length integer array of pairs of the type $[value, key]$. Now, I need to query for range sum. Query is of the type : $l, N, x$ meaning I have to sum up all the $value$ in the index range $l$ to $N$ having key as $x$. Also, there can be updates that add a new pair to the end of the array increasing... |
I want to find a bound on the above problem, and show that a random graph has a positive probability of being an expanding bipartite with the property, |V1|=|V2|. I am not getting, where should I start.
Apologies for not writing my understanding, I am very much stuck.
|
Consider a highly-connected graph of states & transitions where each transition is marked with a weight (representing probability of occurring) and the graph satisfies the Discrete Time Markov Chain (DTMC) property: for each state the outflow transition weights are reals (or just rationals, if that makes a difference) ... |
How to implement a reversible OR operator with a Fredkin gate ?
|
Given a directed graph $G = (V, E)$, you have been told that a Hamiltonian path $p_0p_1\ldots p_V$ exists with the property that for each edge $p_ip_j$ that is not part of the Hamiltonian path, $i > j$.
Find any Hamiltonian path.
It is not too hard to find an $O(|V||E|)$ solution to this problem: for every vertex with ... |
This below language
$$L = \{ w \in \{a, b\}^n : \lvert w\rvert \text{ mod } 3 = 0 \}$$
where $n \geq0$.
|
Given two arrays of digits, both of size $n$, $2 \le n \le 9$, form two separate numbers $n_1$ and $n_2$, so the difference $n_1 - n_2$ is positive and minimal, if multiple solutions are possible the one with the smallest $n_1$ is chosen.
Restrictions:
Time: 0.1 s (brute force ain't gonna do it)
Memory: 2 MB
|
I was wondering about the time complexity of something like the following loop (where work() is O(1)):
for (i = 0 to N; i = i * 2) do
for(j = 0 to i; j = j + 1) do
work()
end
end
The outer loop takes $\lg(N)$ steps, and the inner loop takes (on the final iteration) $N$ steps. So, a simple bound would b... |
Write an algorithm that, given sequence seq of n numbers where 3 <= n <= 1000 and each number k in seq 1 <= k <= 200, finds maximum sum by repeatedly removing one number from seq, except for first and last number in seq, and adding its value to sum of two adjacent numbers. Algorithm ends when there are only two number... |
Let $f(n) = n^2 , g(n) = n$, and $h(n) = g(n)−f(n)$. It is clear that $h(n) ≤ g(n) ≤ f(n)$ for all $n ≥ 0$. Therefore, $f (n) = \max(f (n), h(n))$. Thus,
$O(n) = O(g(n)) = O(f(n) + h(n)) = O(\max(f(n), h(n))) = O(f(n)) = O(n^2)$.
Can you explain why this statement is wrong?
|
In stochastic Universal Sampling selection method of genetic algorithm, the number of selected samples is usually static. I wanted to know if it is possible to select the number of these samples dynamically. For example, in the first iteration the distance between samples is 1/6 and in the next iteration this value ch... |
I am studying the maximum/minimum flow question, and was given the following problem:
A traveling agency has $n$ destinations on their service map, and it intends to maintain them with minimum amount of vehicles. Say a transit $i$ starts at ${s_{i}}$ and ends at $e_i$, and then for that transit, it needs another $ret_... |
Does anybody knows how to calculate w1 and w2 and b .
I have the formula but I have no idea where those numbers come from .
my question has solution so it is not a home work because the solution of question is included I only want to learn how the numbers come from .
|
Can you find the function that satisfy the relation?
$$f(n) = \Theta(g(n)), f(n) = o(g(n))$$
|
I am trying to get better at solving recurrence relations, so I am making my own simple relations and try to solve them. I have made the following recurrence:
$$T(n) = 3T(\frac{n}{3}) + n$$
How can I solve $T(n) = 3T(\frac{n}{3}) + n$ using unfolding when $T(1) = 1$ ?
|
We already know that detecting the one-way latency between only two nodes is impossible.
However, if I have a number of nodes in the same subnet that all know about each other, can measure round-trip latencies (e.g. via ping), and can communicate with each other - and assuming link latencies do not change over time (fo... |
One question from the Grokking Algorithms book:
Implement a max([]int) function, returning the biggest element in the array.
Here's my solution in Golang (adapted from the Python solution in the book):
func maxNumber(arr []int) (r int) {
// base case
if len(arr) == 2 {
if arr[0] > arr[1] {
r... |
let's consider vectors in space dim=3 and values {0,1,2,...,99} on each dimension I would like to create hash function but with special trait: collisions only for permutations on input
$\forall_{x, y \in N^3} (y = permutation(x) <=> hash(x) == hash(y))$
is it even possible but without sorting? if so please attach examp... |
I am given a $N$-length integer array. For each integer, I am given 4 values:
$$[\mathit{left},\mathit{right},t,\mathit{value}]$$
$$1\leq \mathit{left},\mathit{right},t\leq N$$
For each query, I have to find the sum of values which have $x$ in the range $[\mathit{left},\mathit{right}]$ and that satisfy $t\leq t_1$.
Exa... |
I encountered an interesting problem based on tree-data-structure.
We are given a tree which has N nodes, with 1≤N≤105.
Time starts from second 1 and it continues for q seconds.
At each second, the value of each internal node is transferred to all of its child nodes. This happens with all the nodes, except leaf nodes... |
Problem Statement: You are given an array/sequence of positive numbers $a_1,a_2,a_3,\cdots,a_n$ and you need to execute q queries on the array and in each query you will take a positive number as an input and find out all the multiples of the number in the given array and print it.
Input:
2 4 9 15 21 20
q1 = 2
q2 = 3... |
In From Lambda Calculus to Cartesian Closed Categories, the author explains the interpretation of lambda calculus in cartesian closed category and at one point he explains how a term representing a free variable of type A is mapped to the cartesian closed category as follow:
[Γ x:A :- x:A] = π2 : ([Γ ] × [A]) → [A]... |
We have a set of positive integers $N=\{a_1,...,a_n\}$, we want to select a subset $N'$ of $N$ with maximum total sum of integers such that this sum should not exceed a given integer $B$.
What is the complexity of this problem.
|
Background:
There are 832 unique Pokemon in the Pokemon universe, and
There are 728 fighting moves that the Pokemon can collectively learn.
No Pokemon can learn to do every fighting move, and some Pokemon can only learn one.
The average Pokemon can learn between 10-30 fighting moves , and
Most fighting moves can be ... |
In my programming concept class we learned that for the array type it's faster to index in memory if the length of an element is = $2^n$. This case make us only need to offset instead of actually doing multiplication.
We also learned about the representation of multivariable arrays with row major. It was then said tha... |
i was going thorugh different searching algorithms,Linear,binary and ternary search.Now i want to know the number of comparisons in these.
For linear search :
procedure Linear_search(a1,a2,...,an:integers,k)
1.location = 0;
2.for i = 1 to n #n+1 times
3. if (a_i = k) then location = i # n times
4.return locati... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.