instruction
stringlengths
35
29.1k
There are well-defined methods for generating random graphs / networks that satisfy certain properties, including small-world graphs, scale-free networks, and totally random non-planar graphs. I am looking for methods to generate random graphs that (1) are planar, and (2) have the quality that they are arranged in a l...
I am told to find the equivalence classes of the Myhill–Nerode relation of the language $\{0^n1^n \mid n \in \mathbb{N}\}$. For one, I know it has an infinite number of equivalence classes given that it's a non-regular language. Im not sure how to find all the equivalence classes and show how I got those equivalence cl...
I am trying to understand the multiple variable definition of an asymptotic notation. Particularly the definition in Wikipedia. It's also discussed in Asymptotic Analysis for two variables? but I think the answer is wrong. At least it is just corrected in the comments and and referenced to a lengthy answer. What I look...
What is the asymptotic complexity of $$f(n) = -\log(c^{1/n} - 1)$$ for some constant $c > 1$? I conjectured $O(\log n)$ and checking WolframAlpha does give $$\lim_{n\to\infty}\frac{f(n)}{\log(n)} = 1,$$ but I haven't found a proof yet.
I am not able to understand how to write a recurrence relation for this n queen problem algorithm down below. Recurrence relation is for n*n board and the time complexity Algorithm : nQueen(B) for the n queens problem Input : 2-dimensional array B[] Output: All solutions B[] satisfying the condition for the eight q...
I just had a data-structures exam. One of the questions asked us to create a data structure which allowed insert operations in O(logn) amortized and delete-max (or min, doesn't matter) in O(1) amortized. The official answer was to use a regular fibonacci heap, and then to change the potential s.t. for every insert we i...
Let $G$ be a weighted graph with a weight function $w \longrightarrow \mathbb{R}^{+}$. Let $G'$ denotes the weighted matrix with adjacency matrix $$A_{G'} = \sum_{i=0}^{k} (xA)^{i}$$ where $k$ is integer and $x$ is a variable. I am not getting what is $A_{G'}$ matrix? Is it contains all walks of length $k$ or is it som...
Prove that the language $A$ on $\{0,1\}$ containing all words for which the number of $0$s is equal to the number of $1$s is not regular. I know one way to do it would be to show that the cardinality of $A / \mathbin \equiv$ is infinite. But how would I find the different equivalence classes and then show it has an inf...
Consider a simple Bernoulli variable X X = 1 with probability p X = 0 with probability (1-p) The variance is simply p(1-p). The entropy is -p*ln(p)-(1-p)*ln(1-p) Both are measures of uncertainty. What is the advantage of entropy then? Thanks!
This is taken from a practice quiz by my university. I ruled out that aabbbaab is not part of the grammar: S → aSb → aaSbb... This shows that I can't make this word because it would have to have atleast two b's at the end in order for me to add more letters Then I tried to see if abbaabb can be derived from the gramma...
Suppose I have a polynomial $p(x)$, and a "modulus" polynomial $q(x)$ of degree $d$. I want to find two polynomials $r_1(x),r_2(x)$ of degree $\le d_1,d_2$ such that $$p(x) \equiv r_1(x) x^t + r_2(x) \pmod{q(x)}$$ Assume $d_1+d_2= d$, and that we are working over some finite field. Given $p(x),q(x),d,d_1,d_2,t$, is th...
I got confused about minimal and minimum in context of graph theory. Although, I have understanding that minimal means more than one minimum i.e. none qualifies as actual minimum so we say them minimal. What exactly does minimal spanning tree mean? Also, what exactly does 'minimal edge' mean? How do they differ from mi...
I'm afraid this may be opinion-based and not apt here, but... Mathematicians often talk about "mathematical beauty", i.e. Gauss' proof of the Fundamental Theorem of Algebra, Euler's Formula, etc. What's beautiful in Computer Science? Things like the Church-Turing thesis or Curry-Howard correspondence are cool, but I'm ...
As the title says, I have been asked to generate a grammar that defines the language of regular expressions. The symbols are: + . * | ? char I tried and came up with this but it doesn't work when trying to create a parse tree so it's wrong but I'm so lost on how to even begin to define the different rules. So any help ...
Let $G$ be a graph which is a tree with $\ell$ added edges. I wish to show that VWVC ((Vertex-)Weighted Vertex cover) is FPT with respect to $\ell$. In particular, I'd like an algorithm running in $O(2^\ell n^c)$ time, where $n$ is the number of vertices and $c$ is a constant. I tried to approach this by finding a tree...
First, let's start with the description of the problem in dimension 1: Let $T_0$ be a space with $n$ nodes organized in a tree structure, with $m$ of those nodes defined as target nodes. In this space, we define a function $f(node)$ that associates each node to the first target node in the path to the root. So, as an e...
I was wondering for if a single core processor can be MIMD? or MISD? or SIMD? I thought MIMD's requirement is multicore, but I am not sure about this
k-disjoint triangle "We consider the NP-complete problem of deciding whether an input graph on n vertices has k vertex-disjoint copies of a fixed graph H. " The above definition is the best I could find online. Nowhere could I find an clear formal definition. What does it mean to be vertex disjoint exactly? How to pro...
In most machine learning applications, we use Maximum Likelihood Estimation to derive appropriate cost functions. For example, if we assume that our model $f(x;\theta)$ yields the mean of a multivariate normal distribution (i.e. $p(y|x;\theta) = \mathcal{N}(y;f(x;\theta),I)$), we will obtain the mean squared error (MSE...
I didn't study computer science as a degree, so whilst having studied computer science, there are still gaps in my knowledge. Everything I read about 'state' sounds like some form of 'data' but kept in memory as opposed to a database. This keeps leading me to the question: is a state machine not just a way of storing d...
There are 3 definitions of asynchrony that I know of: In event-based programming, asynchrony refers to the execution of tasks in a non-sequential way, which may involve creating another thread. For example with AJAX, we can perform HTTP requests and handle their response in a new thread so that the program doesn't blo...
If I have a sorted list $A=[a_1, \dots, a_n]$ such that the integers $a_1\leq a_2\leq\dots\leq a_n$, and an unsorted list $B=[b_1, \dots, b_k]$, which includes at least one integer also in $A$, can I then find the maximum integer in $A$ which also is in $B$ in $O(k\log n)$ time? If so, how?
I am interested in the asymptotic bounds of the following recurrence: $$T(n)= T(n - 1) + \frac{1}{n\log n}$$ with base case $T(1) = 1$. I'm having trouble while solving this recurrence. It seems much more tricky than I initially thought. I've tried out by iterative method and since $\log(n!) = n\log n$, I've got $\frac...
Show that $$ 1 + \frac{1}{2} + \cdots + \frac{1}{n} = \Theta(\ln n) $$ How do I solve this problem? I tried to to integrate it but I got a weird answer.
The question is as above. I want to prove that there exists a $K_5$ as a subgraph, so this graph is not a planar graph. But I failed. If you can help me, I will be very appreciative.
From time to time I stumble across a problem of matching hashmap keys to a regular expression. In such situations I am forced to loop through all of map's elements and try to match every single key to the regex. With regex compiled to DST it should have complexity class of O(n * m) where n is number of elements in map ...
I wonder how or why Avalanche Effect got its name. Avalanche Effect is a desirable property of cryptographic algorithms, wherein if an input is changed slightly (for example, flipping a single bit), the output changes significantly (e.g., half the output bits flip). (source: Wikipedia) But I feel like this definition...
I'm trying to design an algorithm that finds a number in a given range. The only signal we get for a given guess is: "Is our guess less than the magic number?" I'm trying to: Optimize the number of steps it takes to reach the magic number Minimize how much we overshoot the magic number by Example: Our range is [1, 10...
I am a pure math person doing some ML self-study and I am pretty lost. I am trying to solve the following exercises on decision trees: Exercise 1. Consider the following training set where $X_1,X_2,X_3,X_4$ are the attributes and $Y$ is the class variable. $$ \begin{matrix} Y & X_1 & X_2 & X_3 & X_4 \\ 1 & 0 & 1 &...
I am still really new to compsci theory and some of the topics are really hard to understand. For this Problem I would think that say we have two sets A and B and they are both non-recursive. If we take A ∩ B we would get the the matching inputs and since they are both from non-recursive sets wouldn't the intersectio...
I am looking for an algorithm that can create binary numbers following certain patterns. Let $n$ be the size; and assume that is a power of 2. Let $E$ be the exponent; $n = 2^E; k = \log n$. The $0, 1$ on the "top level" are symbols, and let $0^n, 1^n$ represent $n$ consecutive zeroes and ones respectively. For size 2...
Consider the following recurrence relationship. \begin{eqnarray} T(n) &=& \begin{cases} T\left(\displaystyle\frac{n}{2}\right) + 1, &n \ \mbox{is even number}& \\ 2T\left(\displaystyle\frac{n-1}{2}\right), &n \ \mbox{is odd number}& \end{cases} \nonumber \\ T(1) &=& 1 \end{eqnarray} How to prove there exists an...
I understand that the Bellman-Ford Algorithm can solve the single-source shortest-paths problem. However, can it also be used to determine the longest path in an undirected, graph through first negating the weight of all the edges?
If I start with 4 threads when I run my code and increase thread number each time I run it, my run time decreases as you would expect. However, my run time for 1 thread is significantly smaller than my run time for 4-16 threads. How can that be? Is it an issue with the time needed to create new threads? Should I change...
Answering my question Yonatan N said a statement from which follows that there are computable functions of quantum time complexity strictly above polynomial. Accordingly a Quora answer Quantum computation is fully deterministic. A given computation applied to a given starting state will always produce the same final s...
I found this sentence in multiple sources but I didnt understand in one thesis With a neutral representation each phenotype could be represented by a number of different genotype and in another thesis it may be possible for neural networks with functionally equivalent topologies to be represented by a number of diff...
I am studying a configuration model building $d$-regular graphs and reading the following article: The expansion of random regular graphs by David Ellis. I am stuck on the following step: Each simple labelled $d$-regular graph on $n$ vertices has the same probability of arising. Indeed, it is easy to see that a simple...
So, I have some data to a time capsule project of mine. But the thing is, I need to know the best media on long-time scale to use as storage unity. The time range is 120 years. Now, I've been thinking about two medias: the average CD-ROM/DVD-ROM and a outdated Vinyl/LP. On the one hand the CD/DVD is a good one, due to ...
There are several quantum complexity classes in different ways analogous to NP: NQP, QMA, and, as I understand, others. P=NP BPP=NP in simple words means "any cipher can be deciphered by a classical computer". (Do I understand it correctly?) So, what is the "formula" for "any cipher can be deciphered by a quantum compu...
Assume we have a language L={111}. Prove no DFA with four states can accept L. Can’t a DFA with 4 states accept L?
I need to binarily encode/decode small integers (around 10 bits), in such a way that the hamming distance of the encoded number grows monotonically with the (absolute value) arithmetic distance of the numbers. Edit: the monotonicity doesn't needs to be absolute. There is probably a cost to pay breaking it, but the cost...
What is a regular expression for the language $C=\{wtw^r \mid w, t \in \{0 \cup 1\}^+\}$? Here $w^r$ is the reverse of $w$.
i need help for a specific problem i have at work. You have N number of rows in an array, each with some distribution of Numbers that range from 0 to N.Given an array of size 1000: Row 1 might look like: [1,288,399,784,456,994]. Row 2 might look like: [4,784,123,8] For each each element in each row, we take the mod 8, ...
I have a directed graph which has edges between every vertices $i$ and $j$ such that $i < j$ and the edge is from i->j and every vertex needs to be visited. I need to divide the graph into two parts such that the travel distance on both the parts i.e. sum of edge weights while traveling from the lowest index to the hi...
I'm trying to prove that in-order tree traversal prints the keys in sorted order. It's shown here, but what I want is to prove correctness using ordinary induction. Claim: For any n-node subtree, the in-order-tree-walk subroutine prints the keys of the subtree rooted at node x in sorted order. in-order-tree-walk(x) ...
While there's an algorithm for solving the stable roommates problem, I understand that the three-people-per-room version of that problem, sometimes called the "threesome roommates problem", is NP-complete. I'm wondering if there's an approximation algorithm. This is for a specific use case - grouping people into tables...
I am a little stuck at attempting to give an NFA for the regular expression $0^+(10^+0)^∗$ , where the alphabet is ${0, 1}$. I have tried to construct multiple NFA's state diagram and the closest I can come up with is However, I see that this NFA also accepts $0^+(10^+0)^∗0^*$. Is there any way I can alter this state ...
Recently I encountered an interesting problem while studying discrete mathematics: Give the pseudo code to judge whether a poset $(S,\preceq)$ is a lattice, and analyze the time complexity of the algorithm. I am an algorithm beginner, and I am not familiar with various advanced algorithms. I have no idea about this p...
Consider a string 'ABBAA' Possible substrings with even number of characters are $4$ 'ABBA' : Count of 'A' is even and 'B' is even 'AA' : Count of 'A' is even and 'B' is even - ($0$) Similarly 'BB' and 'BBAA' substrings. So a total of $4$ substrings are possible. If given string is 'AABCCBBCAA' substrings possible are ...
Consider two problems as defined here. Approximate counting: Given a Boolean function $f(x)$, for $x \in \{0, 1\}^{n}$, distinguish between the two cases: The number of satisfying assignments for $f(x)$ is $\geq 2^{k+1}$. The number of satisfying assignments for $f(x)$ is $\leq 2^{k}$. We are promised that one of the...
Because SD cards use flash memory, they should requires wear leveling to avoid significantly shortening the life of the card. At the same time, my understanding is that they usually use a FAT32 file system. My understanding of FAT32 is that there is a small "file system description" block at the beginning of the device...
I found a pseudocode online and I don't know why the complexity of it is $O(2^N)$, according to the site. Given a fixed curr, the for-loop in lis_ending_here(...) will recursively call curr times itself will new curr range from 0 to curr-1, then I stuck here and don't know what's the next step to get the conclusion $O(...
In my analysis of algorithms class we were given the following recurrence relation: \begin{eqnarray} T(n) &=& \begin{cases} T\left(\displaystyle\frac{n}{2}\right) + 1, &n \ \mbox{is even number}& \\ 2T\left(\displaystyle\frac{n-1}{2}\right), &n \ \mbox{is odd number}& \end{cases} \nonumber \\ T(1) &=& 1 \end{eq...
Assume that we have a set S of sets s. Every pair (s,s') in SxS can be overlapping or not. How can we efficiently compute the number of pairs (s,s') that are overlapping, i.e. that share at least one element? Additional: actually each set s occurs a number of times (S is a multiset). I have tried to create a matrix M o...
I was asked this in a hiring challenge that I gave today on HackerEarth: Question/Problem statement: Given an array, split them into several subarrays(possibly zero) such that you obtain maximum sum of difference between maximum and minimum in each of those subarrays. Examples: [1, 2 , 1 , 0, 5] You can split them int...
In the paradigm of Turing machines what is considered a program? Can't find a definition anywhere. Is it a member of L(M)?
Suppose that $D$ is a regular language over an alphabet $A$. How can I prove that the following language is also regular? $$ \mathrm{LANGUAGE}_2(D) := \{ d \mid d,t \in A^* \text{ and } dt \in D \} $$ (This problem is taken from Introduction to the Theory of Computation by Mike Sipser.)
I have a very simple question about the best possible big-O bounds for the following data structure: It starts out empty When you add an element, it is inserted, and the index it was at is associated with it. So if it was the first item inserted, it's index would be zero: 14 12 19 <- items 0 1 2 <- associated indice...
Let's say I have a Binary search tree with $n$ nodes and know its shape. I also knows each node has a unique key that is an integer between $1$ and $n$ (inclusive). This would make the assignment of the keys to the nodes unique, given its shape. What is a good $O(n)$ algorithm for assigning each node its correct key? F...
Given a DRAM-based memory system with a total capacity of $x$ bytes, $y$ DRAM rows and a refresh time of $t$ milliseconds, how do I compute the power consumption for one DRAM refresh? I couldn't find something concerning this question so far.
Im trying to figure out if there's an assembler instructions or a bios intruction to get multi-threading in a kernel. In the case that doesn't exist that, how could i set muti-threading in a kernel?
I calculate similarity percent between two images. Another image is the same with changed brightness. I've already tried comparing by pixel (euclidean distance for grayscale and 0/1 values), comparing by HSV. I've tried also normalisation (pixel brightness-mean brightness). The results were quite good (80-90%), but the...
Suppose a language $L$ has a non-adaptive PCP verifier which uses at most $r(n)$ random coins, and queries at most $q(n)$ locations of the proof, on inputs of length $n$. How can we show that there is a PCP verifier $V'$ for $L$ that uses proofs of length at most $2^{r(n)}q(n)$? I understand that the verifier can query...
The single sell profit problem is: Given a list of prices on each day, find the maximum profit that could have been made by buying on one of the days and selling on a later day. There is a solution with a single scan that is easy to implement and runs in $O(n)$. This question is not about that. It's about the divide-...
Suppose there are two strings, $S$ and $T$, and we want to find the length $l$ of the shortest substring of $S$ which contains all the characters in $T$, in order. (Assume the length of $T$ is bounded, so it doesn't need to be considered for determining time complexity.) Here are some examples: $S$ = "abcabc", $T$ = "...
Using guess and check method, for two given graphs with the same number of nodes, a NTM selects a permutation of the node set and then checks if the edges are preserved. The nondeterministic selection of a permutation of the nodes is done in polynomial time. How is the choice of a function done in polynomial time? This...
I need to prove or disprove that $L^* = L^*L^*$. Intuitively, I know this is true, and I know I need to prove that $L^*$ is subset of $L^*L^*$ and that $L^*L^*$ is a subset of $L^*$. But I am really struggling to prove that.
A unit disk graph is defined by a collection of $n$ vertices corresponding to $n$ points on the plane, with an edge between any two vertices whose distance is at most $r$. Some $NP$-hard problems become solvable in polynomial time for unit disk graphs. I am interested in designing approximation algorithms by adapting s...
The use of the phrase "worst-case running time" is really confusing to me. Isn't plainly stating that the time complexity of an algorithm is $O(n^2)$ supposed to mean that the growth rate of the algorithm is sub-quadratic? If it is then why do we say that $O(n^2)$ is the worst case time? Or do they have different meani...
I've been doing review problems for a midterm and I came across this one problem that I haven't been able to solve. The problem essentially says that given a complete graph $G=(V,E)$ partition the vertices into two subsets $A$ and $B$ such that weight of the smallest intra edge (i.e. an edge $e=(u,v)$ such that $u$ and...
in John Backus' 1978 FP paper "Can Programming Be Liberated from the von Neumann Style" he says To help assemble the overall result from single words [von Neumann ie. conventional mutation-based] languages provide some primitive combining forms in the statement world--the for, while,and if-then-else statements--but th...
Define a sequence $c_1,c_2,\dots$ by the equations $$ c_1=0, \quad c_n = 4c_{\lfloor n/2 \rfloor} + n \text{ for all } n > 1. $$ Prove that $\frac{(n+1)^2}{8} < c_n$ for all $n \geq 2$. Hint: $\lfloor \frac{n}{2} \rfloor \geq \frac{n-1}{2}$ for all $n$. How do I solve this question? I have no idea how to start.
I need to prove the following languages are not regular and I'm having a tough time identifying the equivalence class that can have an infinite index. How would I go about doing these? I know how to prove it after finding the equivalence class but any tips on how to identify the one that has the infinite index? I know ...
From this talk and these lecture notes here and here I learned that sequential consistency does not actually model what really happens in practice. However, it is also pointed out that most of the work in formal methods assumes the sequential consistency model even though there exists other models which correctly chara...
Could you please help me understand the following Language $L = \{ a | a ∈ \{0, 1\}^∗, |a| = k ≥ 4, a = a_1a_2...a_{k−1}a_k, ∃i ∈ N, 1 ≤ i < k : a_i = a_{i+1} \}$ what does $a_i = a_{i+1}$ mean? Could you please give me an example of word in $L$?
I am designing a simple compiler for my university project. In my programming language, the break keyword is allowed. I want to know whether break keyword occurs outside a loop should be a syntax error or semantic error. I want to know what is the best approach. If it is a syntax error I can do it in the grammar file. ...
I was solving some problem from past test, there was this question: Use the closure property of regular language to show the language $L$ is not regular $$L =\{ a^3 b^n c^{n-3} \mid n>3\} $$ I know how to solve it using Pumping Lemma, but how to solve it with closure property? Also, I know that to prove that a langua...
I'm trying to understand how you set about writing an OS in something like C. I've always used C to write applications - using commands like malloc and fork and so on to request things from the OS. If these methods don't exist when you're programming the OS itself (or perhaps the Kernel in particular), how do you write...
Question: Assume there are $n$ distinct gifts on the real line. Their positions are $\{x_1, ..., x_n\}$ and each of them has an individual value $p_i$. Now you can choose a subset of them such that any two gifts in your choice are at a distance more than 5. What’s the maximum total value you can get? Design an algorith...
I'm trying to show that for the following Towers of Hanoi general algorithm that $T_k(n)=\Theta(n)$ for all $k\geq 2 + \frac{n-1}{2}$, I'm not sure how to incorporate the restriction on $k$ into my proof. generalTH(n_disks,k_stacks) if n<k: ### in 2n-1 moves reassemble ### return m = n-2 generalTH(n-m,...
Let $G=(V,E),n=|V|,m=|E|$ be a graph. There exists an algorithm with time complexity $O(n+m)$ to test if given graph $G$ is chordal. If I know the graph is NOT chordal, is there a algorithm to find any of the cycles without a chord of length $k\geq 4$ (running in polynomial time of course)?
This question concerns a variant of the 'experts' problem and the randomized weighted majority algorithm that can be used to solve it. This is the description of the problem from Wikipedia: Imagine that every morning before the stock market opens, we get a prediction from each of our "experts" about whether the stock ...
Given recurrence relation $T(n)=8T(n/6)+n \log n$, I get that the running time of the leaves should be $n^{\log_6 8}$ and $f(n)$ should be $n \log n$, but how can I know which one is bigger ?
I'm still quite new to regex, and I've seen topics online of people talking about removing lambda productions, but that has yet to be discussed in the class and the only formal definition of the rules in a grammar that I was given by my teacher: $rule ∈ V$ $\times$ $(V ∪ Σ)^*$ where V is the set of variables and Σ is t...
Lately, I have been in touch with some C++ snippets, and I have a very strange observation on the tiny detail: Most of the times, I see, that people declare iteration variables outside of the for/while definitions, and then initialise them inside for/while definitions, like: int i, j, k; for(i = 0; ..; ..) { } //note,...
I am stumped on the following question: For any depth first search of a directed graph, is it true that the strongly connected component containing the vertex with the lowest post order number also contains a sink? I know that the sink has the highest post-order number, so I am inclined to say False, but I do not know ...
There is a question in the second chapter of the book that I'm unable to solve, and unfortunately algorist.com does not provide a rigorous enough solution, or maybe I can't quite understand it. Here is the question: I've noticed the sums of rows are the powers of 3, and it's intuitively obvious that the sums of rows a...
Consider a transition system defined by $\langle S,T \rangle$, where $S$ is a set of states and $T \subseteq S \times S$ is a set of transitions, where $T$ is total, i.e. for every state $s$ there is at least one outgoing transitions $(s,s') \in T$. Each path corresponds to a set of states, namely, the states visited a...
The original grammar is $$ S \to SaS \mid SbS \mid ScS \mid d $$ My answer is $$ S \to daS \mid dbS \mid dcS \mid d $$ Is that correct?
I came across the following two regular expressions $r_1 = 0^+(10^+0)^∗0^*$ and $r_2 = 0^+(10^+0)^∗$. I know, in general, proving if two regular expressions are equivalent is hard in terms of time complexity, and that there are several algorithms to determine this. (e.g, convert regex to DFAs.) However, I wanted to kno...
Given a list of non-overlapping ranges and values, i.e. [(0, 5, 0.5), (10, 15, 1.1), ...], and a list of potentially overlapping ranges (bins), i.e. [(0, 10), (5, 15), (0, 5), ...], find the average, min, max, standard deviation of the bins. For example, the answer for averages would be [0.25, 0.55, 0.5, ...]. Assume t...
I have a control flow of function F, I want to know all control flows of this functions. I.e., function F { A; if B { B; } C; } would have the control flows {[ABC],[AC]}. My intuition tells me that the complexity/amount of different control flows is $O(2^m)$ with $m$ being the amount of branches. How...
As far as I can tell, we have invented tools and algorithm to: Detect a wider range of colors at a larger range than humans or any other animals on the planet Detect sound with wavelengths inaccessible to humans or most animals on the planet But why is it that dogs can smell COVID or Cancer and we can't produce a sim...
This is my first time posting here, so I hope I'm on topic. I have a table of natural-language data of the form [Underlying] -> [Observed] ABC -> abcd EFGH -> eghf IJK -> ik LMNOP -> lnop LNOP -> lnop and so on. There are around 5000 more of these, but this is a sort of representative sample of things that go on. For ...
Are there two function $f:N\rightarrow N$, and $g:N\rightarrow N$ such that $f(n)+g(n)\ne O(f(n))$ $\wedge$ $f(n)+g(n)\ne O(g(n))$? My idea: i think because of for any $f:N\rightarrow N$, and $g:N\rightarrow N$ then $f(n)+g(n)= O(\max \{f(n),g(n)\})$ then there are no two such functions. is my argument is valid?
Please help me understand the following $L = \{ a | a ∈ \{0, 1\}^∗, |a| = k ≥ 4, a = a_1a_2...a_{k−1}a_k, ∃i ∈ N, 1 ≤ i < k : a_i = a_{i+1} \}$ To prove: The language $L$ has regular pumping property My argumentation: Let $p = 4 $. Let $z$ in $L$, with $z$ $\geq $ $p$. Set $u$ to $\epsilon$. Than $x$ is the first lette...
Can anyone help me understand the time and space complexity here? I know zip() is O(1) and sorted() is O(n). The loop has the operation min() inside but is operating on just 2 values so is that also O(1)? If so then every operation in the loop is O(1) so the overall time complexity is O(n) correct? For space, z could g...
Input : $x \in \mathbb Z$ and $a_1,a_2,\dots,a_n \in \mathbb N$. Output : $b_1,b_2,\dots,b_n \in \mathbb Z$ such that $\sum_{i} a_i b_i=x$ and $\sum_{i}|b_i|$ is minimized. Main question is, can we solve this problem with greedy or parallel algorithms?
I am trying to model a problem to enable me to use Dijkstra's Shortest Path algorithm. Given are a set of vertices V, and a set of vertices X ⊂ V. Between these vertices are given a set of edges where: edge(u,v) with u ∈ V \ X being weighted > 0 edge (u,v) where u ∈ X being weighted = 0 other edge combinations (i.e. u...
I'm starting to dig into the RAFT consensus algorithm and I wanted to clarify something pretty basic: it seems like RAFT operates on the assumptions that 1) each node trusts all the other nodes and that 2) nodes would not have a failure mode where they would incorrectly identify themselves as a leader from a higher ter...