instruction
stringlengths
35
29.1k
There are $2$ "basic"/"fundamental" data structures due to the way memory works: array linked list Then there are ADT that we implement using those two, for example: stack, queue and more. When we arrive to priority queue we first need to implement and ADT called heap which can be implement using: array tree (which ...
I have to solve an assignment problem between $\{1,\dots, N\}$ agents and $\{1,\dots, M\}$ objects, which comes to maximize : \begin{equation} \sum_{ij}\beta_{ij}x_{ij} \end{equation} where $x_{ij}$ equals one if object $j$ is assigned to $i$, $0$ otherwise. The benefit of such an assignment is the non-negative value $...
I call a string of brackets 'correct' if every opening bracket has a corresponding closing bracket somewhere after it and every closing bracket has a corresponding opening bracket somewhere before it. For example (())()((()())) is a correct string and )()()( is an incorrect string. An operation consists of taking a...
I have the following question in a homework: Let $G = (V,E)$ be an undirected graph, and let $$A = \{ e \in E \mid \text{ s.t. exists an MSP $T$ containing } e\}.$$ We were asked to find $A$ in $O(m \log n)$ time. Any suggestions?
Suppose there are four points (n = 4) which are four dimensional (m = 4) . Lets say these points are : A(4,1,1,1) , B(3,2,1,1) , C(2,3,3,3) , D(1,4,4,4). What is the best data structure to compare all points among one another based on their values in corresponding dimensions ? Aim is to have minimum time complexity . (...
I have a large sparse unweighted undirected graph (20M vertices, 60M edges) and would like to find what I'm calling the "mean center" (the vertex w/ shortest mean distance to all other vertices. Does this already have a name?). I know of an $O(N^2)$ solution: Starting at every vertex: BFS to calculate the mean distance...
I would like to know if $O(n \log n)$ is an exponential speedup over $O(n^2)$?
I am a programmer. I have just deleted a huge amount of code which I painstakingly researched, thought about, coded, then improved and fixed as bugs popped up for a long time. All of that code, which took me a ridiculous amount of time, effort and general "mind work", has now been replaced by a very small number of lin...
There is an exceptionally simple way to embed simply typed lambda calculus with de Bruijn indices in a functional host language (discussed by Carette, Kiselyov & Shan, and by Kiselyov). The construction here, expressed in Haskell, is from Kiselyov's paper: z :: (a, b) -> a z (x, _) = x s :: (a -> b) -> (c, a) -> b s v...
Recently I have studied Kirchhoff's spanning tree algorithm to count the number of spanning trees of a graph, which has the following steps: Build an adjacency matrix Replace the diagonal entries with the degrees of the corresponding nodes Replace all the other ones excluding the one's included in the diagonal by $-1...
I want an algorithm to decide whether a theorem holds in propositional Intuitionistic logic ($IL$). We know $IL$ is $PSPACE$-complete, so we should be able to reduce $IL$ to $QBF$. In Literature i only found reductions the other way around, so im assuming this is not the way to go for writing an algorithm deciding $I...
Given a set $S \subseteq \{0,1\}^*$, the algorithm $A$ is a generator for $S$ if given $n$ random bits $x \in \{0,1\}^n$, $A$ generates an element of $S$ of size $n$, and $A$ can generate at least $\frac{2}{3}$ members of $S$ of size $n$ (for all $n$). $A$ does not have to be uniform. Is there a set $S$ such that t...
I am trying to understand worst case time complexity of quick-sort for various pivots. Here is what I came across: When array is already sorted in either ascending order or descending order and we select either leftmost or rightmost element as pivot, then it results in worst case $O(n^2)$ time complexity. When array i...
I am trying to understand what is the PTAS, FPTAS and what is the difference between them. I found this analysis: PTAS definition vs. FPTAS but I cannot understand what do we mean by saying: "....time complexity is polynomial in the input size and also polynomial in 1/ϵ" ?? Ok n has to do with the linear O(n) worst ca...
We do check for the mantisas overflow in floating point addition e.g. If we are adding $8.02 \times 10^3 + 9.01 \times 10^3 =17.03 \times 10^3$ i.e we get an overflow, so we shift the number right and increase the value of exponent. But does it occurs during floating point multiplication? According to my logic, it shou...
I am implementing an AI based on the MiniMax algorithm that plays the game Dots and Boxes. I would like to reduce the branching factor of the search tree, by introducing a heuristic rule that limits the number of successor states. However, I am not sure whether there exist any situations, where this rule would exclude ...
I am reading https://global.oup.com/academic/product/a-world-beyond-physics-9780190871338?cc=us&lang=en& about one approach of complex systems' theory for the emergence of the life. It is about the autocatalytic soup of molecules from which the life can emerge. Of course, one is thinking further - every computer progra...
I am trying to figure out if this truth table is possible. I've tried inverting the numbers, adding them, subtracting them, but I still cant find anything that works. I am starting to think that this is not possible.
Is $(n^5 + n^7)\in \Omega(n^7)$? Shouldn't it be in $\Omega(n^5)$? I understand Omega to be a "lower bound" on a function. Shouldn't the largest lower bound on the function $n^5 + n^7$ be $n^5$? (Just as the smallest upper bound is $n^7$) The reason I say that the function is in the Omega class of functions larger than...
I am given two files one with the name of person and the location that they are from (Evan Lloyd|Brownsville) and one with the name and salary (Evan Lloyd|58697) (the line number that you find the employee on in the first file is not necessarily the line number that find the employee on in the second). The user inputs ...
For the regular expression $(a^*ba^*b)^*a^*$, I want to learn how to describe it in words. I know there are an even number of $b$s but how much do I need to explain it? Do I need to explain it enough that each possible string can be produced from my explanation? Another example is $(a^*[ba^*c])^*$ where I would describ...
given a network with n stations. assuming the shortest between s,t was found using dijkstra's algorithm. let that path be denoted as $(a_1,a_2,...,a_k)$ assume that between the nodes s and t, there's an at least additional path with the same weight, but with different edges(meaning both paths have different edges, noth...
I have this question: Given a strongly connected and directed graph $G = (V,E)$ with positive weights define $E(t)$ to be the group of edges whose weight is at most $t$. Find an algorithm that calculates the minimal $t$ such that $G(t) = (V,E(t))$ is strongly connected. I thought about running Dijkstra $v$ times from e...
Given a directed graph $G$, vertices $s$, $t$ and group of vertices $U$, suggest a algorithm returning true if exists shortest path $P$ from $s$ to $t$, such that $P$ contains all $U$ vertices. The graph is unweighted, we have to find shortest path in distance. I was thinking about using reduction and BFS, But honestly...
I got a question from my homework in each I have the solution, but not the algorithm. I want to check if I understood it correctly. The question is: Let's say we have a directed graph with no cycles, it has N vertices and M edges. Exactly 2018 vertices are colored green, and the others are black. We know that in eac...
I had to write an algorithm that, given the input ['h', 'a', 'r', 'd', ' ', 'i', 's', ' ', 'c', 's'] would return ['c', 's', ' ', 'i', 's', ' ', 'h', 'a', 'r', 'd']. I found an algorithm that I think I am happy with, but unfortunately, I do not know how to compute its running-time. The algorithm essentially has two sta...
I just saw a YouTube video where Ryan Williams gives a talk about circuit complexity. He stated that random Boolean functions require exponential size circuits to compute, but I don't understand why this would be so. Can someone explain this aspect of circuit complexity for me? Thank you.
I have memory of $k$ elements that you can imagine being represented by an array. One by one, the array receives a value corresponding to the time index, for example at $t=1$ the value will be $1$. At some point ($t=k+1$) the array will be full and we must choose a value inside the array to replace with the new one. Th...
I am working on a webapp (fullstack JS) where the user create documents and attach tags to them. They also select a list of tags they are interested in and attach them to their profile. I am not a math guy, but I did some NLP as hobbyist and learnt about latent semantic indexation: as I understand it, you create a tabl...
In the following program where I repeatedly half an integer, it takes until i = 1074 for my integer to be equal to zero (I know that ideally the while loop shouldn't have ended, and the reason why it stopped was because of the memory limit of the computer). a = 1.0 i = 0 while a != 0: a = a / 2 i = i + 1 pr...
I need an algorithm which can do the following: Given some finite number of particles (circles) each with the same radius, and a list of prescribed points for each particle, find paths in $\mathbb{R}^2$ for the particles to take so they won't collide. The list of points for a particle specifies the order in which the...
I know that to check if a given schedule is serializable we can test for either view serializability or conflict serializability. But do serializable schedules exist which are not view serializable?
so I was reading about stack-organized computer. Does a stack-organized computer implies that every program is equivalent to (and not more powerful than) a Push Down Automata?
I was just wondering if there is an efficient algorithm that given a undirected graph G, finds all the sub-graphs whose size is k (or less)? I searched around, and only found problems about finding the connected components. But I am interested in the smaller and more local connected sub-graphs. To clarify, the graph o...
I solved a recurrence to get the formula $T(n) = \sum_{i=1}^{k}2i+1$ for $k = \frac{n-1}{2}$, namely $$ T(n) = 1 + 3 + \dots + (n-4) + (n-2) + n, $$ but I'm not sure how to finish off the problem by writing the summation and solving for the complexity.
In this paper on PDF page 3, they give $\{c (ab)^k, (ba)^k, (ab)^k c\}$ as an example of an input to the GREEDY algorithm for shortest superstring that causes it to have an approximation ratio of 2. As far as I can tell, the shortest superstring of that set is either $c (ab)^k c (ba)^k$ or $b (ab)^k c (ab)^k$ -- either...
I have a case of costly calculations method like this: Input -> Output 0 -> 8 8 -> 9 9 -> 9.5 9.5 -> 9.6 9.6 -> 9.65 9.65 -> 9.654 I use the output for the next input so this way im trying to find where the output exactly matches the input or is a tiny fraction smaller. The goal of the algorithm is to find the smalles...
In a coding challenge an answer claimed to be able to compute the expected edit distance between two binary strings of length $n$ in $O(2^{3n/2})$ edit distance calculations by dynamic programming. A naive solution would requite $O(2^{2n})$ edit distance calculations. The answer gives optimized code but no mathematical...
I have a univariate polynomial $F(t)\in \mathbb{Z}[t]$ of degree $d$ and maximum bitsize of coefficients equal to $\tau$ and $G(t) \in \mathbb{Z}[t]$ of degree $d^2$ and maximum bitsize of coefficients equal to $d^2+d\tau$. Consider also $P(t), Q(t)\in \mathbb{Z}[t]$ of degree $d^2$ and maximum bitsize of coefficients ...
I'm sorry if the question is quite naive, but I don't understand if a call stack is a language implementation detail or it depends on OS? What I'm trying to understand is what decides how to store local variables and parameters of a function - the language's compiler or OS while running the application? Is it possible ...
In a binary search tree the following must hold: Greater keys are in the right-subtree Smaller or EQUAL keys belong to the left-subtree All the algorithms I found to delete a node start by finding the smallest node in the right subtree of the node we want to delete, the successor (or the greatest node in the left sub...
A Boolean (combinatoiral) circuit is a labeled (with the labels: AND, OR, NOT, IN, OUT), directed, acyclic graph, that satisfies: fan-in=2 for the AND and OR nodes fan-n=1 for the NOT nodes fan-in=0 for the IN nodes fan-out=0 to exactly one node (the OUT node) Unbounded fan-out to the rest of the nodes (but th...
I was messing around with a reactive-based frameworks and found it very expressive. Unfortunately, most of them are using techniques that are not very efficient on CPU cashing mechanism such as calling indirect code, and traversing sometimes big collections of subscribers, some of which are readonly, but some can mutat...
It is known that WS1S can be decided by a DFA. Is this the strongest arithmetic theory decidable by a DFA? What happens when the automata class is extended to include DPDAs or PDAs?
We have directed graph $G$ (not necessarily a DAG), two disjoint sets $A$, $B$, of vertices. I need to plan an algorithm returning the minimum number of edges that need to be removed, such that there will be no path from any node in $A$, to any node in $B$ and vice versa. I had the idea using max flow min-cut to find t...
Supposing if a problem with $n$ non-deterministic bits is in $O(2^{\alpha n})$ time at every $\alpha\in(0,1)$ then is there evidence that problem can or cannot be $\mathsf{NP}$-complete?
This question is a nice variant of How to compare n number of m-dimensional points among one another with minimum time complexity? for two dimensions. We say point $p_i=(x^i_1, x^i_2)$ dominates point $p_j=(x^j_1, x^j_2)$ if $x^i_1 \geq x^j_1$ and $x^i_2 \geq x^j_2$. Prove that if in a set of $n$ points there are no pa...
an interval heap is a binary tree stored on an array where the size of each node is 2. i would like to be able to find the index of a parent and find one of the child indices given the index of a node. an example of an interval trees indices would be: [0,1] [2,3] [4,5] [6,7][8,9][10,11][12,13] or ...
I would like to group a list of strings into groups of strings differing by max 1 character: For instance, given: [John, Alibaba, Johny, Alidaba, Mary] I would expect three groups: [John, Johny], [Alibaba, Alidaba], [Mary] My first thought was about using some clustering algorithm with Levenshtein distance but that s...
I am trying to translate and prove a theorem, originally written in first order logic (FOL), into a combination of equational logic (EL) and Boolean logic (BL) (more precisely a model of Boolean Algebra). The target language also permits Skolemization (Sk). So the translation task is from FOL to EL+BL+Sk. My motivatio...
Consider the following algorithmic problem: Given a list of strings $L = [s_1, s_2, \dots, s_n]$, we want to know all pairs $(x,y)$ where $x$ is a substring of $y$. We can assume all strings are of length at maximum $m$, where $m << n$ and are all over a finite alphabet $\Sigma$ with $|\Sigma| << n$. We may also assum...
If there is a poset $(P, \le)$ and two sets $X \subseteq P$ and $Y \subseteq P$, and we have a way $f : P^2 \to 2$ to efficiently compute for any $(x, y) \in P^2$ whether there exists a $z \in P$ such that $(x \le z) \wedge (y \le z)$, we want to return $\mathbf{T}$ if there exists a pair $(x, y) \in X \times Y$ such t...
I'm a bit confused on how Variational Autoencoders are trained. In particular I'm confused on how the latent variable is generated for each input. My questions are as follows: When running stochastic gradient descent does the sampled latent variable stick with the data point during the entire run or does a new latent...
I'm trying to show that a solution I have obtained via an algorithm is correct. The way I plan on doing this is first by showing that an optimal solution does indeed exist. Then, I plan on showing that every other solution that is not the solution provided by my algorithm cannot be optimal. Finally, I show that the sol...
I have a couple of small instances for XORSAT for which I am to design and implement an exact method. However, there are a few catches. It is guaranteed that there always exists and answer but I need to find the one solution with the minimal (non-zero) number of TRUE variables. As I understand, XORSAT can apparently be...
Basically we have a ticket system, each day we get multiple tickets with different categorization (Question,Change,Error) and importance (High,Mid,Low) for different customers (A,B,C). My job is to create some kind of a system determining the due date of these "tasks" based on The state of the previous ones, completed...
I found recently about Algebraic Dynamic Programming. As I understand, it's a formalization that immensely simplifies developing solutions for DP problems. I spent a few days trying to grok it, to no avail. Perhaps in part it's because papers on ADP seem to require strong background in Formal Language theory, which I d...
so I've just attempted an online technical test. It was on hacker rank however I'm sure leetcode usually has the same (and more) so thought i'd ask. I could not think of a nice solution and cannot find a leetcode exercise that matches what was being asked so I'm here for someone to point me in the right direction. The ...
So I have two arrays $d$ and $s$ with size $n \in \mathbb{N}$. Array $d$ contains the elements and array $s$ contains indices. Array $s$ contains all numbers from $0$ upto $n$ with no duplicates. The indices in $s$ indicate where the elements in $d$ need to go. So the element at $d[q]$ needs to be at $d[s[q]]$ where $n...
A language A, even(A) is the subset of A consisting of those strings in A of even length: even(A) = { x∈A | |x| is even} I need to use closure properties show that if A is regular, then even(A) is also regular. Isn't that a definition called "A language is called a regular language if some finite automaton recognizes ...
I hope it isn't off topic but I need to understand this example. Given the corpus 12 1 13 12 15 234 2526 and smoothing factor of k=1. The example does the following operations: Considers OOV(out of vocabulary) words and assigns them a zero times value, after that k=1 is added to the times every words appears, to avoid ...
$\overline{A} \le A\ and $ $A \le \overline{A}$ Is the following proof correct? If $\overline{A} \le A \Rightarrow \overline{A} \in NP$ since A is NP-hard $ \Rightarrow A \in coNP$ Since $\overline{A} \le A$ and $A \in coNP \Rightarrow \overline{A} \in coNP \Rightarrow A \in NP$ $A \in coNP$ and $A \in NP$ iff $NP=co...
Are non halting programs not computable? How are these two sets of programs related: is a non halting program just a specific example of a type of program that is not computable or is it technically computable just not in finite time (the computation can be defined it just goes on forever). Im just not sure about the g...
I had read about the various functionalities of system calls recently in one of my coursebooks and about how they are used to allocate memory for new processes. The book didn't specify whether it was possible to combine multiple memory allocation requests within a single system call. So I asked one of my teachers and ...
Often programming language lectures and references have an illustration of computer memory as an array composed of individual cells. Each cell has an address, which is effectively the pointer and can be used to access it. I learned that 32 bit systems will have 4 byte pointers and then got curious what the (standard) c...
Consider a string of characters $a, b, c$ only. Such a string is called good if the number of $a$'s + number of $b$'s is equal to the number of $c$'s. Given an integer $n$, find the number of strings of length $n$ consisting only of characters $ a,b,c$ such that all of its substrings of length $k$ are good. Example: $ ...
I want to determine the minimum and maximum number of leaves of a complete tree(not necessarily a binary tree) of height $h$. I already know how to find minimum($h+1$) and maximum($2^{h+1}-1$) number of nodes from the height, but what about leaves? Is there a way to determine them knowing nothing but height of the tree...
I'm not sure how go about this question: Prove the following inequality. For a correct proof, we require a value of the constant $c>0$ and an $n \in \mathbb N$, such that $\forall n>N : f(x)<c\cdot g(n)$. $\mathcal O(2^n) < \mathcal O (n!)$. I'm well aware how to prove $2^n < n!$ using induction, I just don't unders...
CFL is not closed under intersection. That means, if we have L1,L2 of CFL then L1 intersection L2 is not a CFL And we know, all Regular languages are CFL. Then how it is true that intersection of Regular language (R1) (which is again a CFL) and a CFL(CL1) is a CFL? R1 intersection CL1 should not be CFL right? becase ...
Suppose i have a circular array of $n$ elements. At time $t=0$ i am in position 0 of the array. The algorithm moves left or right with probability $p=1/2$ (since the array is circular when it moves left from 0 it goes to position $n$). When i visited all the positions at least once the algorithm returns the position it...
I am reading a book on algorithms. It says that $2n^2+3n+1=2n+\Theta(n)$. For a person like me who has studied some set theory but not from axioms, this notation seems a bit insane. I was wondering why are we allowed to compute a sum of a polynomial and a set. Why not just teach that for every $n\in\mathbb N$ there is ...
I'm having problems finding an algorithm to the following problem: A and B take turns replacing a number $n$ of tokens with either $floor((n+1)/2)$ or $n-1$. The player who makes one token remain wins. We want to know, if there is a way for B to win the game no matter the moves of A. A begins the game. My idea is the f...
I usually check the NP-compendium from Pierluigi Crescenzi, and Viggo Kann when I want to know the APX status and approximability results of a problem. However, I understand that maintaining it is a lot of work, which explains why it is not up to date in some cases. By not up to date, I do not mean non-exhaustive, but...
It should be straight forward to show that there are infinitely many NP-hard problems: Proof: Take the problem Remove 1 Vertex 3-COL ($R1V3COL$) which takes a graph $G=(V,E)$ as an instance and yields a yes answer iff a vertex $x \in V$ exists which, when removed from $V$ yields a new graph $G'=(V\backslash\{x\}, \{(u,...
Can anyone show examples for discrete-time markov chains with associated transition rewards? I am searching for examples of industrial usage of markov chains where their expect and variance or covariance of accumulated rewards until reaching some goal state subset are of practical interest. I am searching for examples ...
I was reading concurrency control section from Operating Systems book by William Stallings. In this book, he gives three attempts by Dekker to give solution to critical section problem: Attempt 1 +------------------------+------------------------+ | //process 0 | //process 1 | | while (flag[1]); ...
Most implementations of CSS-like selectors (that is, patterns that may match paths in a tree) seem to use a bottom-up approach. That is, for each node in the tree, they check for a match against the rightmost element of the selector pattern. If the node matches, they search up its ancestors checking for a match against...
The halting problem states that there is no Turing machine that can determine whether an arbitrary Turing machine halts on $\epsilon$. But I try to ask something different, can we find a specific Turing machine $M$ such that $L_M=\{ 0^n : M$ halts on $\epsilon \}$ is undecidable? Or at least can we prove there exists s...
I'm trying to think of a way to do approximate joins between 2 rows in a data table. Like for example lets say I have a row where the person name is "John Doe" but then another data table uses a different person format like "Doe, John." Now suppose I can put them both to a standard format say "John Doe." Sweet so I hav...
In one sense I understand why the bound on BFS and DFS is $O(|V| + |E|)$. Every vertex gets considered, hence the $O(|V|)$, and over the course of considering all adjacent vertices, we end up considering $2|E| = O(|E|)$ vertices total because $\sum_{v \in V} d_v = 2|E|$. What I don't understand is why we even bother sp...
Consider a directed graph on n vertices, where each vertex has exactly one outgoing edge. This graph consists of a collection of cycles as well as additional vertices that have paths to the cycles, which we call the branches. Describe a linear time algorithm that identifies all of the cycles and computes the l...
f(n) = 32n^2 + 17n + 1. The lecture slide says that lower bound can be Omega(n^2) or Omega(n). Some body please guide me why the lower bound can be Omega (n). i know the upper bound which is O(n^2). Zulfi.
In all books about this topic, I read that there is a rule of thumb is that 80% of the process execution time is lower than time slice. But how do I calculate this value? I looked at every article possible and I found like nothing. Can someone help me understand this topic? I know that there is a topic with this questi...
I tried to complete this exercise but i stopped... Defining a $ \lambda $-term M such that: $$(<M,u>)<M,v> \: \simeq_{\beta} \: <M,u>$$ I chose $M=\lambda m \lambda a \lambda b \lambda p \,((p)m)b \:$ then i have to find a representation T of a function using M that value true if the sequence is empty and false if it's...
I'm new to machine learning and struggle to interpret the results I get from different measures of performance. If for several prediction models I have e.g. accuracy, precision, recall, F1, FPR, and MCC and want to find out which model performs best, what do I look for? I would assume accuracy is most important? Also,...
In studying various solutions for finding a path in a 2d maze using BFS, I've come across two different approaches. One is to store the whole path to a given position in the search queue. The other is to keep track of predecessors and build the path at the end by back-tracking. I'm curious to hear which of these approa...
I am trying to design an algorithm to compute the solution to this problem. Given a list of n tournaments with a name, start_date, end_date, latitude and longitude, find the list of p tournaments in chronological order with the least total travel distance when a person has to travel from one tournament to the next to t...
Per the Sequential Access Theorem we can access every node of a splay tree in $O(n)$ time, when accessing the nodes in a specific order. Given a link/cut tree, is it possible to access all of its nodes faster than the naive $O(n \log n)$ amortized time in the worst-case?
Let the input alphabet be $Σ = \{1,x,=\}$ Let the stack alphabet be $\tau = \{1,\$\}$ where $\$$ is the initial stack symbol. Let,$q_0$ be the initial state of the PDA,$q_f$ be the final state of PDA, I can define a transition function for PDA like this. $(q_0,1,\$)\rightarrow(\$1,q_1)$ $(q_1,1,1)\rightarrow(1,q_1)$ $(...
I was preparing for my exam and have some questions that can possibly come on the test. There is a task to make pushdown automata from a given code: void compile_while() { // while ( expression ) if (symbol == SYM_WHILE) { get_symbol(); if (symbol == SYM_LPARENTHESIS) { get_symbol(); compile_e...
For an integer $I$, the input-output relationship of a discrete memoryless channel is given by: $Y = X + Z$ (mod $I$, i.e. sum indicates a modular addition) where $I ≥ 2$, and • $X$ is an integer chosen from the alphabet $A_x = \{1,\dots,2I\}$, • $Z$ is noise which is a uniform Bernoulli random variable. This means th...
I'm trying to show that $K_1 \le_1 K$ where $K$ is the diagonal halting set $\{x : \varphi_x(x) \downarrow\}$ and $K_1=\{x: \exists y \,\, \varphi_x(y) \downarrow\}$, then I defined the function $$\psi(x, y)= \begin{cases} 0 \, \, if \, \, x \in K_1 \\ \uparrow \, if \, x \notin K_1\end{cases}$$ By the Parameter Theore...
This link says They are not constrained to stepwise calculations but, rather, can compute a vast number of possible solutions simultaneously—and at a speed that is far beyond anything we can imagine. Is this really true? AFAIU quantum computers cannot compute a vast number of possible solutions simultaneously. A ...
Consider this implementation of a dynamic programming algorithm for weighted interval scheduling: M-Compute-Opt(j) If j=0 then Return 0 Else if M[j] is not empty then Return M[j] Else Define M[j] = max(v_j + M-Compute-Opt(p(j)), M-Compute-Opt(j − 1)) Return M[j] Endif...
In the highlighted part below how is Weiss concluding that the array starting at an arbitrary index "p" and ending at "j" can never be larger than the array starting at "i" and ending at "p-1"? By his own example (the inner loop of algorithm 2 shown below) this is demonstrably false. Let i = 0, and j = 3. Let a[ ...
I'm trying to write machine learning software that will predict a list of 3 values from a given number input (reverse grayscale). There is a function determining values of the list to the grayscale, but finding the inverse by hand seems impossible. I think something like Markov Chains or a random forest algorithm might...
I have a question about machine words. We have data and a code segment in the memory which is addressed. If we take a word from it and let's say it is a code (instruction), and another one is some data. Can we have a situation that some word is sometimes code and sometimes data?
As stated in Lamport's papers for the bakery algorithm he states that the ticket numbers are unbounded specifically The range of values of number is unbounded. and Fortunately, practical considerations will place an upper bound on the value of number[i] in any real application. For example, if processors enter th...
Gradient descent sometimes works better than simulated annealing and vice versa. Are there conditions under which we can prove that, given perhaps a restriction on the set of allowed algorithms, one of these is optimal for solving an optimization problem? I am particularly interested in those two examples, but in gener...
I was asked how to remove comments in a JavaScript program, but once I gave the regular expression solution, I was asked what if there are comments like text inside of a string: let hi = " // here "; let foo = " use this: /* "; let foo2 = " \" and that */ "; it also can get complicated with the cases with stri...