instruction
stringlengths
35
29.1k
I tried to do the problem Find first set bit in Geeks for Geeks, and this is the code I used. public static int getFirstSetBitPos(int n){ int counter = 0; while (n > 0){ if ((n&1) == 1){ return counter + 1; } n >>= 1; counter ++; } return 0; } The problem as...
The bin packing problem is an NP-hard optimization problem that has many constant-factor approximation algorithms. I am looking for an additive approximation. I.e., given a set $I$ of items and bin capacity $B$, find a packing in which the number of bins is at most $OPT(I,B)+d$, where $OPT(I,B)$ is the optimal number o...
I was going through the topic of matroid structures for the problems like Activity selection ,minimum spanning tree. I also came to know how to solve if a problem exhibits matroid structure. The statement says that problems that have matroid structure will have a greedy algorithm. But by just showing matroid structure ...
I'm trying to implement conditional probability distribution when the events of two RVs are sets. If I try to extrapolate concepts from real or categorical variables to sets things become confusing for me. In the usual scenario, for some pair of discrete RVs, $X,Y$, we can compute the conditional probability of two "pu...
I'm reading section 19.3 of Combinatorial Optimization by Schrijver where he details an algorithm for finding the min-weight edge cover. His method works for general graphs, but I'm particularly interested in bi-partite graphs. To find the min-weighted edge cover of a graph $G=(V,E)$ with a weight function $w: E \to R$...
Now I'm from a mathematical background, and I found CS people's definition of average time complexity a bit... confusing, to say the least. Here is a definition that I feel comfortable with: Consider a set $A$ of finite elements, with each $a\in A$ indicating individual input cases. There exists a function $T(a)\mapsto...
Question: Given two sorted sequences in increasing order, $X$ and $Y$. $Y$ is of size $k$ and $X$ is of size $m$. I would like to find a subset of $X$, $i.e$, $X'$ of size $k$, and considering the following optimization problem:$$d(Y,X') = \sum_{j=1}^{k}(y_{j}-x'_{j})^{2}$$ And $X'$ is a subset of $X$ of size $k$, $y_{...
Galvin and various other resources only allow either the producer or the consumer to access the buffer at a time, the common code is as follows: //Producer code While(true) { down(empty); down(mutex); buffer[in] = item; in = (in+1) % buffer_size; up(mutex); up(full); } //Consumer code ...
This is a variant of this question. Consider two probability distributions $D$ and $U$, over $n$-bit strings, where $U$ is the uniform distribution. Assume that $D$ and $U$ are far apart in total variation distance, ie, \begin{equation} d_{\text{TV}}(D, U) \geq \frac{2}{3}. \end{equation} We are not given an explicit d...
I'm currently dealing with inverted page tables and how they work. If I understood correctly, an IPT is a table that maps a frame number to a PID and page number. The way this works is by having a hash function map a tuple (PID, page_number) to (frame_number). If the entry of the table given by the frame number contain...
I have a vertex-weighted undirected graph $(V,E)$ with root vertices $R = {r1, ..., rn}$. I need to find the subset $V'⊂V$ such that $R⊂V'$, $N[V']=V$, $∀v'∈V '[∃r∈R ($path($r', v'$)$)]$ that minimizes the sum of vertex weights in $V'$. Note the path must contain only vertices in $V'$. In other words, all roots must be...
I am trying to understand why this "proof" of ETM undecidability is wrong. ALLTM={ < M >|M is a TM, L(M)=∑*} ETM={< M >|M is a TM, L(M)=∅} We know that ALLTM is undecidable, lets assume ETM is decidable (T is a TM that decides ETM) and get a contradiction. S= "On input < M >, M is a TM: 1.Construct the following TM...
Hello I am a CSE student and this question was in my homework. double fact(long i) { if (i==1 || i==0) return i; else return i*fact(i-1); } funcQ2() { for (i=1; i<=n; i++) sum=sum+log(fact(i)); } I thought it is O(n^2) but can the bottom function's log function call make it O(n^3)? I am not sure Thanks in advance
Here is the problem: There are $MN$ people, where there are $M>1$ seeds and $N>0$ people are in each seed. We have to make $N$ teams of $M$ people where everyone in the team have different seeds. Each person have their own value; values are positive integers. Assume there are no two people with same values. For two dis...
Is it possible to optimize the runtime of a two-sum solution by receiving a pre-sorted input either in ascending or descending order? Original Two-Sum Determine whether there are two items whose individual capacity will perfectly equal the total capacity while ensuring the same item cannot be selected twice. Input: ...
If $e = \{u, v\}$ is a cut edge with $\deg(u)$ and $\deg(v)$ both at least 2, then $u$ and $v$ are cut vertices. I want to prove or disprove this statement, but don't know how to proceed. I do know what goes wrong when one of the degrees is smaller than 2.
I'm designing a genetic algorithm to solve the travelling salesman problem. So far, I've gotten fairly good results. I'm now trying to improve on them by implementing some sort of diversification scheme (like fitness sharing and crowding), although I'm struggling with the conceptualisation of the inter-solution distanc...
Say there is a push-down automaton, in this example I'll use a Deadfish-like set: +: increase x by 1 0: set x to 0 ln: set x to ln(x) <-- real valued result With x being an infinite precision real-valued variable, does this allow said machine to have more power than if it was operating on integers? Or am I misunderstan...
If the BB function is computable, does that mean we know how to compute {i | program i eventually halts when run with input 0}, which is a clear contradiction with halting problem. Does this proof work? Am I missing anything? Thanks
Can you help me with sorting algorithm implementation for objects of Student type by rating field. This field (rating) value can be any number from 0 to 100. Can I do the sort in-place?
Example: Suppose $H:${$1,...,n$} $\rightarrow ${$1,..,n$} be a uniform hash function. for input $x$, $z$ is equal to number of trailing zero in the right side of $H(x)$. for $0 \leq c \leq 1$ what is the order of probability $ z \geq c \log n$? $C$ is constant here. Answer: $O(1/n^c)$ How this this is can be achieved?...
Edit: can someone provide clear answer with all details Given: $T(n)=T(n/10)+T(an)+n$ while $a$ is a const and $T(n)=1:(n<10)$ I was asked to find the minimum value for $a$ for which $T(n)=\omega(n)$ Using a set of complicated equations I found and proved that $a=9/10$ is the correct answer (for sure) But how I can pro...
Laptops, PCs (don't consider Apple products here) have processors that are mainly built on x86 and their life cycle is of the order of 5-10 years. Or the frequent changing of smartphones has a perception/psychological side of it and not the durability issues of the hardware?
I thought they did, but recently I tried to express $3^n$ as $k \times 2^n + o(2^n)$ for some constant $k$ but wasn't able to. All I found was $3^n = (\frac{3}{2})^n 2^n$. What am I misunderstanding here? I suppose my question applies to $log_c(n) = O(log_2(n))$ as well.
I figured out that the CFG that starts and ends with the same symbol in alphabet $\Sigma=\{0,1\}$ will be : S -> 0A0|1A1|0|1| A -> 0A|1A| How can i interpret the odd number of 1's also?
I recently asked a related question at the theoretical CS stack exchange, but I have modification to the problem that I think is a bit tougher. This seems like a better place anyways. Let's define a "task" $T_k$ to be a tuple $(a_k, b_k, C)$, where $a_k$ is the amount of active time spent on a task, $b_k$ the inactive ...
How would someone create a Turing machine that computes ⌈log2(n)⌉? I know that: n = 1, 2, 3, 4, 5, 6, 7, 8, ... f(n) = 0, 1, 2, 2, 3, 3, 3, 3, ... And that I want the input tape to have n 1's in it to represent the number i.e. 8 would be ###11111111### How would the the turing machine for this be created?
I know that for the language ww, the TM can zig zag across the tape and match symbols to see if the strings are equivalent by first finding the midpoint of the string. However I am lost on how the TM can find out where in www the repeated strings start and stop. I can find midpoint but how do I get one third or two thi...
Let suppose that we have a file with n = 10^6 records. The block size is B = 10 records and we have available main memory m = 20 blocks. (Sorting with MergeSort) a) If we have 1 disk find minimum available to sort file in 2 passes b) If we have 2 disks how many passes we need to sort the file completely I have starte...
Looking for an algorithm for splitting a list of people (S) into groups (G), |S| <= |G|, more than one person wants to be in a certain group. Every person has a monotone ranking from highest (most desired) to lowest of all the groups. Using this list I want to find the "best matching". "best matching" is when you maxim...
There are multiple very complicated articles about softmax online. I just want to know a few things about it: Why do we need softmax? What is the "problem"? What does it do? How does it do it? I find it very hard to get through all the math when I don't really get what it is all about. The problem is that all the thi...
I have to proof that Turing's combinator is a fixed point operator, but I can't get it. I tried this: \begin{align*} Vg &= (UU)g = ((\lambda f.\lambda x.x(ffx)) (\lambda f.\lambda x.x(ffx)))g = (\lambda x.x((\lambda f.\lambda x.x(ffx))(\lambda f.\lambda x.x(ffx))x))g\\ &= g((\lambda f.\lambda x.x(ffx))(\lam...
My intuition tells me that there is <=1 increase in lps for each increase in the index. Can someone make a better argument why this is O(N)? My confusion arises from len_ = lps[len_- 1] . def computeLPSArray(pat, M, lps): len_ = 0 # length of the previous longest prefix suffix lps[0] = 0 # lps[0] is always...
Let us model a wireless broadcast network as an undirected graph $G(V,E)$ where there is an edge between every pair of nodes ${i,j}\in V$ if they are in transmission range of each other. $w_{i\to j}$ is the weight of the link $i\to j$ which can be calculated only by transmitter $i$ and is unique to receiver $j$. All no...
From classical results of universal simulation of Turing machines there exists a Universal Turing machine simulating any Turing machine with time complexity () in time ()log(). Is there is an analogue for circuits? Since circuits can only accept a fixed input size it would only be able to simulate circuits that can be ...
You can simulate polynomial time Turing machines with polynomial size circuits, can you simulate multiple poly time TMs with a single poly size circuit?
Assume this particular architecture of a machine. Say we have 4 processors and each processor has its private L1 cache and shared L2 cache. Now if we write to an address in one of the private cache's of the L1 cache then we Invalidate the blocks in the other private cache which contains the same address. Say P0(process...
Object B can be in two state 1(stopped), and 2(running) at an arbitrary time t in the future. Object A can be in two states x, and y at t0. However, if A is in state x, B must be in state 2 at t, and if A is in state y, B must be in state 1 at time t. Thus, you can't have Object A in state x at t0 and B in state 1 at t...
$$L_2=\{w \in \{0,1,2\}^* : \text{$w$ has the same number of $1$'s and $2$'s}\}$$ I have tried creating PDA to determine if this was context-free or not. It seems like it would be because whenever a 1 is pushed onto the stack, there always is a 2 to get pop it out. The 0's are what is bothering me at the moment. Do we ...
What ist the time complexitiy of an algorithm with the running time of $a^{n^b}; a,b>1$? And how is it compared to factorial complexity O(n!)?
This problem is from an exercise sheet so it would be nice if you could guide me to the solution. The problem: For $ k \in \mathbb{N}\setminus\{0\}$ let $$L_k = \{x1y | x \in \{0, 1\}^*, y \in \{0, 1\}^{k-1}\}$$ be the set of words with have at the k-last Position a 1. (a) How many Myhill-Nerode-equivalence classes doe...
So the question is Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. You can only move down and to the right. This is a common interview question on software engineering interviews, it is easily solved by implementing ...
Given a machine that sorts an array of length $n$ with the following algorithm: Sort first $2\sqrt{n} + 1$ elements of array with Insertion Sort.(Check Insertion Sort) Select the median of the whole array (after its first $2\sqrt{n} + 1$ length part is sorted from step 1) as the pivot then partition the array.(Check Q...
If I have a password = "passwordPASSWORD" and the time it takes to encrypt the password successfully is: 353259.545 nano seconds is there a formula that can work out the time taken to successfully conduct a brute force attack on the password? I was thinking: AvrgTimeToEncrypt^PasswordType x PasswordLength ?
In a code, I saw someone use: n&(n-1) to get the least significant bit of n ⇒ 101000 will return 1000 n&(-n) to remove the lsb from n ⇒ 101000 will return 100000. This sounds magical to me. Is there any proof for these? Thanks a lot!
Let's suppose we have a supplier, sorting facilities, shipping companies and a target warehouse. We produce n packages of the product, and each goes to a different sorting facility (so every facility receives exactly one package). A sorting facility then passes the processed product to a shipping company, each sorting ...
After reading Church's thesis, and godelization theory, it seems everything is futile, is this really true, all the machines we are making machine which is same as before, bounded to not solve halting problems, in more simple terms can quantum computer do anything that a Turing machine can't? PS: In book named Elements...
The answer is yes, NP/poly is defined as the class of problems solvable in polynomial time by a non-deterministic Turing machine that has access to a polynomial-bounded advice function--the advice function only adds power; however, I'm having a hard time understanding NP/poly's containment of NP from the angle of the d...
A configuration of a Turing machine is defined as the following: an ordered triple $(x, q, k) ∈ Σ^* × K × N$, where $x$ denotes the string on the tape, $q$ denotes the machine's current state, and $k$ denotes the position of the machine on the tape. I have read in a paper that a space-bounded non-deterministic Turing...
I've been asked a question that goes something like this: Using depth-first search and Robbins' theorem, design and analyze an efficient algorithm to construct a strong orientation of a given undirected graph G. If none exist, output a bridge in G. Now, I can prove Robbins' theorem easily, which states that a graph i...
I wasn't sure whether to post this here or in the ai stack exchange - please let me know if i need to move my post elsewhere) I have been learning about how dynamic programming can be used as a tool to solve the bellman optimality equations: (only show state value function) $$ v_{*}(s) = \max\limits_{a\in A(s)}\sum\lim...
The maximum height of an AVL tree with a balance condition of 1 is 1.44log(n). So the worst case height is O(logn). However, if the balance condition was hypothetically 2 (meaning that the allowed imbalance condition between two child nodes would be 2), how could I find the maximum height of such a tree. Would I need t...
I'm studying Algorithms and Data Structures from The Algorithm Design Manual and I'm having a hard time going through the exercises. Specifically, the proofs are a bit hard and not really explained in the book(It only gives two proof exmaples). Prove the correctness of the following sorting algorithm. Bubblesort(A)...
We know that in an asynchronous system, no assumptions about process execution speeds or message delivery times are made. My question is: can we present any guarantee in asynchronous systems? Some examples of the guarantees that I'm looking for are: Consider two processes $p$ and $q$. $p$ sends a message an infinite n...
Is there an example of an algorithm whose time complexity is strictly larger than Ackermann's function?
The Laplace mechanism is a standard way of making the output of a function $f$ differentially private. More concretely, let $\Delta_f$ be the sensitivity of $f$, i.e. the maximum value by which the output of $f$ can change, if the input database is changed by one row. On input database $x$, the $\epsilon$-private Lapla...
Solve the following recurrence-relations: my attempet for the first one was doing upper bound and lower bound by changing for lower $6T(n/3)+1$ and for upper $6T(2n/3)+1$ but i didn't get the same order for $\Theta$ $T(n)=5T(n/3)+T(2n/3)+1,T(1)=c$ $T(n)=2T(\sqrt{n})+\log_2(n),T(4)=2$ I'm not sure if I solved this righ...
Computational distance between sequences of distributions $\{X_i\}_{i \in \mathbb{N}}$ and $\{Y_i\}_{i \in \mathbb{N}}$ can be defined as the maximum, over all probabilistic polynomial time algorithms $A$, of $$ \left|\underset{x \sim X_{n}}{\mathsf{Pr}}(A(x) = 1) - \underset{x \sim Y_{n}}{\mathsf{Pr}}(A(x) = 1)\right|...
Given code to just an NP-verifier, where the certificate/witness is required to be of size polynomial in the instance, for a language L, can you, from that data alone, construct code for a solver, or generate / get back the language L itself? At a glance, the answer seems to be yes--you could just try every word, certi...
I was hoping someone could point me in the right direction in terms of what type of problem I am describing and what type of algorithm I should use to answer it. Here is the problem: A company is in the process of reducing its office space and wishes to find the path that will minimize double-rent costs during the tran...
I'm having trouble understanding the difference between the Held-Karp $O(n^2 2^n)$ solution and the cutting-plane method pioneered by Dantzig, Fulkerson and Johnson. Held-Karp is $O(n^2 2^n)$ which result is computational times that are excessive. To quote Cook: This is disappointing since for $n = 30$ the Held-Karp g...
I'm trying to hash integers n = 4k(0,4,8,12,16...) into an array of linked lists of size 4 (chaining). What is a good hasing function that guarantees a good distribution of the keys? that means to use all indexes of the array from 0 to 3.
For sufficiently large |w|, how many of the 2^|w| strings of length |w| are entirely unrelated? A way to define this: two strings are unrelated if their joint Kolomogorov complexity is practically equal to their individual Kolmogorov complexities added together: K(w1,w2)=K(w1)+K(w2)
Dependently typed languages such as Agda support inductive families, also called indexed datatypes, which allow type parameters to vary between constructors. This can be used to define a set of relations between types, which can be used to constrain existentials. For example, we can capture the relation $$\begin{align*...
I have the following condition in an LP problem. I have a variable $x_i \in i = 1,2,..7$ and I need to constrain the problem via: if $x_1$ >5 then $x_2 \leq 30$ I'm stumped on how to formulate that with integer variables. Thanks
I am currently studying the textbook Principles of Program Analysis by Flemming Nielson, Hanne R. Nielson, and Chris Hankin. Chapter 1.3 Data Flow Analysis says the following: The least solution. The above system of equations defines the twelve sets $$\text{RD}_\text{entry}(1), \dots, \text{RD}_{\text{exit}}(6)$$ in t...
I am defining, a string $w$ is accepted by a PDA whenever the PDA enter into a final state during the computation(at least on one branch of the computation) on the input $w$ (no matter whether the input is read fully or not). I can guess PDA with the new definition of acceptance is less powerful, and easy to see every ...
So, I need a data structure that would support the following operations: Add an element to the structure and get some "handle" for that element Retrieve an element by a handle Remove an element by a handle Iterate over all elements Note that the elements are not expected to have any particular order in iteration. Pre...
are for every $\alpha \in N $ , $ \frac{1}{\alpha-2} \geq \frac{1}{\alpha}+\frac{1}{\alpha-1}$?
I have been trying to understand the use of circuit models for boolean functions, and came across this question, that I am trying to struggle to understand: Show that if a function $f\colon \{0,1\}^n→\{0,1\}$ has a support of size $k$, then it can be decided by a circuit of size $O(nk)$. I understand that for any binar...
How do I prove that the predicate $P(x , y)$ is primitive recursive, where $P(x,y)$ holds if $x,y$ are relatively prime?
I'm studying CLRS section 21.3, which introduces a union rank + path-compressed implementation of disjoint set. The implementations of MAKE-SET, UNION, LINK, and FIND-SET on p 571 of the book all work with nodes themselves, where each node has a parent pointer and rank. Exercise 4 in that section claims that if you wan...
A hash function $H$ operating on strings can have the following property: Let $x$ be a string and $c$ a character. Given $H(x \cdot c)$ and $c$, $H(x)$ can be determined uniquely (where $\cdot$ stands for concatenation). Note that it may not be possible to determine $x$, only $H(x)$. An example of such hash function is...
I ran into a very hard question. We have array of $n$ integers. for $1 \leq i \leq j \leq n$. we want to set $c_{ij}$= Sum of all values in the range $i$ to $j$ of this array. we want to finding average of all possible $c_{ij}$ in this array. if 4 basic operation in math $(+,-,*,/)$ can be done in $O(1)$. the best algo...
Question There are $n$ computers arranged in a cycle ($1,2,3..,n,1$), with undirected edges between adjacent computers. There are $m$ messages that need to be delivered. Message $i$ ($1 \le i \le m$) has to be sent from computer $s_i$ to computer $t_i$. There are two ways to deliver a message $i$: clockwise from $s_i$...
I'm reading section 16.1 of the book, Combinatorial optimization, Polyhedra and efficiency by Schrijver. Here, he starts with a matching $M$ and describes a path $P$ that is $M$-augmenting if: The path has odd length (in terms of edges). Its ends are not covered by $M$. Its edges are alternately out of and in $M$. Th...
The post here: Solving the min edge cover using the maximum matching algorithm provides a way to obtain the min edge cover from a maximum matching by greedily adding edges on top of the maximum matching until all vertices are covered. Now, thinking about the min-weighted edge cover problem, it would seem this approach ...
I see the following image on google: And I want to find Amortized Cost for Updating of each vertex on Dijkstra algorithm. I have an answer $O(E/V)$. I'm get stuck it means at this answer we should used sorted array or binary heap for implementation? non of others get us this Amortized Cost?
A path consisting of a number of disequality edges and a single equality edge A path consisting of equality edges A path consisting of a number of equality edges and a single disequality edge A path consisting of disequality edges The answer is number three, right? Who has any reasonable doubts or general short r...
I know that there's no such thing as a finitely sized undecidable language. However, does there exist an undecidable language where a finitely sized set of undecidable elements are 'hiding among' an infinite set of decidable elements? In order to formalize this, let's build a deciding machine that answers $\text{YES}$,...
the corpus what is the shape ? what is the colour ? what colour is it ? it is what ? is it red ? what is it ? what shape is it ? it is red it is green the colour is red the shape is square red is the colour square is the shape (1) What is the probability of the following sentences: (4 points) ...
I am studying the topic of vertex cover on coursera and how it can be solved approximately by linear programming. Suppose the optimal solution for the vertex cover problem is $OPT$. I do not understand why the approximate solution $$\sum_u w_u x^*_u \leq OPT$$ where $w_u$ is the weight to each vertex and $x^*_u$ is the...
The following algorithm constructs a binary tree. MakeArray(array[x:y]) ( if(x==y): the root is x else: pick a number r as root MakeArray(array[x:r-1]) MakeArray(array[r+1:y]) ) Let $a_n$ be the expected number of nodes which have two children in the tree with $n$ nodes generated. Prove $a_n = \frac{n-2}...
Is it possible to somehow store a $n$ bit string using only $\mathcal{O}(\log{n})$ space? I am thinking if the string could be stored using a hash function, but I am not sure if it is even possible.
Which of these properties hold for all FO theories? (but not regarding fragments thereof) a. Decidable b. At least expressive as propositional logic c. NP-complete a) Decidable: no, some first order theories are not decidable. b) Propositional logic lacks expressiveness, so possibly yes. However, are hence all FO theor...
I'm studying The Algorithm Design Manual and the proof exercises of the first chapter are really hard(at least for a first-timer). I asked a question on here about the previous question in the exercises two days ago and I still haven't been able to go through the whole page. Anyway, I'm trying to inductively prove Eucl...
When I look online for examples of the Hungarian method for solving the min-weight assignment problem, for example here, it involves iterating on the cost matrix; subtracting entries from the rows and columns. However, in section 17.2 of the book, Combinatorial optimization polyhedra and efficiency by Schrijver, a seem...
What is the best way to find if there are two individual capacities that sum to a total capacity within a range of plus and minus the total capacity? Optimize for runtime over memory complexity. The same item cannot be selected twice. Inputs An Int representing the total capacity An Int representing the range abo...
I'm reading the algorithm on page 12 of An Introduction to Counterfactual Regret Minimization. On lines 25 and 26, we accumulate new values into $r_i$ and $s_i$: $25.\space \space r_I[a] ← r_I[a] + \pi_{-i} . (v_{\sigma I \rightarrow a}[a] - v_{\sigma}[a])$ $26. \space \space s_I[a] ← s_I[a] + \pi_{i} . \sigma^t(I, a)...
Most normal linear programming problems look like this: We choose some point in the double shaded area that solves our optimizer and we're good to go. However, I've come across a problem where it's fairly common to get a lp problem like this (infeasible): I'd like to employ some metric such that the solution given re...
I am currently studying the textbook Principles of Program Analysis by Flemming Nielson, Hanne R. Nielson, and Chris Hankin. Chapter 1.3 Data Flow Analysis says the following: The least solution. The above system of equations defines the twelve sets $$\text{RD}_\text{entry}(1), \dots, \text{RD}_{\text{exit}}(6)$$ in t...
I don't know what this problem is called, so I haven't been able to Google for it, but I have a graph problem that I feel must have been solved many times before, and I just cannot find a good solution. Given a directed graph, and nodes A and B, I want to find a route that takes me from A to B and back to A again, goin...
S is defined as S x y z = x z (y z) This suggest that (y z) should be evaluated just after x z and the the results of x z is applied to the results of (y z). I'm implementing call by value in lambda calculus, I would need to support parenthesis when evaluating this expression right? Does this affect the results? I thou...
I was reading the book by Kozen-Theory of Computation. There is a statement that Turing machine is the best model for defining basic time and space complexity because atleast for higher levels of complexity the definitions are robust and reflect fairly accurately our expectations of real life computation. I did not ...
So this question has two questions and i have to use the answer from 1 to answer question 2. Assuming that my answer for 1 is good. I need help with 2. ( Correct me if wrong please.) Question 1 : Show the following language is decidable $L=\{\langle G,w \rangle $ : $G$ is a grammar in normal form of Chomsky and $w$ is...
The Fugaku is the most powerful computer. Its performance is 442,010 TFlop/s. That number does not mean much to a layman like me. I want to know how fast it can solve a hard problem. For example, can it solve the Max-Cut Problem of 1,000 vertices in minutes, hours,...,years? By the way, what is the best record of solvi...
I'm reading the book Introduction to Algorithms. In the book, in the initial step of proving that a red-black tree with $n$ internal nodes has height at most $2\lg(n+1)$, they prove that any subtree rooted at any node $x$ in a red-black tree has at least $2^{bh(x)} -1$ internal nodes. However I couldn't wrap my head ar...
Can anyone kindly give me some hint on solving this? There are $n$ water containers placed on the top of each other (container1 on top of container2, container2 on top of container3, ...), each with capacity $c_i$ and initial water $a_i$ ($a_i<c_i$). In case of breakage of any container, all the water inside it will po...
Here is the description of a problem Given an array of strings representing an $N$x$N$ grid of $red$ and $blue$ cells and a target color $r$ or $b$, partition the grid into $N$ sections of $N$ contiguous cells. The goal is to have the maximum number of sections where more than half of cells are of the target color. Re...
I have N objects, each of which has a weight. I need to form combinations of the objects to maximize how many sets of objects add up to at least x total weight. Combinations can consist of any number of objects. 1). What is a fast and correct algorithm to solve this? 2). Is this NP-complete, hard, or neither? Ideally, ...