instruction
stringlengths
35
29.1k
Suppose that I have two lists of numbers (which represent IDs for rows in a database): list1 = [1, 4, 7, 8] list2 = [2, 3, 5, 6, 7] I would like to write an algorithm to pair each number in the larger of the two lists with a number in the smaller list such that: Every item must appear in at least one pairing No item ...
We are given a sequence of $n$ numbers called $\alpha$ and an arbitrary number $x$. Give an algorithm to find a permutation $\pi$ of size $n$ such that $\sum_{i=1}^n{\alpha_i.\pi_i} = x$ or tell if there is none. Well I wasn't able to solve it in polynomial time and I'm not sure whether it's possible. So if it's NP w...
My question is simple but I don't know if the answer is. If you have two strings of length 10 million each, is there an algorithm that would allow you in practice to compute their edit distance (Levenshtein) if you are told it is at most 100?
In a rewriting system, suppose the production rule S→xAyAz (or <S>:=x<A>y<A>z, in BNF), where S and A are nonterminal symbols and x, y, z are any string. This rule produces the string xa1ya2z, where a1 and a2 are strings substituted by the nonterminal symbol A. The substitutions a1 and a2 may be equal or different stri...
I am attempting to understand the growth of the following algorithm, which is described as $n^2$ growth in the book I am reading: "... performs of the order of $n^2$ steps on a sequence of length $n$." Could someone please explain how this is calculated in the following code, which is also taken from the book? If I pri...
Is it possible to define a 《chess language》: language={alphabet = {(chess pieces, squares of chess board)}, grammar={rules of movement of pieces over the board}}? I looked online but I cannot find a way to define the grammar. Every way I can think of, is either stupidly long and complicated, or does not cover all the r...
Consider a tree structured task list where intermediate nodes define sub-groupings of tasks but are not tasks themselves, and the leaves represent the actual tasks. I want to traverse this type of tree giving equal opportunity/priority/time(?) for each group with respect to its parent. For example, if the root have 3 s...
I've taken intro to graphics and am interested in diving deeper into the subject. My understanding is that the field depends a lot on geometry, but I'm having trouble figuring out exactly what geometry I should learn now that I've tackled the basics. I found https://www.springer.com/us/book/9781852338343, but it basic...
Consider a 2,3,4 tree like so, 53 / \ / \ / \ 46 60 | 70 / \ / \ \ / \ / \ \ / \ / \ \ 41 48 55|59 65|68 73|75|79 How to delete 41 from the tree from here ? I would like to know the in...
I have the the following problem. Say we have a graph $G = (V,E)$ where all $e \in E$ have positive weight, and $E$ can be separated in to two disjoint sets $E = A \cup B$. We have to find a spanning tree such that we minimize total weight but also we can only use a maximum of $c$ edges in $B$. I feel like this is just...
As far as I know, Breadth-First-Search [BFS] theory traditionally requires a Queue to process a given level of a graph (i.e: wiki seems to assume so). But does BFS really actually require a Queue, rather than just any type of Collection? A Queue is a Collection A Set is also a Collection, for example Wiki states that...
My textbook says, "Instead, it is far better to use a hexadecimal representation for documentation purposes. Whether or not a code represents a binary number, it can be treated as such and converted to the corresponding hexadecimal number. This makes the representation more compact and, as a result,...
I've been struggling with a particular constraint satisfaction problem, that appears like it should have an easy solution. In fact, I need a very fast solution. The problem is: I am making a card-playing AI, and at some point I need to guess a plausible solution to the other players hands. Given the history of the gam...
I'm wondering why if I increase the number of step in a set of simulation of a random walk on a grid the distance from the origin is higher. If I can move on the grid in 4 directions, there are 0.5 chance of getting closer to origin and 0.5 of getting farther. This is a simple javascript example (well, here maybe I mad...
If you have a back edge in a directed graph, then you may have a cycle or must have a cycle?
Student asked me this question. During lectures on algorithm complexity I've shown similar picture (source): After I've explained and gave examples for each category, a student asked: "Which of these represent a majority of algorithms?" I guess that the question is not right in a sense that we are creating new algorit...
I read that a fully polynomial time approximation scheme (FPTAS) has time complexity polynomial in the input size and also polynomial in $1/\epsilon$. However, this leaves some ambiguity. For example, $T(n,1/\epsilon)=\min(n^{1/\epsilon},(1/\epsilon)^n)$ is both polynomial in $n$ (when holding $1/\epsilon$ constant) an...
If consecutive natural numbers 1 .. n^2 are placed in a n*n grid so that sum of numbers in each column and in each row is a constant then we call it a magic square. I would like to generate magic squares of size 16x16 and 256x256 for not skewed byte mapping. Maps arranged as magic squares tend to have better distributi...
Solve by using the substitution method $T(n)=T(n-1)+2T(n-2)+3$ Given $T(0)=3$ and $T(1)=5$ I kind of understand it with only one given and one recurrence call by expanding the call using what is inside. ex. if it was $T(n)=T(n-1)+3$ Given $T(1)=5$ I would take the $n-1$ and plug it into the the first equation $T(n)=T...
This problem involves the time-complexity of determining set intersections, and the algorithm must give output on all possible inputs (as described below). Problem 1: The input is a positive integer $m$, and two unordered subsets $A$ and $B$ of $\{1,\dots,n\}$. The size of the input is $n+ |A| +|B|$. Output: The ...
How can I prove this identity of languages? My aproach is the following: Let A, B and C to be languages, and let x to be an arbitrary string. (A ∪ B) ⇒ x ∈ A ∨ x ∈ B How do you proceed?
Whenever we try to get space in heap(using malloc or new) we can get out of heap space error if it exceeds the limit. But, we have virtual memory so why can't OS allocate that much space and then do swapping when I need some part of it or not?
I study Huffman Coding tree from "Data Structures and Algorithm Analysis" of Shaffer and it says that Huffman Coding tree is an opportunity to experience a search trie. However, the code implements it with a heap class. As a result, I wonder if Huffman Coding tree is actually a heap or a trie? If it is a heap, is it a ...
I am trying to implement the algorithm described in the paper A quantum-inspired classical algorithm for recommendation systems. This is the algorithm: These are the necessary definitions for mathematical notations used in the algorithm to understand the algorithm. The distribution is defined as, for a nonzero vecto...
Hypercomputation is a "cheat" that extends the capability of a Turing machine or quantum computer or cellular automaton by adding extra abilities. A standard method is "Oracle machines", Turing machines with an extra black box device that can be queried and give an output that normally would be uncomputable. For exampl...
The Space Hierarchy Theorem states that If $f(n)$ is space contructible, then for any $g(n) \in o(f(n))$ we have $SPACE(f(n)) \neq SPACE(g(n))$ An example of a SHT proof can be found here or here but they are generally based on the same idea differing only in technical details. We would like to find a language $L$ su...
I want to show the reduction $HC \leq HP$. Let $G=(V,E)$ be my undirected graph. My idea is: For each edge $e=(u,v) \in E$ check whether $(V,E\backslash\{e\})$ has a Hamiltonian Path. If this is true for all edges, we have a Hamiltonian circuit in $G$. It is pretty trivial to proof the first direction (when we have a ...
I was solving this problem and end up learning two ways to solve this problem. One is two pass method and the other is considering peak and valleys (candies - interviewstreet). Both of these are O(n) solutions. Now, I was thinking about the generalized problem which consider k neighbors(i.e. for the ith child we have t...
I am stuck on how to progress with this proof; i cannot see my next move. The task is to show $S \to \exists x Q(x) \vdash \exists x (S \to Q(x))$ using natural deduction for predicate logic. My first attempt was the following; 1: $S \to \exists x Q(x) \space \space \space \space \space \space premise$ 2: $x_{0} \space...
I'm going through an algorithms text book. One of the questions asks: True or false? $n + 2n^2 + 10n^4$ is $O(n^5)$. This is marked as true. Shouldn't it be $O(n^4)$? What am I missing here?
Let $U=\{1,2,3\cdots m-1\}$ and some $n$ keys from $U$. Is it possible to sort these $n$ keys in $O(n \log \log n)$ time using $O(n)$ space? Model of computation is RAM.
These questions is about one of my research. As I am not a computer scientist, formal answering is difficult to me. I have a special search algorithm which the explanation here will take a lot of time. However I can explain it shortly by some notations. Assume that we have an array of somethings (in my real research ...
We have given array $V$ of $N$ integers, we want to count the number of subarrays of the array such that each elements in the subarray either doesn't occur at all, or it occurs odd number of times. Subarray is subset of array that is contiguous part of the array. For example $N = 4, V = \{1, 1, 1, 2\}$. The result is $...
I had review feedbacks regarding my recent publications and reviewers argued that the improvements are not significant over the baselines. I tried my classification algorithm on some image datasets such as Extended Yale, and in the literature (other papers) i noticed the same amount of improvements in the results was a...
Both AlphaGo and AlphaGo Zero include prior board states as input features (the "Turns Since" planes for AlphaGo, and the repeated 8-step history planes for AlphaGo Zero). What is the purpose of including this history information in the input to the neural networks? If we ignore the ko rule, the best move at a position...
Say I have $n$ numbers in an array and I have to compute the sum of those numbers. Is the complexity considered as $O(1)$ or $O(n)$? Clarification Say I have 10 constants, I could precompute the total and claim that overall, the complexity is $O(1)$. Yet, if I have 10 assigned variables, I would have to perform 10 addi...
Suppose we have a formula $F(x_1,x_2,x_3) = x_1 \vee (x_2 \land x_3)$. $F$ outputs 1 when it has a satisfying assignment and 0 otherwise. How can I convert the above formula(or any formula like this in general)to a branching program(constant width)?
Let $A\subseteq \{1\ldots n\}$ with $|A|=\alpha n, 0<\alpha\leq1$. Now we start generating random sets $B_i \subseteq \{1\ldots n\}$ with $|B_i|=\beta n$ where $0<\beta\leq\alpha$. How many $B_i$ do we have to generate, so that there exists a $j: B_j\subseteq A$ with decent probability (constant or overwhelming in $n$...
I have been reading the chapter 6.2.2 in Knuth's book about lower and upper bound on the average path length in binary search tree. And I have problems with understanding small details of Theorem M (page 445, second edition) about an upper bound on the average cost of the search. Here is the theorem: Given $n$ keys and...
The classic $k$-center with outliers problem is NP-hard and there exist approximation algorithms to solve it. However, what if we assume that the input point are on a line, rather than in an arbitrary metric space? Does the problem become polytime solvable? Can someone link me to reading on this topic?
There is a popular proof for the undecidability of the PCP (Post correspondence problem), which is outlined here: https://en.wikipedia.org/wiki/Post_correspondence_problem I'll assume whoever will answer the question will be familiar with this proof. I have seen this proof elsewhere and this kind of proof always menti...
As I understand, everyone can create logic programming language and system by declaring that the valid program of some logic programming language is the set of statements in the form: body->head, where body is arbitrary expression of boolean type and the head is set of expression that, in some cases, can change the cur...
Are there any standard persistent data structures that facilitate the following? tabulating, for each arc in a rooted, oriented, acyclic multigraph, the set of root-emanating paths containing the arc keeping accurate tallies of path collections as arcs are added to and removed from the graph My research to this point...
I face a problem that is related to (strongly) connected components. Let $G=(V,E)$ be an undirected graph. I want to find subgraphs $G_1,G_2, \dots,G_n$ of $G$ such that they do not overlap (i.e. don't share any nodes) each two nodes in a subgraph are connected by an edge, i.e. $\forall i \forall n,m\in V_i$ then $\{m...
A list of n strings each of length n is being sorted in lexicographical order using the merge sort algorithm. Since we have to take care of comparison of each character in the strings so the merge step would be $O(n^2)$. So the recurrence should be of the form $$T(n) = 2T(\frac n2) + O(n^2)$$ By master's theorem it s...
I built the next automaton: I have problem to prove $L = L(q_0)\cup L(q_1)$, (when $L(q)$ denotes words $w$ such that $\hat{\delta}(q_0,w) = q$ at a given DFA) because semantically $L(q_0)$ is the language of words over $\{a,b\}^*$ which don't start with $a$, and $L(q_1)$ is the language of words which start with $a$ ...
How to approach this question ? I have no idea regarding the method to be applied for solving such kinds of problems .
I am currently learning Supervised ANN training using Backpropogation and I am stuck in this exercise. I calculated the δA using the equation at the bottom of the screenshot, however, I am unable to calculate δB because the weight of BD is not given. How do I find the weight of BD?
I am interested in constructing simple connected graphs where each vertex has a fixed number of edges (degree) ahead of time. I had originally assume I could use some modification of the Havel-Hakimi algorithm to do this, but Havel-Hakimi isn't actually guaranteed to produce connected graphs. Are there any known algori...
The symmetric difference of $L_1$ and $L_2$ is defined to be: $(L_1-L_2) \cup (L_2-L_1)$. Problem: I’m trying to prove that given L a non regular language and F a finite language there symmetric difference yields a non regular language. Although this looks like it should be a very simple problem and it seems very obvio...
I have been exploring Dikstra partitioning Algorithm. Below are my given: R = Red W = White B = Blue I have this unpartitioned array. | W | B | R | W | R | W | B | W | W | I want it partition in the format: R, W, B consecutively. | R | ? | W | B | 0 i j k n Given: i = 0 j = n k = n n ...
What are the reasons that FHE is so slow? Is it possible to make the FHE algorithm so fast that it can be used in practice (say, the practical FHE algorithm should be slower no more than 10 times compared to conventional calculations)? Or there is some fundamental limitation and any FHE implementations will always be ...
In the $F\star$ tutorial it says Dv, the effect of a computation that may diverge; what does diverge mean here? It's not explained and it confuses me. I guess it means the type consists but the value varies, but if so why there isn't a non-diverge non-terminate effect?
If there is an algorithm running in time $O(f(n))$ for some problem A, and somebody comes up with an algorithm running in time, $O(f(n)/g(n))$, where $g(n) = o(f(n))$, is it considered an improvement over the previous algorithm? Does it make sense, in the context of theoretical computer science, to come up with such a...
We have given graph of at most $200$ nodes, we want to split the given graph in two parts, such that the number of nodes with even number of edges is maximized, note that the edges that are between nodes of different parts are destroyed and not counted. All possible splittings are allowed, even the one where all nodes ...
I have the transition matrices of two communication channels. I am able to find the capacity of each by performing an optimization calculation, however I need the total capacity of the two channels. The channels are not weakly symmetric so I don't think I am able to simply add the two capacities. I think what I need to...
I'm trying to decode the following Hamming sequence (using EVEN parity and knowing there is a 1-bit error), which contains an ASCII value: 01100110101 I've tried to check for the correctness of each parity bit: p1 p2 d3 p4 d5 d6 d7 p8 d9 d10 d11 0 1 1 0 0 1 1 0 1 0 1 p1 - 0 1 0 1 1 ...
I am looking for an algorithm(s) that can compute a global ranking (partial ordering) given individual rankings, in some kind of principled manner. I want to establish a partial-ordering of some projects, and had some users create their own partial orderings. I've looked at these algorithms so far: borda-0 borda-1 Dow...
Assume a process execution interrupted at the middle and CPU started executing a different process.How does the OS handle this situation?
Description of the problem: I am modeling checking a distributed protocol against a global property with TLA+ developed by Leslie Lamport. The global property is defined on all states of a behavior (more details can be found below). However, by the nature of exhaustive enumeration of model checking, the state transitio...
Assume we are given a set $X = \{x_1,...,x_n \}$ of size $n$, and a probability distribution $P$ over $X$. I am interested in an algorithm $A$ which can sample from $X$ according to $P$, i.e. $\Pr(A=x_i) =p_i$. More specifically, I assume $A$ can generate a uniformly distributed real number in the interval $[0,1]$ in a...
I'm looking to solve this planning problem. Any pointers or ideas are much appreciated! You have a number of i individuals i = { 1, 2, ..., n } that need to perform tasks. Tasks are performed in teams, with a fixed and given amount of required individuals per task (2,3 or 4). For each individual it is known which task...
In A First Course in the Numerical Analysis of Differential Equations (page 26) Arieh Iserles gives the following derivation: \begin{equation} \frac{\rho(w)}{\ln(w)}=\frac{\xi+\xi^2}{\xi-\frac{1}{2}\xi^2+\frac{1}{3}\xi^3+\mathcal{O}(\xi^{4})}=\frac{1+\xi}{1-\frac{1}{2}\xi+\frac{1}{3}\xi^2}+\mathcal{O(\xi^3)} \end{equat...
Is there a proof that all terms of type $\forall{a}. a$ are operationally $\bot$, in a non-weakly-normalising version of System F? If you ask a free theorem calculator such as this one for the free theorem of $\forall{a}. a$ (written just $a$, as the tool adds implicit $\forall$s for each free type variable), you get t...
I was reading about UDP and TCP. TCP is a stream-oriented, connection-oriented protocol and always delivers the segments in order to the application layer. But UDP being connectionless, does it also always deliver the datagrams to the application layer in order?
According to this answer, a random graph on $n$ vertices is a graph which has each of the $n\choose2$ edges independently with probability $1/2$ each. The probability of at most $3n-6$ edges (which is a necessary condition for planarity) is: $$2^{-n(n-1)/2}\sum_{k=0}^{3n-6}{n(n-1)/2\choose k}$$ Therefore, the plot for...
By what provision is context switching disabled in a process ? Or is it the case that if a process is in in kernel mode , context switching is disabled by default ?
We are given an array A of size n and we have to rotate it in left direction by d positions. So e.g. if A = {1, 2, 3, 4, 5, 6, 7} then for d = 2, the resultant rotated array is {3, 4, 5, 6, 7, 1, 2}. One algorithm which does this goes as follows: Reverse A[0..d-1] (0-indexing) Reverse A[d..n-1] Reverse A[0..n-1] Thes...
I am working on a problem that can be simplified to consist of the following: an initial symbol tree a list of interpretations (an interpretation is a transformation guarded by a predicate) a predicate describing what the target symbol tree should look like Where the goal is to find a path from the initial symbol tre...
Suppose I have $n$ balls. Among them, there are $m \leq n$ black balls and the other $n - m$ balls are white. Fix a random permutation $\pi$ over these balls and denote by $Y_i$ the number of black balls in the first $i$ positions of our permutation $\pi$. I would like to show that $Y_i$ is sharply concentrated around ...
Is it an $NP$-hard problem? You're given an undirected graph $G(V,E)$ with vertex weight $w: V \to \mathbb{N}$ and a function $\mathrm{max}$-$\mathrm{visit}: V \to \mathbb{N}$ and a number $W$. Does there exists a path in $G$ with total weight $W$ that does not visit any vertex $v$ more than $\mathrm{max}$-$\mathrm{vis...
Branch tables are usually described as an efficient way a compiler can implement a switch statement, and that actually seems how GCC and Clang do it (and LLVM even has an opcode just for that). If a sequence of if statements is used (instead of a switch), GCC doesn't seem to generate a table, but Clang still does. Give...
Is it an $NP$-hard problem? You're given an undirected graph $G(V,E)$ with edge weight $w: E \to \mathbb{N}$ and a function $\mathrm{max}$-$\mathrm{visit}: V \to \mathbb{N}$ and a number $W$ in unary. Does there exist a path in $G$ with overall product of edge weights equal $W$ and that does not visit any vertex $v$ mo...
I came across this circuit that swaps logical signals: However I don't understand why would you need to use logic gates. Would it be possible to just connect the A on the left to the B on the right and the same with the B on the left (maybe add a diode to prevent current from going back?). And one last question; would...
I am following the quicksort analysis in CLRS (pp. 181-184, 3rd edition). Let me summarize the setting of the analysis. Setting in CLRS First let $Z = \{z_1, ..., z_n\}$ be the set of elements of the input array $A$ in sorted order. $X$ is defined as the number of comparison we make (i.e., between pivot and an element)...
I fail to see a contradiction in the halting machine proposed by Alan Turing. Definition of halting machine Where H = all possible programs that terminates N = all possible programs that do not terminate $N_p$ = a program that does not terminate e.g.while True do x:=0 T = true F = false if a program outputs T or...
I'm doing this course: Engineering: Algorithms1 - SELF PACED Algorithms: Design and Analysis, on Stanford's website. And the first assignment asked us to count the inversions in an array. The idea that they used was: Break the original array in half. Count the inversions in each half Pass the original array through me...
I am currently in the process of writing an IB Extended Essay on the efficacy of multithreading on increasing the performance of applications. So far, I have been able to deduce that there are three main multithreading techniques: Cooperative/Coarse-Grained/Block Multithreading Preemptive/Fine grained/Interleaved Mul...
my solution is that $L\in co-RE$ by showing that $\overline{L}\in RE$ TM $M$ on input:$\langle M_1,M_2,w\rangle$ Build TM $M_1,M_2$ Simulate $M_1$ on $x\in\Sigma^*$, before that check if $x\neq w$ If $M_1$ accepts some $x$, than Simulate $M_2$ on $x$ If $M_2$ accepts than $M$ accepts. If $M_2$ reject, that we back at ...
I'm asking the question here because it's not a purely mathematical question and the answer also depends on how computers work. I think that according to the Wikipedia article Bailey–Borwein–Plouffe formula, there is a spigot algorithm for quickly computing in terms of any natural number $n$ expressed in binary the $n^...
So in this math exchange question I asked, it was proven that for $n>2$ dimensions, you can always find a curve that separates $k$ points in $n$-dimensional space into $2$ arbitrary sets that you pre-defined. What I wanted to know is if there is a polytime algorithm (polynomial in $k$) for determining this curve. If so...
Let's I have to make the following reduction: $$\text{CLIQUE}\le_p \text{VERTEX-COVER}$$ The technique of building the reduction is - Assume you can find a $\text{VERTEX-COVER}$ of size $k$, in polynomial time. Building a new graph, in which I say that if a $\text{VERTEX-COVER}$ exists of size $k$, then in the origina...
I know I must be getting stuck on notation. However, I'm having trouble following the logic in Example 1.2 in https://arxiv.org/pdf/cs/0611018.pdf. They define what preserving a propositional formula means. So, I'm trying to understand a basic example. Take X = A or (Not B) or (Not C) as an example Horn Clause. Defi...
Let $L$ denote the (context-free) language of matched parentheses over the alphabet $\Sigma$. Consider the following problem: Input: words $x_1,\dots,x_n \in \Sigma^*$ Question: does there exist a permutation $\sigma$ of $\{1,\dots,n\}$ such that $x_{\sigma(1)} x_{\sigma(2)} \cdots x_{\sigma(n)} \in L$? What is the co...
I am looking for a data structure to store a set such that given two instances of size $O(n)$ which are known to have non-empty intersection, the minimum element of the intersection can be found in $O(\log n)$ time. Is this possible to achieve, either for worst-case or amortized complexity? Other requirements for the d...
Given a cycle of $n$ vertices and each vertices of the input graph $G$ assigned a weight. We want to find an independent set of cycle such that weight of the vertices taken in the independent set is maximum. A brute force way is consider cycle as a set of three consecutive vertices and pick the one with max weight, bu...
Subject reduction is a well and widely used property of typed rewriting systems. Subject expansion is much less known. What are the applications of this property and which systems enjoy it?
I have an array of length $n$ representing a time series of data. I want to implement a moving (sliding) window of length $k < n$ and calculate things like sliding median, sliding quantile, sliding trimmed mean, etc. Each of these requires the data to be sorted prior to calculating the statistic of interest. Therefore ...
I am looking for a suggestion. I know it is possible to construct a binary tree from an array. I want to know that vice verse is true? Is it possible to construct an array from a binary tree? If yes how could I construct it? Any well known algorithm for that? I am looking for suitable datastructure in Java. Thank you i...
I can't understand why $\epsilon$ is accepted. I thought if $\epsilon$ is inputed then it would go from $q_1$ to $q_3$. $a$ is also accepted, but I though if $a$ is inputed then then the NFA would die, because in $q_1$ there's no where to go. I read on another post about $\epsilon$ being at two states at the same time...
I want to pick k objects from a pool of n. Not any k objects, the optimal k objects: that which minimizes the cost of the set, defined as the sum of pairwise costs for all pairs within the set. What NP-complete/hard problem is this an instance of? What is a good (i.e. fast but finds a low cost) way to solve this proble...
With the randomised algorithm for Pi approximation (see https://www.geeksforgeeks.org/estimating-value-pi-using-monte-carlo/ ), I keep wondering why just using points with an even distance should'n work just as fine. Obviously, with the montecarlo method you get a better approximation the more random points you generat...
The problem: This is a reduced version of a problem I currently have. I have a list of edges as input. This list contains the names of 2 nodes (the edge connects these 2 nodes) and 2 x 2D coordinates (which is the start and the end of the edge). The nodes can be in an arbitrary order, and the whole list can contain dup...
I was taking course on compilers by Alex Aiken. You can find the slide discussing handles on this page. On the page of the slide, the instructor defines handle as follows: Assume a rightmost derivation $\require{AMScd}$ \begin{CD} S @>{\text{*}}>> \alpha X\omega @>{}>>\alpha\beta\omega \end{CD} Then $\alpha\be...
Question is: Calculate the minimum absolute difference between the maximum and minimum number from the triplet a, b, c such that a, b, c belongs arrays A, B, C respectively. There is another question: Find i, j, k such that : max(abs(A[i] - B[j]), abs(B[j] - C[k]), abs(C[k] - A[i])) is minimized. Return the minimum ma...
What is the regular expression for language containg no. of 011 equal to 110 in string ?
I am attempting to implement IDAstar and so just need to double check my reasoning. Suppose I am trying to solve the following pancake sorting problem using IDA-star assuming all operations have a cost of 1 and assuming that I am using the zero-heuristic: start state= 1 0 2 3 4 5 goal state= 0 1 2 3 4 5 I believe t...
everybody, I'm trying a whole day to compute this recursion. I will be grateful if someone can try and solve it $$T(n)=2*T(n/2)+2/\log(n),$$ where $\log n$ is the logarithm to the base 2 - of course! thanks!
A disk pack has 12 platters ( plates) having 2048 tracks on every surface. It can store 1024 bytes per sector ( assume each track has 512 sectors). Calculate the storage capacity of this disk in GB.
There is an NP-hard problem called Minimum k-Union where we are given a set system with $n$ sets and are asked to select $k$ sets in order to minimize the size of their union. I'm currently interested in a very similar problem, but don't know how to convert one to another: Given a set system with $n$ sets and a bound $...