instruction
stringlengths
35
29.1k
Given a sorted array where every element is distinct, we need to evaluate product of every difference, modulo $ 10^9 + 7 $ $$ \prod_{i < j} (arr[j] - arr[i]) \% (10^9 + 7) $$ Best approach I can think of is finding frequency of primes in product by grouping elements with same modular residue, which allows $ O(N * M / \...
This question is from Exercise 1.7 in the book An Introduction to the Analysis of Algorithms by Robert Sedgewick and Kevin Wayne. Assume that the running time of mergesort is $cN\lg{N}+ dN$, where $c$ and $d$ are machine-dependent constants. Show that if we implement the program on a particular machine and observe a r...
In search of an efficient data structure to store some sort of list hash that I can compare to a value to obtain a probability of it already being in the list. Perhaps it makes more sense defined as follows: Given a multiset $$X_n:=\{x_i \ | \ \ 0 \leq i\leq n\}$$ we define a singular value (or finite set of values sig...
We have $3n$ items with profits $p_1, \dots, p_{3n}$ (sum = $P$) and weights $w_1,\dots,w_{3n}$ (sum = $W$). We want to determine whether we can choose exactly $n$ items with profit at least $P/2$ and weight at most $W/2$. Is this problem NP-hard? It is very similar to the usual knapsack problem, but the constraint of ...
I'm trying to understand David Pisinger's balanced algorithm for the subset-sum problem with bounded weights, which can be found on page 5 of his paper Linear Time Algorithms for Knapsack Problems with Bounded Weights (link). Before asking this question I have read the following sources: https://codeforces.com/blog/en...
I am trying to teach myself asymptotic notations. I feel like I'm in over my head. I read the explanations in the text book, and Khan Academy. But when I try to do proofs, I can't grasp anything. I'm trying to prove that If f (n) = ω(g(n)), then f (n) is not in O(g(n)) or o(g(n)). I know that they don't intersect, as ω...
In quantum computing, there is an error correcting code called the color code where each error in the bulk of the code produces three types of symptoms (one red, one green, one blue). Pairs of errors can push a symptom of one color around. The task of decoding is to find a minimal set of errors that merge the given sym...
We have a $N \times N$ cost matrix where the cost denotes the amount incurred for assigning a worker to a task. The number of possible assignments is $N!$. Let us call this set of all possible assignments as $Z$. Assume we have a subset $S$ of assignments from the $N!$ possible assignments. How can I get one best cost ...
I'm studying the convex hull algorithms in the high dimensions. There were two papers by Bernard Chazelle and T.M. Chan from the 90s, to have achieved the at then the state of the art complexity. However, when I tried to find the recent papers, most of ones I found was about the "approximation" of the convex hull, rath...
I am not an expert with functional programming. What I know is that the bag data structure satisfies the definition of a monad. There are two different implementations of Bag: one with linked lists, B1, and one with hash maps, B2. In B2, you are storing integers that are the multiplicities. I want to know: Are B1 a...
In category theory, we are taught that polymorphic functions correspond to dinatural transformations, a k a multivariant natural transformations between functors of mixed variance $\operatorname{G} \in \mathbf{Set^{op}} \times \mathbf{Set} \to \mathbf{Set}$, if there is one type variable. I have been investigating anot...
There are many algorithms used for Very large-scale integration design (VLSI) or EDA (Electronic Design Automation). Most of them are challenges that imply some combinatorial/mathematical optimization. For instance, some well-known problems and their algorithms can be interesting for the field - Graph generation, Floor...
Given recurrence equation : $T(N) = T(N-1) + T(N-2) + N$ Given base case $ T(1) = -3$ So I rewrote the equation as $ T(n)+ n - T(1) = T(n-1)+ (n-1) - T(1) + T(n-2)+(n-2)-T(1)$ Substituting $ V(n) = T(n) + n - T(1)$ we get : $V(n) = V(n-1) + V(n-2) $ which is the Fibonacci relation , hence : $ T(n) = \frac{\phi^{n} - \p...
Notation: We write $|\alpha|$ to denote the length in characters of an expression $\alpha$ in propositional logic. Consider an expression $\alpha_n$ in disjunctive normal form built from $2n$ variables where each conjunct contains $n$ variables chosen from those $2n$ original variables. All $\binom{2n}{n}$ conjuncts ar...
Self-taught programmer here. I'm reading CORS, and right at the beginning, question 1.2-2, there asks a question: For inputs of size $n$, insertion sort runs in $8n^2$ steps, which merge sort runs in $64n\lg n$ steps. Which values of $n$ does insertion sort beat merge sort? I simplified this to $n=8\lg n$, and ran it...
I have a finite region of 3D space that some (arbitrarily-shaped, concave) geometry occupies, and I need to identify whether that geometry forms a closed 3D volume (or multiple disjoint closed 3D volumes). That is, I need to identify if, and where, the geometry isn’t airtight. The geometry is, effectively, a series of ...
I've you've ever had a table of text like in Word or Google Docs, you'd know that there are ideal widths for each table column to minimize the height of the table and fit the most text, here's an example. I've tried thinking about how I could implement that myself, but have no ideas. I wonder if this would be some sort...
SAT Solvers focus on CNF formulas. For many implications it is much mroe natural to use implications and conjunctions to encode problems, and when converting to CNFs, information is lost, and the solver may need to extra work. Is it possible that if we would rewrite SAT solvers to solve formulae using conjunctions and ...
From this research paper I want to write an algorithm for finding envy-freeness(EF) and Pareto optimality(PO) division for more than two agents. We consider the problem of fairly and efficiently allocating indivisible items (goods or bads) under capacity constraints. In this setting, we are given a set of categorized i...
I recently had a software engineering exam, and there's a particular question that's causing some confusion between my professor and me. I'd like to get some insights from the community to better understand this issue. If I can convince my professor I was right, I could get a higher grade. The Question: The question in...
I'm a freshman in computer science and I have a question that has been bugging me after my programming and electronics classes were over. My question is that in an integer datatype (assume short datatype in Java, where the range is from -32768 to +32767.) I understand (based on what has been taught) that this is becaus...
I am trying to encode some circuit checking algorithms, but encountered difficulty creating a 2SAT representation for a NAND circuit. Is there a proof that this is not possible?
I am trying to decide whether the following language is context free: $$L = \{ a^nb^{3n}c^n \, | \, n \geq 0 \} $$ Assume $L$ is context-free. Let $p$ be the pumping length given by the Pumping Lemma. Choose string $s = a^pb^{3p}c^p ∈ L$. Then, $|s| ≥ p$. Take an arbitrary decomposition $s = uvxyz$ where $|vxy| \le p$ ...
Let us assume I use bloom filters of size $m$ bits with $k$ hash functions. Now I have two set $X$ and $Y$. Let $B(X)$ be bloom filter of the set $X$. In general I know that $B(X\cup Y)= B(X) \lor B(Y)$. Let us assume that $|X|=n, |Y|=m, |X\cap Y|=l$. So I can use formula from wiki for math expectation for number of no...
I know there are algorithms for translating regular NFAs into their corresponding DFAs. Can these algorithms be applied to automata that employ transitions involving counters in a straightforward way, or are there special considerations that need to be taken into account, or even different algorithms altogether?
We have $3n$ items with profits $p_1, \dots, p_{3n}$ (sum = $P$) and weights $w_1,\dots,w_{3n}$ (sum = $W$). We want to determine whether we can choose exactly $n$ items with profit at least $P/2 - 1$ and weight at most $W/2$. If the profit must be at least $P/2$, we can set the profits to be equal to the weights and r...
Here: $W$ is "bitness" - number of bits in one machine word, that could be stored in memory slots $N$ - number of memory slots (each has bitness equals $W$) My solution: If max length of machine word is $W$ so there are $2^{W}$ different machine words. Suppose, that each possible machine word works like an address o...
I implemented an incremental Delaunay triangulation algorithm. It basically works except it has this weird issue. The algorithm starts by creating a bounding triangle that it then splits recursively as new points are inserted. Then the 3 extra points are deleted. This yields these kind of meshes before deleting the poi...
I am trying to solve the following problem: Suppose there are traders who can exchange one good for another. Each trader $i$ defines two functions $y = f_{i1}(x)$ and $x = f_{i2}(y)$, with which we can determine how much of $y$ or $x$ we can receive after exchanging with this trader. For example, trader 1 can exchange ...
Suppose we have a website and you log in the website with a username and a password.During registration your computer downloads a file containing a random 32 digit number.Now when you try to log in , the website asks you 5 questions.Which is the digit at position x?(with x being a random number from 0-31).Isnt this a z...
Alice is preparing decorations to decorate the classroom for Children's Day. She is using beads in the colors red (r), green (g), blue (b), and yellow (y) to create strings of beads. During the class meeting, it was established that two beads of the same color cannot be placed next to each other. Help Alice design the ...
Imagine having a number of straight and curved train track segments (e.g. 90° to the left and right, but they could have other values in the general case), how is it possible to find all complete (closed) tracks that can be built with them (not necessarily using all elements)? I suppose with a low number of track segme...
I'm playing around with the implementation of PEGs and it struct me that the parser generator itself isn't any different than the language it's use to construct. If fact, it has all of the hallmarks of a compiled (pure) functional programming language: It's declarative State is passed around to other functions and aft...
This is a continued question from: The updated convex hull algorithms in 2023? From Handbook of Computational Geometry (Third edition, 2018) section 26.3, Seidel mentioned the boundary and the lattice descriptions of the convex hull algorithms, and that the lattice description was less practical, where Avis-Fukuda's bo...
Consider a very simple RAM chip that has 20 address pins and 4 data pins. I would like to know the function of the 4 data pins when only 1 data pin is enough. What do I mean by 1 data pin is enough? If an address is applied to address pins, a memory cell is selected (which can only have value 0 or 1 — in a very basic R...
In some languages, it is expected that a function declaration be terminated by syntax that includes the function name. For example, in MODULA-2, a function is declared as shown below: PROCEDURE P ; BEGIN ... END P ; Is it possible to verify such a requirement using a syntax analyzer? If yes, explain how to do it. If no...
Consider the language L = {< M >| M accepts iff input length is divisible by 3}. I'm supposed to use reduction to show that the language is undecidable. I tried proving it but didn't know what to do.
Please point me to the right place if this isn't the right one to ask in. There are 2 initial integer variables (the values of the two can be changed). $a = 4$ and $b = 1$ There's a function. Each run of the function can distribute a total of $5$ to $a$ and $b$. So any positive integer combination of $5$ is possible. ...
I have two types of objects, X and Y, each are recursive structures, and contain different structures sets of tuples containing sets.. etc. The number of elements in X and Y are is the same. I need to proof that for every x in X, there is a unique y in Y. Can this be achieved by defining a bijective function which uses...
by definition log(n)=O(f(n)) therefor if M uses O(f(n)) cells it might as well uses log(n) cells, how do I continue?
I was reading about star-free languages recently and a common example of a non-star free language is the one given by (aa)*. I was wondering if (ab)* would also work (for an alphabet of two symbols let's say).
Definitions: Let $n \in \mathbb{N}, n \geq 1$. We write $|\alpha|$ to denote the length in characters of an expression $\alpha$ in propositional logic. We define partial evaluation in the normal way where evaluation is applied to an expression containing constants until no more evaluation is possible. So for example if...
I am working on exact algorithms for an NP-hard problem $P$. I was able to get a $(1.75^n$) time algorithm for split graphs. When it comes to bipartite graphs, the problem becomes hard to tackle. Now, I want to prove that there is no sub-exponential algorithm for the problem on bipartite graphs. So to prove this, I hav...
Haskell's monads are usually considered to mean strong monads in category theory, but it seems like the former is a bit stronger than the latter. With strong monads, you have a Kleisli extension operator $-^* : C(a, Tb) → C(Ta, Tb)$ that operates outside the category $C$, whereas with Haskell's monads you can write an...
Can the strengths of Mulitple Dispatch system of Julia language be replicated in a newly designed language like Mojo through cleverly designed mechanism? Or only Julia gets to have such a feature due to its strong type system. Can programming languages theory address this issue?
This question is because I think it would be fun to make an A.I. Any programming language is acceptable. I am wondering how do I make a simple program that can associate certain things with points and learn to prefer things with more points associated with them. It is a very general question. If you need an example, ho...
Say that I have a plasma gun: It's easy to compute the trajectory of the plasma ray starting from the gun. However, another ray may come from afar: As everybody knows, plasma rays are deviated when they collide. In fact, they are always deviated 90°, away from the other ray: Space is discreet (like a chess board). E...
Can any SAT problem be converted into one with only affine formulas? Handbook of Satisfiability p. 672: Affine formulas. A linear equation over the two-element field is an expression of the form $x_1 ⊕ … ⊕ x_k = δ$ where $⊕$ denotes the sum modulo $2$ and $δ$ stands for $0$ or $1$. Such an equation can be expressed as...
From Discrete lizard's answer and Handbook of Computational Geometry (Third edition, 2018) Section 26, Chazelle's solution of high dimensional convex hull achieved worst case optimal. T.M. Chan's algorithm made the practical implementation, and Avis and K. Fukuda's solution was more efficient. However, I recently came ...
I recently came across this question, and the way I think people usually go about this is to find a certificate that answers 'yes' to the decision problem 'Is this LP infeasible?' Or, given a certificate, verify if that yields infeasibility or not. I know of the theorem that says Ax = b is infeasible if there exists y ...
The steps to get a number in 2's complement are simple: Flip the bits (Using NOT) Add +1 (afaik this step is done to eliminate the duplicate 0) Recently I've seen an ALU design that can operate negative numbers in 2's complement without the seconds step. For example, we want to perform the following operation $y-x$ T...
Let $\Sigma$ be an alphabet. Is the set of all strings over $\Sigma$ (i.e. $\Sigma^*$) countably infinite or uncountably infinite?
If a virus is defined as a self-reproducing program, then Rice's theorem implies there can be no infallible virus-detecting algorithm. Can we take that one step further, as follows? If you have the source code for a virus-detecting program, could you use it to produce a virus that the program will fail to detect?
I am currently watching the FreeCodeCamp Algorithms and Data Structures Tutorial. In the explanation for exponential time complexity, they explain that using a brute force attack on a combination lock would create O(x^n) time complexity. I am confused as this attack sounds very similar to a linear search of the passcod...
So in the halting problem, there is a program that reverses the output of a program that tells if the input program halts or runs forever(I'll call it the main program further). The whole paradox is based on the fact that if we feed this "reverser" program to the main program the reverser program will be in two differe...
I am working on giving an MSOL formula for an NP-hard problem; this proves that the problem is linear-time solvable on bounded treewidth graphs. Given a graph $G = (V, E)$, the problem would be to find a subset $S \subseteq V$ such that each vertex of degree at least three has at least two neighbors and at most three n...
I'm trying to isolate the key differences between induction and recursion so that I am able to know when to use one over the other. From my understanding, both can be used to prove properties about recursive structures. For example: Consider a recursive structure $x \in X$. In order to prove that for all $x$, $P(x)$ is...
So, I know there is no general algorithm for the halting problem, but I was curious if a three output decider could at least give us "an" output {0 if doesn't halt, 1 if halts, U if undecidable for this decider}. Here's the halting problem, roughly, in python: # The decider function tries to determine if a function...
I have a genetic algorithm/programming problem where I need the best arrange of items in a binary tree. My question is the best way to mutate/cross this binary tree subject to constraints described below. All items need to be leaves in this binary tree and there are no nodes with only one branch populated. That is, all...
In the book Self-Stabilization (Dolev, 2000) the author provides a proof (p.19) of Dijkstra's self-stabilizing mutual exclusion algorithm. An excerpt of the book showing the proof is found below. At the end of the proof for Theorem 2.1, the author states In accordance with lemma 2.4, P1 must assign j to x1 in every n...
Consider the problem of scheduling jobs with different lengths on a single machine while the jobs have the same release times and different due dates. The goal is to schedule the maximum number of scheduled jobs such that none of the scheduled jobs is late. Can this problem solved in polynomial time if jobs are non-pre...
Let us assume, we have a FSM (to be precise, an epsilon-NFA) in which I've got redundant structures. I am looking for a framework that allows to factor out the redundant part into some kind of subautomaton, respectively a more canonical representation and naming of this kind of NFA. As illustration I've got the followi...
Consider normalized DFT (discrete Fourier transform) — a transform with input $x = (x_0,\dots,x_{n-1})$ and output $y=(y_0,\dots,y_{n-1})$ s.t. $$y_j = \frac1{\sqrt{n}} \sum_{l=0}^{n-1} x_l \omega^{jl}, \tag{1}$$ where $\omega$ is a primitive $n$-th root of unity (e.g. $\omega = e^{-2\pi i/n}$). It is described by a un...
I was exploring a problem of label flipping in the target column: Problem: I have a data frame with just two columns: Predicted probability | Target. Target column is binary (contains only 0 and 1) --- the actual target values. Predicted probability column contains outputs from my model. I calculate the ROC-AUC metric ...
Are there (interesting) situations where we can decrease the time complexity of a program by increasing its ordinal complexity? For example, is it possible to find a primitive recursive function such that: The fastest primitive recursive program to compute it runs in $O(f(N))$. The fastest non primitive recursive (for...
int q(int n) { if (n <= 0) return 0; return 1-q(q(n-1)); } I'm not sure how to approach this. I tried representing the time complexity as a function $T(n)$ and then use repeated substitutions: So I got $T(n)=C+T(T(n-1))$ where $C$ is a constant representing a constant amount of lines we have in the fun...
I wanted to ask a simple question: Assume I have a function whose time complexity is given by the following function: $T(n)=\frac{1}{1^2}+\frac{1}{2^2}+\frac{1}{3^2}+...+\frac{1}{n^2}$. Would it be correct to say that the time complexity of the function is $Θ(1)$ because $T(n)$ is represented by a convergent series?
The literature that I have reviewed shows examples of calculations of known approximation algorithms such as the Christofides' algorithm for the TSP. However, I have not been able to find information regarding the calculation of the approximation factor of an algorithm that has a loop inside as the one in the example b...
A common issue with CPU performance is that pipelining requires the knowledge of what will come next, and what comes next can only be known once a branch condition is evaluated, so that instructions in the branch can be preloaded. As such, CPUs employ branch predictors to predict which branch will be taken so that the ...
I'm working my way through the graph section of Introduction to Algorithms by CLRS (3E,4E) and I came across the following proof: 3E: Lemma 22.2 Let $G = (V, E)$ be a directed or undirected graph, and suppose that BFS is run on $G$ from a given source vertex $s \in V$. Then upon termination, for each vertex $v \in V$, ...
Let $G = (V, E)$ be a graph with edge weights $w: E \rightarrow \mathbb{R} \cup \{\infty\}$. Let $P := \{(a_i, b_i, w_i)\}$ be a set of tuples of nodes $a_i, b_i \in V$ with shortest distance $w_i$ from $a_i$ to $b_i$. We want to update the weights of a subset of edges $E' \subseteq E$, and then efficiently update the ...
Is it possible for a language (or machine or system) to be universal or turing complete, when there is no possibility to write a program for it that halts? Lets say we create a new language, brainfuck-nonstop, that like brainfuck with a single change: When the program pointer reaches the end, it goes back to the start ...
Consider two large numbers $a$ and $b$ of which some, not necessarily prime factors, are known. This means $a = a_1 \cdot \dots \cdot a_n$ and $b = b_1 \cdot \cdots \cdot b_m$. Required is their quotient $$ \frac a b = \frac {a_1 \cdots a_n} {b_1 \cdots b_m} $$ of which is also known that it is a (positive) integer. Mo...
The Trench algorithm (1996) has complexity N*N to invert an N by N positive-definite Hermitian Toeplitz matrix. More recently (2005), Martinsson et al "A Fast Algorithm for the Inversion of General Toeplitz Matrices" describe an algorithm with complexity NlogN for general Toeplitz matrices but the intrinsic complexity ...
I am new to C++, and upon running this code I am getting the following error, can someone please explain what's wrong with the code? Thank you. main.cpp:8:17: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings] 8 | C(char *s = " ",int i =0, double d=1){
A computer science lecturer said that one should use test as programs can't be proved to be bugless. Is this true? What does it mean to prove that program is bugless? Is there a proof that it is impossible to find such a proof? And is there a method to transform a program to a mathematical statement whose proof can or ...
I know that Integer Linear Programming problems are NP-hard. But it seems like this answer is only applicable to Integer Linear optimization problems. It seems like integer linear feasibility problems should be able to be solved in polynomial time. I was thinking that this would look something like this: Solve the lin...
Quantum mechanical principles have already been used to attack computer science problems in the form of quantum computing. In a similar vein, is there any usage of general relativity principles to generate algorithms in favor of computer-scientific problems? One (fairly trivial) example would be solving the shortest pa...
Weighted interval scheduling with m-machines ('Weighted interval scheduling with m-machines') I encountered the problem of weighted interval scheduling on m identical machines (as discussed in the link above). My greedy solution is exactly the same as the answer provided by D.W. in that link. 1. sort the interval by pr...
Let $\Sigma$ be a finite nonempty alphabet. Is the set of all DFAs over $\Sigma$ countable? I know the set of all regular languages is countable, however, it is impossible to build an injection from the DFAs to the regular languages since a regular language isn't necessarily accepted by only a single DFA.
The time complexity of the matrix product is $O(n^3)$ if calculated normally for each element. If computed on GPU, is it $O(n)$? What I thought: GPU can compute each element of the matrix product in parallel. Each element is computed by a inner product of vectors $\sum_{k=1}^n a_kb_k$ Each $a_kb_k$ can be calculated i...
I am searching for a CS equivalent to American Math Monthly. It should contain articles on topics and some problems at the end for submission. I need some recommendations . Thanks in advance.
Consider the following "game". There is an ant on a strip of length N. The ant can perform the following actions: move left, move right, and paint the cell he is on with white or black. The ant is also given a target coloring and must paint the strip according to such coloring in the most efficient way possible. The a...
Weisstein, Eric W. "One-Way Function." From MathWorld--A Wolfram Web Resource.: The existence of one-way functions is not proven. Why not?
I'm interested in getting a precise estimate of the computational complexity of an algorithm I wrote involving permutations. Permutations are represented in my code as arrays of the integers $1$ through $n$ for some $n$, which can vary, and at least in the output (but perhaps not in the intermediate stages) the $n$th e...
I am developing a computer vision system, using the pinhole camera model. Is this an appropriate model to use for a real camera? I know that lenses and such will distort the image, my main questions are: for a cheap webcam (which I plan to use), what are the distorting effects of lenses and having a finite sized camera...
Suppose we are given $n$ bits $a_0,\dots, a_{n-1}$. Then let $s=\sum\limits_{i=0}^{n-1}$ Then $BCOUNT(a_0,\dots,a_{n-1})=s$ and $UCOUNT(a_0,\dots,a_{n-1})=1^s0^{n-s}$ Now i have to show that $UCOUNT\leq_{cd} BCOUNT$ i.e. $UCOUNT$ is constant depth circuit reducible to $BCOUNT$. I have to create a constant depth circuit...
This is a follow-up for Weighted interval scheduling with m-machines ---greedy solution with approximation factor. As suggested by @D.W., I will present the problem more comprehensively. $\textbf{Problem Definition}$: Given $n$ intervals and $K$ identical machines, each with a duration $t_{(\cdot)}$, fixed start time,...
Suppose some hash family H satisfies $$Pr_{h_{\in_{R}} H}[h(x_1) = h(x_2)] = \frac{1}{|Y|}$$ Does it mean H is 2 universal? The converse is true, but I'm not sure about this.
Suppose we have an alphabet of size $S$, a pattern of length $P$ and a text of length $T$. We want to design an algorithm for matching all caesar rotations of the pattern $P$ in the text $T$. The problem can be solved using the following two methods: By $\text{KMP/Z}$ against all $S$ rotations of $P$ in time $O(P+ST)...
Gaussian integer is a complex number whose real and imaginary parts are both integers. Say I want raise $(a + b*i)$ to power $(c + d*i)$ and have result modulo $m$. I can do it with floating-point approximation using normal complex power, as defined with exp and ln. But this is not precise, I can lost important last di...
The AND boolean function $AND(x)$ can be represented using the polynomial $P(x) = x_1x_2\cdots x_n$. I have a few questions: Is there a similar polynomial for the PARITY boolean function? Is there a boolean function whose polynomial doesn't have a maximum possible degree?
Given an ordered list of two-dimensional points $P$ that represent the vertices of an $N$-sided (very) self-intersecting polygon, find a point $p_{best}$ with the highest winding number of all points within that polygon represented by $P$. Sunday's algorithm sounds great for efficient calculation given one point, but s...
You are given the number $m$ and $m$ intervals of the form $a_i, b_i, v_i$, where $a_i<=b_i$ and $v_i>0$ and also a number $n$ and an array $s$ of length $n$, where $s_i>0$. In one operation you can choose an interval say $j$ and decrease the values of $s_i$ by 1, where $a_j<=i<=b_j$, and you can choose interval $j$ at...
My understanding of the Curry–Howard correspondence is that it shows an isomorphism between constructive logic (also called intuitionistic logic) and computer programs in appropriate typed languages. Basically, a (logical) proposition corresponds to a type, a proof (of that proposition) is an inhabited type, a function...
I'm trying to check if the binary tree is binary search tree. My idea is to use Morris traversal. Intuitively a binary tree is balanced iff Morris traversal produces a sorted threaded linked list. The problem is I could not prove this proposition strictly. Is it even correct so it's safe to use it for binary search tre...
For reference, the $Y$-combinator is the expression $$ Y = \lambda f . (\lambda x . f (xx)) (\lambda x . f (xx)) $$ in the untyped lambda calculus. If $g$ is any lambda expression, then \begin{align} Y g &= \lambda f . (\lambda x . f (xx)) (\lambda x . f (xx)) g \\ &\to_\beta (\lambda x . g (xx)) (\...
I am trying to design an algorithm. For now, I am trying to give myself a large overview. Assume I have K (for example, K can equal 8) perfect slave machines, and one master machine. Each slave has a perfect HDD. I want to save the string "ABCDEFGHIJKLMNOP". My wished are I want to only save a fragment of the string ...
Hello I am trying to implement Non Max suppression algorithm for removing overlapping bounding boxes. I have a list of bounding detected by an object detector in the format B(x,y,w,h,s) x,y are coordinates, w,h are size, and s is confidence score. Aim of NMS is to remove overlapping boxes and retaining only ones with h...
Given an $n$ input array, is there an algorithm that is faster than Fast Fourier Transform if we are only interested in obtaining the maximum amplitude frequency? Looking at the Cooley–Tukey algorithm it seems there would be a way to "prune" frequencies that are guaranteed to not be of maximum amplitude. The applicatio...