instruction
stringlengths
35
29.1k
I tried many grammars and so far I got this one: \begin{align} &S \to aXbZ \mid abc \\ &XZ \to Ybcc \\ &Xb \to bX \\ &bY \to Yb \\ &aY \to aa \mid aaX \end{align} Is my grammar correct? Is there a simpler one?
I have 2 max-flow function f1,f2 that are different from one another (atleast on a single edge). I know they give each edge a natural even value. I constrct 2 types of average functions: A)$ g (e) = (f1(e)+f2(e))/2$ B) $h(e)=f1(e)*1/3 + f2(e)*2/3$ I want to prove or disproof their being max flow functions too. My thoug...
I have an $MST$ tree $T$. I increase the weight of a single edge $e$ by $c$(a non negative constant). I need to recompute an $MST$ as fast as i can. How I do this? The idea I had in mimd is to remove $e$ from $T$. Loop over all crossing edges between the two "halves" of $T$. See which one is minimal weight. Add her ins...
found this question online and I am trying to solve this question. I have solved this question but I think I might be missing some cases. Could someone verify if my answers are correct? Let N = (Σ ∪ {λ}, Q, δ, q0, {qf }) be a λ − NFA and let L = L(N) be the language accepted by N. For N assume q0 has no incoming transi...
I have a question about the pumping lemma for context-free languages. I understand the conditions of the pumping lemma. Assume $L$ is context-free. Let $n>0$ be the pumping length given by the lemma. $z=uvwxy$ with conditions: $|vwx|\leq n$ $|vx|\geq 1$ $\forall i >0, \exists z= uv^iwx^iy \in L$ But i need to kn...
In every group chat of six (distinct) people on Instagram, there is a group of three (distinct) people such that either: everyone in the group are friends everyone in the group are strangers (i.e not friends). Let $F(x,y)$ be a relation that denotes that $x$ and $y$ are friends on Instagram. Translate the statement...
I've read Chapter 5, Syntax Directed Translation, of the Dragon Book but am still unable to understand the following related points: How to handle L-attributed SDDs in an LR grammar when using a tool such as Bison? I believe, the book says that inherited attributes could be used with an LR parser (via Marker symbols?)...
I don't understand the last para. I corrected its typos. Please explain like I'm 5. If micro-kernels can be big, and monolithic kernels can be small, doesn't this size gradation collapse the distinction between monolithic kernels and micro-kernels? Is this what a hybrid kernel means? So.. that's the ELI5 version. Thin...
Let's say we start with $i = 1$, $j = 1$, $i \leq n$, and $j \leq i$ and then increment $i = i+1$ and $j = 2j$, respectively. The output prints $k$ times, which represents the inner loop. Output: print s $k$ times. Example when $n=5$, loop will print 11 times. How to find the complexity function of this algorithm for...
I am still trying to get my head around what is valid CNF and how distribution works, I am not even sure if the examples I have tried to convert are correct for one, but I am also unsure of the rule for distribution and when I have looked at other posts here it seems so complicated and the actual rule does not seem to ...
I am told to solve the recurrence $$T(n)=10T(n/9)+n\lg(n)$$ using the Master theorem. I then try to use case 3. However, I am unable to show that for $f(n)=n\lg(n)$ then $10f(n/9) \leq cn\lg(n)$ for $c < 1$ and all sufficiently large $n$. Is it wrong to use case 3? Or does the Master theorem even apply?
I understand that in a non-deterministic automaton, an input can lead to one, more than one, or no transition for a given state. Given this information, I would assume that if the input lead to a loop, this loop would be infinite until a determined input happened (being one || more || ε). However I would like to know i...
Is the language $\{wxw^Rx^R \mid w,x \in \{0,1\}^* \}$ context-free My thoughts, Let $x = \epsilon$ and we get $ww^R$, which is context-free. Hence the given language must be context-free. Am I right?
I am using language as a placeholder although I think it can be used in music too. I am unclear if the frequencies are given based on the text or the entire language. The latter would prove to be difficult because if we are to say that 'e' is the most common letter in English, wouldn't this shift over time with some ne...
I have to figure out the frequencies of 3 letters for Huffman encoding of {0, 10, 11}. One suggestion is in the order {$\frac{2}{3}$, $\frac{1}{6}$, $\frac{1}{6}$} as given in part (a) the 2nd slide of page 3 here. My question is whether the last 2 character frequencies need to be evenly split. Could we not have had {$...
In a weighted graph $G(\mathcal{V},\mathcal{E})$ where $w(i,j)$ is the weight of the edge $(i,j) \in \mathcal{E}$. How can I find a maximum weighted matching with a specific size (i.e specific cardinality).
I have a simple question regarding reduction using K-Maps. My professor gave this example: While I somewhat understand that we can only group quantities of base 2 numbers, why did my professor group the K-Map values like the image above instead of the image below (what I drafted): Why did my professor include element...
David Harel's StateCharts introduces hierarchical states and history mechanism, which are really powerful when modeling complex system behaviour. But when doing model based testing we need a "flattened state machine", that is an equivalent state machine without any hierarchy. By googling around I found this paper by Wa...
So I have the question: show "Show $\{0^1^|≠\}$ is not regular". I've already seen various proofs for this question, but they all have one step I don't get. They all take: $\bar{L}∩(0^∗1^∗)$ ($\bar{L}$ is the complement of $L$) and show that it's not regular. I don't get why we can't just take $\bar{L}$. Because isn't ...
I am trying to understand the proof of the master theorem and I came up with my own proof for why (4.23) is true. My argument is as follows: Claim: $g(n)=O\left(\sum_{i=0}^{\log_{b}(n)-1}a^i(n/b^i)^{\log_b{a}-\epsilon}\right)$. $$g(n)=\sum_{i=0}^{\log_{b}(n)-1}a^if(n/b^i)$$ Now by the definition of big O, we have that...
This is a GATE 2021 exam question. If the numerical value of a 2-byte unsigned integer on a little endian computer is 255 more than that on a big endian computer, which of the following choices represent(s) the unsigned integer on a little endian computer? A. 0x6665 B. 0×0001 C. 0×4243 D. 0×0100 According to me, answ...
May anyone explain me why $\forall x \in \mathbb{N}\ \Phi(x,x)$ is unary but $\Phi$ is binary? In my latest exam I wrote that the universal function $\Phi^n(x_1, x_2, ..., x_n,y) = \psi^n_y(x_1,x_2,...,x_n)$ is unary because its $n+1$ parameter is a constant referring to the number of the S-program ($y$), but my teache...
Given that array has $k$ elements (all distributed uniformly). Its length is exactly $3$ somewhere in $[0, k)$. For example, if $k=100$ then, we have $100$ numbers and they can be in $[10,13)$, but they can also be at $[89,92)$ I need to offer a sorting algorithm, which is efficient. Now, my idea was Bucket Sort, but w...
Let $\forall n \in \mathbb{N}\ \ P(n)$ a primitive recursive predicate such that $\neg P(n)$ for a finite number of values of $n$. Why this function: $$ f(x) = \begin{cases} 1 & \text{ if there are at least $x$ numbers $n$ such that $P(n)$}\\ \uparrow & \text{ otherwise} \end{cases} $$ is a recursive primitive functio...
Any help will be appreciated, as I wasn't able to find much about it online in the last few days and I can't seem to write a suitable recurrence relation for this kind of functions.. Are there any tips or general guidelines for calculating the complexity (time/space) for functions of the following form? int f1(int n) {...
I am trying to figure out the solution of the recurrence relation $$T(n) = 5T(n/3) + n \log n$$ using the Master Method. I am guessing that $f(n) = O(n^{1.46 - \varepsilon})$, but I am confused in the part that $\frac{n \log n}{n^{1.46}}$ must be polynomially smaller. If something is polynomially smaller does it mean i...
The paper “Where the really hard problems are” (https://www.ijcai.org/Proceedings/91-1/Papers/052.pdf) and others that cite it provide evidence that lots of algorithms for many NP complete problems (when suitably parametrised) perform poorly on the problems that lie on the phase transition from under constrained to ove...
I am trying to solve this by using Substitution method. My solution must work both for even n-s and odd n-s. For evens case I have solved it. But for the odd's case I am stuck at this point. Hot to continue?
I have the vocabulary $\tau = \{+, 0 \}$ and the structure $R = (\mathbb{R}, +^R, 0^R)$ where $+^R$ is a binary function symbol representing the normal addition of numbers and $0^R$ is the constant $0$ in $\mathbb{R}$. I 'm trying to prove that the bijection $$\sigma : \mathbb{R} \rightarrow \mathbb{R} \text{ with } \s...
The following algorithm for computing the number of nodes in a linked list appears in this thesis on common algorithms in the PRAM model for parallel computation. The author then argues that this is a $log(n)$ time algorithm (where $n$ is the number of nodes in the list) because the span of nodes covered by the "far" ...
I am given a sorted array with n integers. All of the elements repeat exactly twice, while there is one element without duplicate. I need to solve it as efficient as it is possible by divide-and-conquer algorithm. I have noticed that n needs to be odd to satisfy my condition. I thought about doing this: divide my array...
Is there a way to generate a bijection over integers $F : [0..n) \rightarrow [0..n)$ that satisfies the properties: $n$ is arbitrarily chosen and can be any positive integer $F$ generates a pseudorandom, potentially biased permutation of its domain $F$ is seedable and can be easily influenced to generate a different r...
can someone explain what the following notation is? For j <- 1 to n Legal <- True I've seen these in various places, including wikipedia articles. It seems to be a specific notation, but I don't know the name and can't find much of anything on it. Can someone explain what it is, where it's used, if it's in widespr...
When $\overline{M}$ is a non-deterministic polynomial by time Turing machine that final states switched: accept to reject and vice versa. I'm thinking that this equal to $P=NP$, but I saw a solution (an example) that I disagree with: $M$ is a non-deterministic polynomial by time Turing machine that decide $SAT$, if all...
I was trying to store a Huffman tree in a binary file recently. I thought it wouldn't be a big problem since you actually have the binary codes already in front of you. Well, the difference is that the file (in the hex editor) is logically coded in hex. So I tried to convert the "characters" from binary to hex. Without...
Given an arbitrary CPU - Architecture and its instruction set... What would be the outcome of the given inverted instruction within that Architect? For simplicity, let's use an 8-bit CPU architecture that has an 8-bit Bus design where that bus is used for both addressing and data transfer operations. A single instructi...
if given a language $L$ recognized by NFA $N_0$ over an alphabet $\Sigma$. Is it possible to find a general way of constructing an NFA $N_1$ that accept $L^C$ such that $L^C= \{w \in \Sigma^{*} |\mid w \notin L \}$?
Given a string s and an int k, return an int representing the number of substrings (not unique) of s with exactly k distinct characters. If the given string doesn't have k distinct characters, return 0. Input: s = "pqpqs", k = 2 Output: 7 Explanation: ["pq", "pqp", "pqpq", "qp", "qpq", "pq", "qs"] I have this solution...
I sort of know how to solve the problem but I am not sure how to do it in a systematic way. Could someone provide a step-by-step solution especially for the follow set one? Thanks!
So I get this through the math behind the SVM (Support Vector Machine), and I get this formula $$(w^T)(x_1-x_2) = 2.$$ We then divide both side with norm of $w$ then we get the new formula $$ \frac{w^T}{\|w\|}(x_1-x_2) = \frac2{\|w\|}. $$ Why do we divide by the norm of $w$ in both sides?
Can somebody help me with the formula needed to calculate the number of weights for a CNN, using the following sample question as the basis for it? Suppose we have a convolutional neural network with a 5x5x1 input volume, followed by one convolutional layer with 5 filters that have a 2x2x1 receptive field, followed by...
I had a question about a general statement regarding finding a computationally indistinguishable distribution given any distribution, observed (in the third paragraph of Section 11, page 31) here. This is the statement: For any distribution $D$ over $\{0,1\}^{n}$, there exists a distribution $D'$ such that $D$ and $D'...
The $\Leftarrow$ direction is straightforward. On the other hand for $\Rightarrow$ direction I have an idea of the prove but I don't sure about it. For NTM, Non Deterministic Turing Machine, $M$, for example TN that decide $SAT$, $L(M)=L(\overline{\overline{M}})\in NP$. It's clear that exists NTM $M'=\overline{M}$ such...
having problems with big oh and big omega functions when there is a $\log n$ added or subtracted. For example how do I deal with $n+\log n$ or $n-\log n$ when I have to determine whether the function is in $\Omega(n)$ or in $\Omega(n^2)$? For example, is $n-\log n$ in $\Omega(n)$ or in $\Omega(n^2)$? I cannot ignore th...
Support Vector Machines turn machine learning linear classification tasks into a linear optimization problems. $$ \text{minimize } J(\theta,\theta_0) = \frac1n \sum_1^n \text{HingeLoss}(\theta,\theta_0) + \frac{\lambda}{2} ||\theta||^2 $$ My question is, what linear programming runs on the background for the minimizati...
Let $\Sigma$ be some alphabet. We define the following operation on the set of all languages over $\Sigma$. The operation $\mathrm{3MAJ}(L_1, L_2, L_3)$ takes in three languages $L_1$, $L_2$ and $L_3$ and outputs the language of all words that are members of the majority of the input languages. Formally: $$\mathrm{3MAJ...
How would the following term in the pure untyped lambda calculus be parsed: y λx.x y The relevant conventions listed on https://en.wikipedia.org/wiki/Lambda_calculus_definition#Notation (as well as many texts on this subject) state: Applications are assumed to be left associative: M N P is parenthesised as ((M N) P) T...
A relation on two sets $A$ and $B$ is defined as the subset of the cartesian product $$A\times B = \{(a,b),\ a \in A, b \in B\}$$ A database is also a relation and each entry is an ordered tuple respecting the cartesian product. Now, interchanging the rows and the columns of a database does not change it. I can underst...
I think Option C is false. Following is my thought process: Starvation in general mean Process is waiting indefinitely for the resource or to get scheduled etc. [A/c to Galvin Book]. So, here in this question, Any process needing any resource at any point can call the OWNRESOURCE function and process will surely get t...
I'm using the grammar scheme of Danielsson and Norell ("Parsing Mixfix Operators"). The short version is: user defined mixfix operators such as _+_ or if_then_else_ the precedences form a DAGs it is known that this creates an unambiguous grammar if the operators don't share lexical tokens otherwise, input gets rejecte...
I'm new here, and I'm currently trying to understand why mod operation can be used as a hash function. For example, consider the function $h(x)=x\mod 2^{256}$, where $x$ can be a string of any length. The book says that this function will return a fixed size of 256 bits. To my understanding, $h(x)$ will return an integ...
This is an overall system design and DBMS question: If the user books a ticket or an item on a website, how do we solve the issue of confirming a ticket is sold to the user, but the main Database System breaks down, and the secondary DMBS doesn't have that information yet? Is the most common solution just to not commit...
Problem 1: Consider the following problem: given a binary string $w=a_1a_2\cdots a_n \in\{0,1\}^*$, decide whether $w$ contains 00000 as a substring (i.e., where $w$ contains five consecutive 0's). There is an obvious $O(n)$-time algorithm. You will investigate the hidden constant factor, concerning the number of bits...
I started watching SICP lectures and am totally new to computer science. SICP. LEC 1B: Procedures and Processes; Substitution Model I don't know why the time complexity of the Fibonacci sequence is O(Fib(n)). So, I googled about it, he says There's a thing that grows exactly at Fibonacci numbers. It's a horrible thing...
I'm trying to figure out how to make the action table for a Turing Machine computing $⌈\log_{2}(n)⌉$. The input and output shall be unary (meaning $3$ should represent $111$). I can only deal with 1 tape. Also, I would prefer having 7 transition states, 1 final state, 24 actions and 5 symbols, but any other numbers are...
Is there some kind of "universal list" of performance of different algorithms in different situations? I have different databases that save user input (numbers). However some of these sets of numbers are small and some of them are really big (such as the common one). There are negative numbers included. I remember from...
For clarity, I'll claim the supposed impossible program to be 'Code X'. Something doesn't seem to make sense about the proof against Code X: Consider a code that halts if you input oranges, but doesn't if you input apples. The answer to whether it halts is in this very obvious case is that 'it depends'. So either this ...
I faced a problem that looks very hard, the problem is this: We have 5 people putting dots on a whiteboard, each person uses colored dots with a different color (there are 5 colors, 1 for each person). My job is to find a cluster of points which contains 3 or more distinct colors. Also, we have some fixed radius $R$,...
I have a given fully-connected undirected graph associated with (known) distances or alternatively a distance matrix, where the nodes or matrix rows/columns represent locations. Additionally, I have a number of items smaller or equal to the number of locations, as well as a finite number of traversal paths for the item...
Assuming I have an Oracle that takes as input a strictly 3SAT Boolean instance and states whether the instance is satisfiable or not. If it says instance is unsatisfiable then the instance is unsatisfiable. If it says instance is satisfiable there is a 57% chance the instance is satisfiable and a 43% chance that is uns...
I'm trying to figure out if there is an algorithm which can solve the following: Given an array of randomly generated values, for example: $$[54.6, 1.96, 5.0, 31.31]$$ Find an array of equal length, in this example $[x_1, x_2, x_3, x_4]$ such that: $$54.6 \cdot x_1=1.96\cdot x_2=5.0\cdot x_3= 31.31\cdot x_4$$ and $$x_1...
How would you construct a Turing Machine that calculates log2(n)? The process must take in an input such as 4 and output the result in a unary format such as a 11 (11 = 2 in unary)? In the final output tape, the tape should only contain blank symbols followed by a consecutive number of 1's from the final head position....
I'm trying to prove the running time of heapsort on an array sorted in decreasing/increasing order is $\Theta(n\lg n)$ in order to show that the worst-case running time of heapsort is $\Omega(n\lg n)$ The site here https://courses.csail.mit.edu/6.046/fall01/handouts/ps2sol.pdf mentions : The running time of HEAPSORT o...
In a set system $(U, F)$, $F\subseteq \mathcal{P}(U))$, we say that a function $f: U \to \{0, 1\}$ is a coloring of $(U, F)$. A set in $F$ is split by $f$ if $F$ receives both colors. The Set Splitting problem is defined as follows: Given an set system $(U, F)$ and an integer $k \in \mathbb{N}$, does there exists a ...
Suppose you are given two sets of integers L and M both having N elements. The problem is to match each number in L to a number in M. Such perfect matching has some cost given by $\sum_{i=1}^{N} l_i*m_i$. I want to find some perfect matching with some given cost. I suspect that this is hard (i.e. NP-complete). Can you ...
If $x \in L$ only if $x \in A$ and $x \in B$, where A is an NP problem and B is a coNP problem, I cannot place $L \in NP$ or $L \in coNP$ without implying that NP = coNP right?
I have the following code which I have to figure out the recurrence relation, but I am having a bit of a trouble understanding what the algorithm does exactly. Interesting-Product(A[1..n]) if n = 1 then return for i := 1 to n/3 do A[i] = A[i]*A[i+(n/3)] Interesting-Product(A[1..n/3]) for j := (n/3) + 1 t...
I saw this question Can I simplify log(n+1) before showing that it is in O(log n)? and wanted to know if a similar situation was also true. Namely, is $\log(n-1) \in \Omega(\log(n))$?
I'd like to monitor divergence/diversity in my swarm during the particle swarm optimization algorithm to measure when the swarm search space is converging. This would be used as one metric to be recorded during the run and potentially to terminate the PSO process when not much further progress is to be expected. Is the...
I have been looking for a while but I cannot find an algorithm for a particular generalisation of sequence alignment. I have two posets $(A, <)$ and $(B, <)$ and a similarity score $s(a, b)$ for all $a \in A, b \in B$. I wish to find a maximal scoring alignment such that both partial orders are respected. An alignment ...
The Wikipedia definition of the decision tree model says that it allows the sign functions of certain classes to be computed in constant time (and presumably also memory). My questions, still unresolved by reading the article, are: Can those functions be fed any values computed by the algorithm (including ones of asym...
I am learning this topic and there is a concept that LSB ( bit ) of MSB ( byte ) should be set to 1 for multicasting . But why we need to do so as multicast address is unique so why can't we assign any multicast address which is not present in that network.
Can someone tell me if this works? It seems to be easier to implement and also creates slightly less paths (though still O(log N) ). The problem: given any tree of size N, find a way to split it into some disjoint paths such that from any node, you can reach the root by passing through log N paths. Heavy light decompos...
Let's say you have a binary tree defined by a group $S=\{a:[5,6],b:[7,67],c:[45,12],...\}$ (this group is just an example). The binary tree is constructed so that there are two starting parent nodes, $a[0]$ and $a[1]$. Each of those nodes have two child nodes $b[0]$ and $b[1]$. Each of those nodes ($b[0]$ and $b[1]$ fr...
Let's consider we want to calculate a[i]=a[i]*c for a vector the size of N=12 on some random processor. We do assume that c is some given constant already present in the register. We do not consider any superscalarity or vectorization. We also know the latencies for the following instructions: Load operand to register...
How to simulate two counters using one (FIFO) queue? (In terms of algorithms, unary stack.)
Let G = (V,E) be a directed graph, where V is a finite set of nodes, and E ⊆ V × V be the set of (directed) edges (arcs). In particular, we identify a node as the initial node, and a node as the final node. Let x and B be two non-negative integer variables. Further, we decorate each edge with one of the following four ...
Suppose you're given this KB: $$KB = (A, A ⇒ B, A ⇒ C, B ∧ C ⇒ D)$$ How would you show using a SAT solver that $KB \vDash D$?
Question For any string $\sigma$ over alphabet $\Sigma$, we define the operation $\texttt{MOVE}$ as following For $\sigma = aw$ ($a \in \Sigma, w\in \Sigma^*$), $\texttt{MOVE}(\sigma)=wa$ This is equivalent to moving the starting symbol to the end. For example, $\texttt{MOVE}(10110)=01101$. Show that for a regular la...
How do you go about solving the following problem that tries to match the greatest number of clients with servers with constraints? I'm trying to identify an algorithm or simulation that could help me solve this problem as optimally as possible. Assume you are given a 2d map of servers and clients randomly scattered. E...
I'm looking for algorithm that, for given undirected graph $G=(V,E)$, find graph $G'=(V,E')$ with minimal amount of edges that have same vertex cover as G. I mean, vertices $U$ are vertex cover of $G$ iff they are vertex cover of $G'$. I understood that a polynomial algorithm exists, it's mean without finding the verte...
I know why cases 1 and 2 are wrong because our language can have different numbers of 0's and 1's. But I'm not sure how case 3 can be proved wrong for our language. Exercise 1.30: Describe the error in the following “proof” that $0^{∗}1^{∗}$ is not a regular language. (An error must exist because $0^{∗}1^{∗}$ is regula...
I want to know why the distances between nodes in a minimum spanning tree seems to be rooted to the node with highest degree. A bit of context here: I have spatial explicit weighted network that describes the physical growth pattern of a fungal colony. Most of the nodes in this network have either degree = 1 or degree ...
I have two functions. a and b. Both have linear complexity O(n). fcn a (items) loop items -> item ... fcn b (items) loop items -> item ... loop items -> item ... loop items -> item ... Though b obviously takes 3 times longer to run than a for the same input. Is the...
I came up with the idea finding a k-clique through starting at a small s-clique (like 1-,2- or 3-clique) and use it to find every s+1 Clique iterative. I had some trouble finding the Time Complexity and I am not sure where I might have went wrong. First I will show the algorithm, argue about its correctness and then wh...
This is a follow-up to post Perfect matching problem, where nir proved weak NP-completeness. Suppose you are given two sets of integers $L$ and $M$ both having $N$ elements. We want to match each number in $L$ with a number in $M$. Such perfect matching has some cost given by $\sum_{i=1}^{N} l_i*m_i$. The problem is to...
I have a question related to design, implementation of programming languages. I hope it fits here and apologize if it doesn't. All or most programming languages version modules (aka packages, libraries, crates). All the entities in a module (types, functions, variables and other information) share the same version with...
Suppose there's a program A that decides whether or not every program halts. Then we could construct program B that invokes A and does the opposite. Do I halt? If so, loop. Do I loop? If so halt. That shows we cannot construct program B. HOWEVER, that assumes B can be embedded in A. Could there exist a program B that d...
The question requests to find the recurrence relation of the following algorithm and solve it using the characteristic equation. \begin{align} &\text{SORT}(A[0\dots n-1])\colon\\ &\quad \text{if } n = 2 \text{ and } A[0] > A[1] \text{ then} \\ &\quad\quad \text{swap}(A[0],A[1]) \\ &\quad \text{else if } n > 2 \text{ th...
I have the following regular expression $R=ab^*(\epsilon \cup c) \cup c^*a$ and I want to construct the NFA that accepts languages defined by that regular expression. I started by constructing the NFA that accepts $R=ab^*(\epsilon \cup c)$ Next I tried to continue the concatenation part by adding the following to the ...
I graphed the functions and when $n_0$ is greater than $3$, $cg(n)$ is always greater than $n^2 \log n$ so it would seem to me by definition that $m^2 \log n$ is in $O (n^2) $. I tried to prove it by dividing both sides of inequality by $n^2$ . The $c \ge \log n $. As n tends to infinity there will be values of c that ...
I have a large set of $(X)$ hospitals and $(Y)$ homes, where $(Y)$ is much larger than $(X)$, and their respective coordinates. Each hospital can handle any home within a 50 mile radius, and up to 10,000 homes. Homes can be assigned to one hospital. How do I create assignments of homes to hospitals such that as many ho...
I am trying to come up with less than and less than or equals operators for a Map where values are Sets. These are the hints I was able to get from the Professor. {A -> {1,2}, B -> {3,4}} < {A -> {1,2}, B -> {3,4}, C -> {5,6}} {A -> {1,2}, B -> {3,4}} < {A -> {1,2}, B -> {3,4,5}} My solution was this: val v_compare ...
Let $L\subseteq\Sigma^*$ be a language, where $\Sigma$ is a set, and let $n\in\mathbb N$. I am wondering if there is some good terminology for $L\cap\Sigma^n$. Of course I could say "the set of words in $L$ of length $n$" but maybe there is some special terminology like "level set of length", "grade", "homogeneous se...
Definition: Let $T(V, E)$ be a rooted tree with root $r$. If $T$ has no other vertices, then the root by itself constitutes the preorder traversal of $T$. If $\lvert V \rvert > 1$, let $T_1, T_2, \dots, T_k$ denote the subtrees of $T$ from left to right. The preorder traversal of $T$ first visits $r$ and then traverses...
In step 2 (expansion) of the Monte Carlo tree search algorithm, one or more child nodes are created, and one node named C is chosen among them. The simulation step is applied to C giving it a score of 0/1 or 1/1. What happens to the other newly created leaf nodes? I assume they get a score of 0/0, which will not work v...
I have been working on the following homework question, and I just can't seem to make any progress: Construct a finite automaton having fewer than 36 states that recognizes the language $\{s \in a^* : \operatorname{gcd}(|s|, 504) \geq 6\}$, where $|s|$ is the length of $s$. So far I have been trying to figure out a r...
Can anyone suggest a starter book or website where I can find information and examples of putting functions under summation signs into Big Theta. basic Arihmetic , geometric, Quadratic are fine , but I would like to work on examples like $$\sum_{i = 1}^{\log n} i \cdot n \text{ or } \sum_{i = 1}^{\log n} 10^i$$
Immediate Smaller Element Problem: Given an integer array arr of size $n$. For each element in the array, check whether the right adjacent element (on the next immediate position) of the array is smaller. If next element is smaller, update the current index to that element. If not, then update it to –1. Input: arr[] ...
I am doing an exercise which says that this is true: T(n) = 2 + 2T($\frac{n}{4}$) = O($\sqrt{n}$) So I tried to solve it by substitution, but I am getting a non-sense result. So would really appreciate some pointer in the right direction. So I want to show it for $\frac{n}{4}$ (sub-question, I am picking $\frac{n}{4}$ ...