instruction
stringlengths
35
29.1k
Is it possible to parse all kinds of structured data and give them a semantic meaning? For example, C++ is a really complicated language and I could never imagine a parser would be possible for it. What makes a certain grammar parse-able and contain semantics? How do I decide a written information is parse-able?
What is the hardness of the following problem? Input: An undirected graph $G(V, E)$ and a natural number $k$ Output: YES if $G$ has an equidistant vertex set of size $k$, otherwise NO $\DeclareMathOperator{\dist}{dist}$An equidistant vertex set is a set of vertices $V'\subseteq V$ such that for every two pairs of ver...
I am trying to relate the following integer square root theorem $\forall x: \mathbb{N}, \exists y : \mathbb{N}((y^2 \leq x) \land (x < (y+1)^2))$ and its proof to its role as a specification of the Integer Square Root isqrt ($\lfloor \sqrt{x} \rfloor$) function in a Haskell program. Below is a inductive proof of the ...
I have read that checking if tuple belongs to join of two tables is NP-complete. I had computional-complexity activities during my studies, I remember basics, however I have forgotten details. Nevertheless I don't understand why it is NP-complete, it seems to me that I can solve it in polynomial time. Let's consider ...
I was reading single pass in memory indexing and had few doubts. Why is the time complexity of SPIMI O(T) where T are the token. We know that before writing blocks to Disk, we have to sort dictionary terms. So, why don't we consider log(T) factor of it? Also, if there is some data in memory then while performing sorti...
Let's say I have a context free language. It can be recognised by a pushdown automaton. Chances are it can't be parsed with a regular expression, as regular expressions are not as powerful as pushdown automata. Now, let's put an additional constraint on the language: the maximum recursion amount must be finite. Because...
Consider a network with $N$ nodes $1,...,n$. Every node is connected to every node via a weighted edge, where the weight represents distance. You start your travel at a given node, say $1$, and end your travel at a given node, say $12$. Your travel has $T$ time steps. At time step $t=1$ you must visit one of nodes $\{1...
What does she mean by finding the 6 qubit quantum state $|010001\rangle$ from a sphere of dimension $2^6$. Here is the link: https://www.youtube.com/watch?v=IrbJYsep45E at time 8:47.
Let $R$ be a regular set over the alphabet $\{0, 1\}$. Give a machine construction to prove that the set obtained by deleting one 1 from each even length block of 1’s is also regular, and using closure properties for the class of regular sets. Current Approach: For the first part, using a machine construction, I w...
So, in the book I'm studying from it says : The statement “f(n) is O(g(n))” means that the growth rate of f(n) is no more than the growth rate of g(n). What I understood from this statement is that since 9n is O(n), the growth rate of the functions 9n and n have the same growth rate, which does not make sense. I know...
I wondering how the browser's JS runtime implements these methods. I looked on the web and could not find any documentation. How does something like the V8 runtime actually work to implement these methods into machine code? At runtime what does the call stack look like? Function function multiply(a, b) { return...
The relation between disparity and depth is derived based on the assumption that the two cameras are parallel. Image rectification does not make this assumption valid. But I see in many university computer vision lectures, with two rectified images, the depth map is directly calculated. I cannot figure out why.
I'm having difficulty understanding the big-O analysis of the selection sort algorithm. Here is my pseudocode (with line numbers): procedure SELECTION (A(n), limit) 1. for j <- 0 to limit - 1 do 2. min_index <- j 3. for k <- j + 1 to limit do 4. if A(k) < A(min_index) 5. min_index ...
I need help with proving the following language is not regular: $$ L = \{ a^n b^k \mid n > k \} \cup \{ a^n b^k \mid n \neq k-1 \} $$ My usual methods using pumping lemma are not getting me anywhere.
Suppose we have a CNF formula $F$ and a permutation $\sigma$ of its literals such that for any literal $x, \sigma(\neg x)=\neg \sigma(x)$ and $F \vDash \sigma(F)$. Does it hold that $F \equiv \sigma(F)$? It is the case when $\sigma$ is a syntactic or even a semantic symmetry of $F$ but I don't know if it hold for any ...
Prove that for any symbol $a$ and regular expression $r$ it is true that: $$\partial a(r^* ) = \partial .a(r)(r^* )$$ My attempt: Induction on regular expression $r$ Base cases: 1) $\emptyset $ $\partial a(\emptyset^* ) = \partial a(\varepsilon) = \emptyset$ $\partial a(\emptyset) (\emptyset^* ) = \emptyset \empty...
Beginner in DFA related studies, was trying to figure out how to create a DFA with {a,b,c}, that can recognize a * b * c *. Appreciate the help.
The rod-cutting problem described in Section 15.1 of CLRS, 3rd edition is the following. Given a rod of length $n$ inches and a table of prices $p_i$ for $i = 1, 2, \ldots, n$, determine the maximum revenue $r_n$ obtainable by cutting up the rod and selling the pieces. This can be solved by dynamic programming with ...
I asked this question on Math Stackexchange but it didn't get much attention, so I am asking it here. Edmond's Blossom algorithm (Wikipedia), or simply the blossom algorithm, is a popular graph algorithm to construct a maximum matching in a graph (matching is a set of edges without any common vertex; maximum matching i...
Following the success of the previous question: Karp hardness of an equidistant vertex set I continue to propse yet another computational problem. This time, we modify the notion of an equidistant vertex set to obtain the notion of a simply equidistant vertex set. A vertex set $V'\subseteq V$ is called simply equidista...
The problem is from the ACM Collegiate Programming Contest: 5924 - Parallelogram Counting Problem Description The International Consortium for Parallelogram Counting (ICPC) wants to move into the digital age and automate their parallelogram counting. They want to count the number of parallelograms formed by universitie...
I am wondering how to represent signed number, vector, matrix on binary tape of Turing machine to consume the smallest possible amount of memory. For signed number it is obvious: encode sign as a single bit and sum it with the length of number representation $\lceil\log_2(\mathrm{abs}\,(n)+1))\rceil$. But how is it pos...
I just saw this short documentary about atomic clocks. The person working for the Atom clock company gets asked what would happen is all the atom clocks would be turned off and he replayed that cell phone services and the internet would stop working. I have read that an accurate time is important but do not now why. W...
I have a binary variable $x_{ijt}^k$ that is $1$ iff job $i$ is assigned to machine $j$ at time $t$ using processor $k$. I would like to express the following constraints: If job $i$ is assigned to machine $j$ at time $t$ using processor $k$ then job $i$ cannot be assigned to machine $j'\neq j$. If job $i$ is assigne...
I'm trying to connect cylinders with a sphere in 3D smoothly. The sphere is given by a single 3d point-diameter data and the cylinders are given by point-diameter data as well for the start of the cylinder and the end of the cylinder for each cylinder respectively. I would like to describe the cylinder by a spline, ...
I'm having trouble understanding exactly how the graph for Pn (where n = number of pancakes) is defined recursively for n>= 4. I can see obviously that, in the case of n=4, there will be 4 rough copies of the graph where n=3 with additions of 4 in certain places (where, and how is this defined?). But these copies aren'...
This is a thread about mathematically calculating time complexity of nonlinear functions. I know that those questions were asked a lot, but it didn't make me understand fully the subject. Also I understand that it's impossible to calculate every function, but usually we can (otherwise we have not been asked to do so o...
I am going through the Monte Carlo methods, and it's going fine until now. However, I am actually studying the On-Policy First Visit Monte Carlo control for epsilon soft policies, which allows us to estimate the optimal policy in Reinforcement Learning. I am having troubles understanding the step in blue of the algor...
I was reading the paper titled "Primal-dual RNC approximation algorithms" by Rajagopalan and Vazirani. I have a problem of understanding the Lemma 4.1.1. They present a dual fitting based algorithm for weighted set cover. First let me set up the required concept to clarify where I am having trouble. Suppose we have $n...
It seems to me that problems whose dedicability remains open for a long time, if resolved, tend to end up being undecidable. A prominent example would be (e.g.) Hilbert's tenth problem, whose decidability was open 21+ years (†) until proven decidable. Is there a similiar example of a problem whose decidability was open...
We typically measure algorithm efficiency by space efficiency and then time efficiency e.g. this algorithm takes O(n) time and O(n) space. However, I feel this does not capture the full story. Say we have a process that looks like this. Assume memory allocation is O(1) time complexity for simplicity. process(n): mem ...
Let $A$ be a problem that I want to show it is coNP-complete. I know I could just show its complement $\bar{A}$ is NP-complete or that $\bar{A}$ is in NP and for some coNP-complete problem $Q$, show that $Q$ can be Karp-reduced to $A$. But I wonder if the following steps are sufficient to show that A is coNP-complete...
The divisor and dividend are of length n and m bits respectively. According to Wikipedia article, https://en.wikipedia.org/wiki/Output-sensitive_algorithm division by substraction is an output sensitive algorithm and has the time complexity of Θ(Q). Can the time complexity be calculated in terms of length of input bits...
I was studying the grid problem where a robot is at the top left position and wants to go to the bottom right position and you need to return the number of unique paths it can take to get there with the constraint that it can only move down or to the right. It looks like the standard way to solve this is with the top-d...
I have a course named "Evolutionary Algorithm". But, our teacher is always mentioning the word "Optimization" in his lectures. I am confused. Is he actually teaching Optimization? If yes, why is the name of the course not "Optimization"? What is the difference between the study of Evolutionary algorithm and Optimizatio...
While reading Computer Architechture book by M.Mano. I came across Arithmetics Microoperations sections which has two microoperations which confuses me a lot, R3 <- R1 - R2 ( Minus Microoperation ) R3 <- R1 + complemented(R2) + 1 ( Subtract Microoperation ). Can someone tell me the difference?
I'm reading about Quicksort algorithm, specifically using the Hoare partitioning scheme. Wikipedia page says, that when choosing a pivot element one can use both hi and lo indexes. However, when implementing the same code in Python, my code fails in a very specific circumstances. My python code is a translation of the...
I'm fairly new to studying data structures and algorithms. I've implemented a non-recursive BFS on a 2d "maze array" which seems to work well. It finds the position of 2 in an array of 1s (walls) and 0s (spaces), marking visited positions with 3. However, I notice that there are duplicate values in the Queue. I underst...
I'm currently trying to implement this paper. Based on a bayesian network, the paper stays unclear about how to ultimately use it's content ("straightforward inference"). But after a lot of researches (I have no background in that field), I think I can apply Viterbi algorithm to get the expected result. I will give he...
I am trying to understand this program and the respective forest. This is from the book Logic,Programming and Prolog by Ulf Nilsson. Question: In the main tree, why from ←off_gound(a) can you derive ⧠ ? In the main tree, why was chosed on(b,a) first instead of on(c,b)? Could someone please explain this? Thank you ...
Consider I have the following recurrence $$T(n) = 10T(n/3) + \Theta(n^2\log^5 n)\,.$$ Now, by the master theorem, if we evaluate $n^{\log_{b}{a}}$, we get $n^{\log_{b}{a}} = n^{\log_{3}{10}} = n^{2.095}$. Now, can anyone please explain me, which of the three cases apply? If you plot these functions you can see that $n^...
Is the problem to construct a $\mathcal{O}\mbox{*}(1.4^n)$ (or better) time algorithm for subset sum still open? I wanted to check the problem before finishing a paper. The most recent reference I found to this open problem is on next paper: 'SETH-Based Lower Bounds for Subset Sum and Bicriteria Path, Amir Abboud e...
Given an Nondeterministic Finite State Automaton with $n$ states over an unary alphabet, is there some algorithm to check if the automata is universal in time polynomial in the number of states? I would not expect this would work over an alphabet of size two or more, since it is PSPACE-complete to check whether a regul...
Assuming only computable functions, and in line with set theory, defining a "proper class" as a collection that is itself not allowed to be a member of a set. A "collection" is then defined as either a set or else a proper class, in cases where we do not wish to distinguish. If a set is defined by its membership functi...
Given a Monte-Carlo algorithm (called A) that given a binary array with b 'on' bits (one-bits) returns a, where in a probability of 1/2: $\frac b 3 \leq a \leq 3b$ How can I use A to build an algorithm that does the same, but with probability $poly(\frac 1 n)$ of success (success means $\frac b 3 \leq a \leq 3b$ ), us...
Following the success of the undirected version: Karp hardness of an equidistant vertex set Inspired by the success of this long ago question: NP-hardness of problem with indices and subsets We move on asking for the hardness of the directed version of an equidistant set. Input: A directed graph $G(V, A)$ and a natura...
Today I was taught that since the height of a heap cannot exceed $\log n$, it is $O(\log n)$; height in my class was defined as the maximum number of steps in a simple path from a leaf to the root. That is fine, but I think we should further specify it as $\Theta(\log n)$ since it, at that same time, must be greater th...
given an AVL tree with $size$ value to any vertex $v$ in the tree (which is the size of the tree rooted in $v$), is it possible to tell for a given value in the tree, what its order in the sorted group in $log (n)$ time complexity?
Toda showed long ago that $\mathrm{PH\subseteq BP.\oplus P\subseteq BPP^{\oplus P}}$. That somehow describes the power of Parity Non-deterministic Computation. If we swap the base and the exponent of the relativized class $\mathrm{BPP^{\oplus P}}$ to obtain yet another relativized one, namely $\mathrm{\oplus P^{BPP}}$....
Between an adjacent pair of nonzero IEEE single precision real numbers, how many IEEE double precision numbers are there? I was also wondering if this question has something to do with the hidden bit. Can anyone help me?
Given the question below: Consider that, on the procedure below, the variable X is defined globally and the parameters of the vr function are passed by value procedure vr(u,v) { u = 2*u; x = u+v; u = u - 1; } Define the value of x in the end of the following: x = 4; y = 2; vr(x,y); print(x); I always knew ...
In Wolpert's "No free lunch theorems for optimization", he uses the following formalism for an optimization algorithm: Let $X$ be a finite space of which an element has to be chosen, and let $Y$ be a finite space. Let $f:X\to Y$ be a cost function, where a higher value in $Y$ denotes a higher cost. An optimization algo...
We have that $\mathrm{NP\neq coNP\iff NP\neq NP\cap coNP}$. So by assuming that $\mathrm{NP\neq coNP}$, can we prove the existence of intermediate problem between $\mathrm{NP}$-complete and $\mathrm{NP\cap coNP}$?
Consider the example of solving for $x$ where $Ax=b$. This is not in general function, there can be more than one solution. So if you make such a solver in a functional style...does this count as a side effect? def solve(A:Matrix[Float],b:Matrix[Float]):Matrix[Float] = ... Obviously the solution will be dependent ...
I have a little problem which requires determining if a system of linear inequalities in 3D is infeasible. The constraints (or oriented planes) are added one by one, so there is an opportunity to stop as soon as the system becomes infeasible. Basically this: class LPSolver { // add constraint ax + by + cz + d < 0 (...
The randomization solution is from majority-element, and the corresponding complexity given confused me very much. The complete procedure of calculating iterations give is : $$ \begin{split} EV(iter_{prob}) & \le EV(iter_{modif}) \\ & \le \lim_{n\to\infty} \sum_{i=1}^n i \times\frac{1}{2^i} \\ & =2 \end{split} $$ I w...
What are some problems that are in $\mathrm{P}$ but the best known algorithm has a high-degree polynomial ($\ge 3$) time complexity?
I understand that in terms of minterms, F (Boolean Function) = Sum of Products and thus will yield true when either of the products is true. But I am unable to develop any intuition for maxterms, F(Boolean Function) = Product of Sums (of maxterms). Is F = Product of sums just a different way of representing F = S...
A related question: How to prove that a bounded pushdown automaton is regular? Well I proved that $a_k$ for each $k$ is the set of all the regular language. Thus $\bigcup_1 ^{\infty} a_k = \bigcup_1 ^{\infty}\{$ the set of all regular languages} = $\{$ The set of all regular languages $\}$. However before noticing that...
I'm trying to write a non-ambiguous context-free grammar that can generate the set of natural numbers, including the 0. My current solution is the following grammar: $\mathcal{G}: S \rightarrow 0\ |\ ...\ |\ 9\ |\ 1S\ |\ ...\ |\ 9S$ From what I understand, there is not an algorithm to determine whether my guess is corr...
We have two equations $g = O(f)$ and $h = O(f)$ , then can we derive that $g = O(h)$. I came up with following proof but i dont know it's correct or not. $$g = O(f)$$ $$g \le c_1*f $$ $$h \le c_2*f $$ Now we have to prove, $$g = O(h)$$ $$g \le c_3*h$$ $$g \le c_3*c_2*f $$ $$ c1 \le c3*c2 $$ We can find $c_3$ such that...
I would like to know how to alter/add NOTs when applying Duality principle. Suppose I have P = XY(X+Y) + NOT(Y), how to find its dual? My book says that while applying Duality Principle to a relation: Change all 0s to 1s Change all ORs to ANDs Change all ANDs to ORs But it doesn't say anything about NOTs.
I know that unsafe state does not always mean deadlock. That is a situation that banker's algorithm does not detect deadlock accurately. I am just wondering if there is any example of a safe state that deadlocks?
I'm reading a paper, and there is this paragraph about LLVM: ''it heavily relies on the static single assignment form (SSA) which cannot be readily used to design an abstract interpreter. The $\phi$-nodes need to be eliminated and other inadequate constructs need to be simplified using various LLVM transformatio...
[Using Idris syntax and terminology, but the question is not about Idris] If a monad interface (or type class) has a constraint requiring applicative functor, a monad instance can be written by implementing either bind: (>>=) : Monad m => m a -> (a -> m b) -> m b, or join : Monad m => m (m a) -> m a, or both. However, ...
Pseudocode: if n < 2 return false while n != 1 if n % 2 != 0 return false n = n/2 return true The loop will terminate when n is odd. If n = 1, true is returned and that means that n0 was a power of 2. Otherwise it's false. I'm new at this and struggle with the proving the power of 2 part for before...
I'm interested in implementing equality checking mod 10 in an arithmetic circuit. Is this possible? Preliminary evidence points towards "no", but I thought it best to ask before completely writing it off. First, note that if $\mathbb{Z}_{10}$ were a field, this would be trivial due to Lagrange interpolation (allowing ...
In the book here: http://neuralnetworksanddeeplearning.com/chap3.html If you scroll down to Exercise 2 in the Softmax Section, it says Show that $\partial a^L_{j}/\partial z^L_{k}$ is positive if $j=k$ and negative if $j \neq k$. As a consequence, increasing $z^L_j$ is guaranteed to increase the corresponding output a...
Given two sequences of points(i.e. ordered points), connect the points in seq_A with the points in seq_B according to some rules. A point could be connected to 0, 1, or many points in the other sequence. But there should not be any line crossing. And each line could be assigned with a weight(controlled by relation betw...
I am trying to find the name of an algorithm for a game I am making. I am pretty sure it exists, but I have no idea what name it has. Say I have a matrix like: $$ \begin{array}{|r|r|r|} \hline \hphantom{-}1 & -1 & 0 \\\hline 0 & 0 & 1 \\\hline 0 & 1 & -2 \\\hline \end{array} $$ I know that the sum of e...
I am going through Richard Sutton book about Reinforcement Learning and I just encountered the tile coding method. I understood pretty well the principles, however, at the very end of the section, tile hashing is mentionned. Hashing produces tiles consisting of noncontiguous, disjoint regions ran- domly spread throu...
How to prove $\Theta(g(n))\cup o(g(n))\ne O(g(n))$ ? Is there a simple example for understanding? Seems there's a gap between $O(g(n))- \Theta(g(n))$ and $o(g(n))$ just from the definition. But I cannot understand What kind of function lays there?
Is it there any computer or cellular automaton or model of the brain where they could compute logically impossible things and incomputable things? For example, if we wanted to compute/simulate/think about a universe where 1+1=3 (which would gives as result a universe where literally everything could happen, possible or...
I've been trying to get into Agda and I noticed that it doesn't have recursion, which implies that it isn't Turing-Complete. From what I could understand, if Agda had recursion, it would make itself an inconsistency from a type theory perspective. Something stuck to my mind: Is it possible to exist a language that it i...
I have a question that I am stuck on reasoning about knowledge. For the following statement, I need to show whether it is valid, satisfiable or unsatisfiable: $\bf{K}$(Happy $\lor$Sad) $\implies$ $\neg \bf{K}($Happy) I have done the following: Let e w be an interpretation where e is the set of possible worlds and w is ...
Background I have several F# codebases with reasonably high level of complexity of code. In order to convince myself that the code is solid I do whatever I can to write as much of it as possible type-driven and pure (up to what I am able to determine is pure without much help from the compiler) and unit test it like cr...
Imagine I have a binary heap, traversed in a breadth first manner like so: 0 1 | 2 3 | 4 | 5 | 6 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 To the left of root (0) is 1, to the right is 2, to the left of 1 is 3 to it's right is 4 etc. So node 13 corresp...
I've noticed that Big-Oh notation actually has some properties such as summation, product but i couldn't find an introductory explanation for their use or how they can help to solve asymptotic problems. 1) Is it possible to explain these properties in plain English? 2) Can these properties be applied to Big-Omega and ...
I came across this problem in Tim Roughgarden's course on Coursera: In this problem you are given as input a graph $T=(V,E)$ that is a tree (that is, $T$ is undirected, connected, and acyclic). A perfect matching of $T$ is a subset $F \subseteq E$ of edges such that every vertex $v \in V$ is the endpoint of exac...
There exist 5 rules for any pseudocode , one of these rules is : "Keep statements language independent" I don't understand what is this rule is saying. So can someone explain it and then give an example of pseudocode written to be language independent ? Moreover, the source for this rule is "Invitation to Computer Sci...
What is the highest time complexity lower bound that has been proven on any (non-contrived) NP complete problem?
I am somewhat aware of the correspondence between (tuple and domain) relational calculus, relational algebra, and SQL. To the best of my understanding, one should be able to automatically convert a formula in relational calculus to an SQL query whose run on a database produces rows that make the original formula satisf...
Lets assume I'm talking about Jpeg and Mp4 and a general video player(not sure if different ones load it differently, if they do please tell) So do video players (process) usually load the entire Jpeg or Mp4 including metadata into its own memory space right? like lets say we have a 1920x1080 picture with 10 bytes of ...
The problem of "Scheduling to Minimize Lateness" is as follows (Section 4.2 of the book "Algorithm Design" by Jon Kleinberg and Eva Tardos): Input: A finite set $J = {J_1, J_2, \ldots, J_n}$ of $n$ jobs, their processing time $t_1, t_2, \ldots, t_n$ and deadlines $d_1, d_2, \ldots, d_n$. We assume that all jobs were a...
The question is simple and given as, alphabet $A$ is $\{a, b\}$, and language $L$ over $A$: $L = \{w: w \in \{a, b\}^*, n(a) - n(b) = 1 \mod 3\}$. Here $n(a)$ = number of $a$ and $n(b)$ is number of $b$. My answer is that it's not a regular language because the modular expression can be simplified as. $n(a) =n(b) +3k+1...
Problem statement: Input: a digraph $G(V, A)$ and a natural number $k$ Output: YES if it is possible to color all vertices of $V(G)$ by $k$ colors such that no directed cycle is monochromatic, NO otherwise Is this an $NP$-complete problem?
The question is as follows $$(a^* (ba)^* )^* (b+\epsilon) = (a+b)^* (b+\epsilon)\,.$$ But I am unable to solve this regex expression. My answer is as follows: \begin{alignat*}{2} (a^* + (ba)^* )^* ( b+\epsilon)\qquad &\text{(using property} (a^* b^*)^* = (a^*+b^*)^* = (a+b)^*\text{)}\\ =(a+ ba)^* ( b+\epsilon)\qquad...
Are there any known famous and usable algorithms that seem to solve some famous problem but which haven't been proven to be correct?
I'm reading Computer Science: An Interdisciplinary Approach. It mentioned an NFA (nondeterministic finite automaton) with a null transition, as shown above, recognizes all binary strings that do not contain bba as a substring. I didn't quite understand why it says so. If the null transition happens before reading the ...
I am focusing here on positive even SAT problems, that is a CNF for which all literals are positive, and in which an even number n of variables occur. This is obviously trivial : just set all variables to true and all clauses are satisfied. The same if we look for an assignment that would have all but one variables be...
I was told that this language is regular but as I can show below, pumping lemma is not working for it. What am I doing wrong? Is this language really regular? Why?
Consider the alphabet $\mathcal{A}=\{a_0,a_1,a_2,a_3\}$ with the the following corresponding probabilities: $\, p_{A,1}=\{0.5,0.3,0.15,0.05\}$ $\, p_{A,2}=\{0.5,0.25,0.125,0.125\}$ The entropy for the first case is $H(A,1)= 1.65$, and for the second is $H(A,2)=1.75$. The Huffman code for both can be $\{0, 10, 110, 11...
My first post here so please correct me if my terms are off or needs clarification. Suppose I have several sets of lists of spans. I define a span as a pair of indexes: begin and end index in a string. You can also think of a span as a consecutive sequence of 1's in a bitarray. e.g. 00111 is a span of (2,5). I will hav...
I have a ciphertext $c$ encrypted with RSA algorithm that needs to decrypt. I have the public key $(n,e)$. Is it possible to decrypt with this amount of information?
I asked my Advanced Algorithms professor recently if we could solve the coin change problem (least number of coins necessary to make change for S cents using denominations d1, d2, ... dk). I thought this might be possible using something like the least common multiple of the denominations to find a subset of answer tha...
the question is as follows, further the notation used are standard as used in theory of computation $$L = \big\{ w : w \in \{a,b\}^*,\ |n(a) - n(b)| = 2k\}\,.$$ Beware 'K' is not a fixed integer its a set of natural number , so 2k means all natural nunbers divisible by 2 and so on for 3k , 4k... .I think the above lan...
I am given a connected graph. I have to construct a spanning tree from the graph, that has minimum diameter. However, I looked for the solution, and the solution goes like this. If the diameter of the tree is even, then it must have a center node. Then we try to find the center node by finding all pair shortest path fi...
Problem I am trying to solve is this: There are n nodes, and for every pair of node $X$ and $Y$, the relation "$X \space knows \space Y$" is either $T$ or $F$. It is possible that "$X \space knows \space Y$" but "$Y \space doesn't \space know \space X$". We are trying to find if a special node exists: that is known ...
I am thoroughly confused by a problem that was brought up in class: Given the following pseudocode for a function RANDOM which generates a random number based off of recursion: function RANDOM(n) 1. if n = 1 then 1.1 return 1 1.2 else 2.1 assign x = 0 with probability 1/2, or 2.2 assign x = 1 with probabi...
There are tones of solutions for Knights tour or shortest path for Knights movement from source cell to destination cell. most of the solutions are using BFS which seems the best algorithm. Here is my implementation using HashMap: public class Knight_HashMap { static HashMap<String, Position> chessboard = new...