instruction
stringlengths
35
29.1k
I have two multisets $A$, $B$ where $A \subseteq B$. Using these two sets, we construct two Bloom filters $BF(A), BF(B)$; both using bitsets of size $n$ with the same $k$ hash functions. What's the probability that: $A \not\equiv B$ but $BF(A) = BF(B)$ Notes: Since $A$ and $B$ are multisets, they might have duplica...
I have read that information management is a function of O/s by which it A) Manages, stores, retrieves,modify data. It makes sure that right people have access to their information. B) Some of the system calls in this category are as follows: Create a file Open a file (for, read, write or both). Create a directory Rea...
The following paragraph is from the book CLRS: Given an ordinary hash function $h' : U \rightarrow \{0, 1, ..., m - 1\}$, which we refer to as an auxiliary hash function, the method of linear probing uses the hash function $h(k, i) = (h'(k) + i) \; \text{mod m}$ for $i = 0, \: 1,\: ... ,\: m - 1$. Given key $k$, we fir...
Given two sorted arrays $a_1,a_2,\dots,a_n$ and $b_1,b_2,\dots,b_m$, merge them together into one sorted array $c_1,c_2,\dots,c_{n+m}$ containing the elements of $a$ and $b$. The typical mergesort method works in $O(n+m)$, and if we run binary search for each element from one of the arrays, it works in $O(\min(n,m)\log...
Let $T$ be a max heap tree with no duplicate values amongst the nodes. When does $T$ satisfy the following. Remove the root, and restructure the tree to satisfy the heap property. Reinsert the root, and restructure the tree to satisfy the heap property. After 1, and 2, the resulting heap is exactly the same as the or...
I am given a graph $G=(V,E)$ undirected and two vertices, the source vertex $s$ and the target vertex $t$. Additionally, each edge comes with a capacity $c(e)$ (non-negative) and a set of weight functions $w_1(e),...,w_k(e)$. To simplify things, assume these weight functions are non-negative as well. I am also given a ...
a) We know that solving consensus in asynchronous distributed systems is impossible. b) Let the consensus number of a concurrent object be cn = 2, which means that two processes can solve consensus using the concurrent object. From (a) and (b), can we conclude that the concurrent object cannot be implemented in asynchr...
$L = \{$$a^mb^nc^pd^q \mid m+p = n+q,$$\text{ where } m, n, p, q \geqslant0\}$ If, for instance, we try to construct a PDA for a similar language $L2 = \{$$a^mb^nc^pd^q \mid m=p $ $\text{and}$ $ n=q,$$\text{ where } m, n, p, q \geqslant0\}$, it is clearly not possible to come up with one. Then, why is $L$ context-free?...
For learning purposes only, I would like to make a small, fairly basic computer algebra system (CAS) manipulating mathematical expressions, such as polynomials, logarithmic or trigonometric expressions. One of the key features of this style of project is the simplification of expressions. For example, we can ask to sim...
I'm working my way on a problem which requires me to store elements in fixed 4KB-sized pages on an SSD. Each page is requested once for some computation on its elements, and then the CPU requests for another different page from the SSD. I'm trying to ascertain whether any page contiguous-ness can be exploited here for ...
Let's assume that for every $e\in E$ it holds that $c(e)$ is an integer. Does it mean that there exists a max flow $f$ that for every $e\in E$ it holds that $f(e)$ is an integer? It sounds obvious but I can't exactly say why it is true.
I am currently working on a project where I need to detect bold text on a multi font-size image (so no mathematic morphology possible). This detection will be used in parallel of an OCR system (with tesseract) to detect which information (in bold) are important in a document. I already tested the wordFontAttribute() fu...
I have two arrays. One array represents items. The other array represents bins with capacity. I need to find if all items can be stored in the bins. An item can only be placed in a single bin. But multiple items can be placed in the same bin. Example, Items: [10, 20, 30] Bins: [40, 20] Yes. Bin 1 can store items 1 and ...
I've been looking for places where I would find regular graphs in the real world. I know that there are many applications for graphs in general (I've seen this question: What are some real world applications of graphs?), but I can't find any applications for regular graphs. Surprisingly, Google doesn't give me any answ...
I understand that vulnerable time in CSMA cd is Tp (Propagation time). This is because collision can occur in Tp duration since one bit has to travel to the end. My question is- Why that is not true in the case of Aloha ?. Why we do not have the same vulnerable time in Aloha? That question has already been asked but no...
Is there a tool to compute the accuracy of a function in a program? Perhaps a static tool or some debugger-based tool that logs each time an arithmetic operator is applied? So one can avoid quirks in floating-point arithmetic, like destructive cancellation and similar.
Given an undirected graph $G=(V,E)$ and 2 sources $s_1,s_2$ and 2 targets $t_1,t_2$, I am looking to find paths $P_1$ and $P_2$, where $P_i$ is a path from $s_i$ to $t_i$ and $P_1$ and $P_2$ are edge-disjoint. One attempt is to find $P_1$ by DFS or BFS, and then find $P_2$ using a DFS/BFS with the remaining edges. Obvi...
It's possible to modify a graph search algorithm such as Dijkstra's or A* to allow for non-additive objectives or constraints. Is there a standard treatment for these algorithms to reduce unnecessary expansions? For instance, consider a weighted graph $G=(V,E)$, with some edges colored red, and consider the problem of ...
What is a pseudocode of try-catch? Is it this? **Try** SOMETHING If you succeed Do nothing special Else, if you didn't succeed Do what's described in the **Catch** block Anyway, either if you succeeded or failed Do what's described in the **Finally** block (if there is one) Update I aim to find the pseud...
For clarity, I'm talking about this theorem. My confusion lies at the fact that we can seemingly compute any real number by re-arranging a conditionally convergent infinite series, but apparently we can't actually compute every real number, so I'm not sure where I'm wrong.
I was on a interview with an algorithm problem, which I cannot seem to solve nor find a solution already for it, but I'm really curious how it can be solved. Here is the problem. You’re working on making some mini-games, and you’ve decided to make a simpler variant of the game Mahjong. In this variant, players have a...
One of the characteristics of functional programming is as follows: You’re describing the result you want rather than explicitly specifying the steps required to get there. I found this quote at https://realpython.com/python-functional-programming/. I don't really understand what is the meaning of this. Functional Pr...
Suppose a convex polygon $P$ in plane is given. We want to triangulate it such that any arbitrary line $L$ intersects with $O(\log n)$ triangles. I divide $P$ in half using a diagonal line. Then I continue in each half in the same way. But at this step I get stuck.
I have just started out theory of automata in my university and we are studying the pumping lemma. From what I have understood, the lemma states that $y \neq \lambda$ (where $\lambda$ is the empty string) and that $xy^iz$ (where $i \ge 0$), so if $i = 0$ then $y^0 = \lambda$ and the string is still accepted. How do the...
I'm new in computational geometry and I have the following question: Suppose Given $n$ disjoint axis parallel rectangles $R$ in plane. We want preprocess $R$ in $O(n\log n)$ with $O(n)$ space such that for each given point $q$ we must find a rectangle that contains $q$ in $O(log^2n)$. I have no any idea for solving th...
How can I create a DFA automaton that will have every four digits (if they exist) at least two 1s for strings of languages with alphabet {0,1}? The expression at least two 1s seems easier than the expression every four digits
I would like to clarify something in my understanding of proving a problem to be NP-hard. So in short, what I know is that: "If I have a problem A that I want to prove that is NP-hard and another well -known NP-hard problem B and I can find a polynomial time reduction R such that if I answer A I know the answer to B as...
I'm taking an algorithms class for my computer science degree, and one of the requirements is to research and present 3 different algorithms. The only problem: linear algebra wasn't a prerequisite to the course. Which of these algorithms would be the easiest to understand with the littlest math background? I plan on go...
I started studying through Aho, Ullman - Foundations of Computer Science as a free time exercise. In the second chapter about loop invariants and inductive proofs, there is a starred exercise. int sum = 0; scanf("%d", &x); while(x >= 0) { sum = sum + x; scanf("%d", &x); } printf("%d", sum); Read a number into ...
I am reading on https://en.wikipedia.org/wiki/FO_(complexity)#Iterating that FO[$t(n)$] consists in first-order logic with an iteration operator that iterates $t(n)$ number of times some quantifier block Q. Can someone provide me an example of a formula using such operator, please? I feel that I am not understanding th...
Is try...catch a control flow pattern such as if-than-else-elseif or switch-case-break-default? Would another definition be better than control flow pattern for it?
I have read the question asked here Is polynomial reduction reversible and the logic actually makes sense to me. In other words, if A is polynomially reducible to B, it means that A <= B in terms of hardness. However, when I thought more about the reduction process, I am confused. As far as I can understand, the NP-Com...
I was studying computational geometry on my own from "Computational Geometry: Algorithms and Applications" - by Mark de Berg. In chapter 9, i.e. Delaunay Triangulation, there is an exercise that reads: A Euclidean minimum spanning tree (EMST) of a set P of points in the plane is a tree of minimum total edge length con...
Let $G=(V,E)$ be undirected, and let $s,t\in V$ and $C\subseteq E$ be a circle that contains $s$ and $t$. Assuming $s$ and $t$ are on the circle $C$, we are given a set of edges $F\subseteq E$ which are to be removed. After removing these edges, we want to verify whether the remaining edges from the circle $C(F) = C \b...
I am studying this article. But I have trouble with understanding the Buchi arithmetic. It says in section IV: ... Formulas in this fragment generalise classical integer programming and are of the form $$ \mathbf{A} \boldsymbol{x}=\boldsymbol{c} \wedge \bigwedge_{i \in I} V_{p}\left(x_{i}\right)=y_{i} $$ But I don't ...
Given the following problems: 2VertexDisjointPaths: Given: a directed Graph $G$ und vertices $s1, s2, t1, t2$. Question: Do paths $p1$ from $s1$ to $t1$ and $p2$ from $s2$ to $t2$ exist if $p1$ and $p2$ are vertex disjoint? Vertex disjoint meaning if $p1$ uses a vertex $p2$ can't use it and vice versa. SimpleCycle: Giv...
I'm working on a graph problem that basically boils down to an edge-coloring problem. I have a graph where all vertices have (at most) an in-degree of 2 and an out-degree of 1. I thought this would make it such that I could color all edges using only 3 colors, however based on the wiki page, it seems like this doesn't ...
A while ago I defined the language HaltingFuck, but I've never been able to figure out its computational class. The language is defined as follows: HaltingFuck is a language very much like Brainfuck, with one key difference: instead of loops stopping when the value in the current cell is zero, they stop when the value...
I'm a CS Year 2 student working on a team project which requires a solution to the following problem: Given a starting position on the edge of an irregular shape (example above) and a maximum number of available agents, maximise the area covered (meaning the number of squares visited inside the shape*) while minimisin...
The set of (non-generalized) regular expressions over an alphabet $\Sigma$ is the set of expressions generated by the following grammar, where $a\in \Sigma$ ranges over symbols in the alphabet: $$ \pi ::= \epsilon \mid \emptyset \mid a \mid \pi_1\cdot\pi_2 \mid \pi_1\cup\pi_2 \mid \pi^*. $$ Here, $\epsilon$ stands for ...
I am not able to solve the following recurrence relation: T(n)={T(n−1)+n(n-1) if n≥2,T(1)=1.
I am to parse through a series of strings with a given token list. I was wondering if my lexical analysis is correct. T1 = { abc, abc1 } T2 = { abd, abd1 } ID = [a-z]+[a-z0-9] NUM = 0 | [1-9][0-9] lexer.getToken() will return the current token and advance the input buffer by one. lexer.peek(num) will return the token ...
Let's say we have a red-black tree of $n$ total nodes where all keys are distinct. The subtree rooted at the root node's left child has $n_L$ nodes, and similarly the subtree rooted at the root node's right child has $n_R$ nodes. What is the range of values on $n_L$ and $n_R$ for any $n \geq 3$? From Red Black Tree vs...
Let V be a set of vertical segments, and H be a set of segments parallel to a line (e.g. a line with slope -1). We want to find a data structure for set S = V ∪ H to find all pairs (v,h) of segments intersecting in an axis-parallel query rectangle, where v∊V and h∊H. For orthogonal input segments (i.e. segments paralle...
I'm reading the book Computational Geometry in C by O'Rourke. One of the problems ask the following Diagonals$\rightarrow$triangulation. Given a list of diagonals of a polygon forming a triangulation, with each diagonal specified by a counterclockwise indices of the endpoints, design an algorithm to build the triangul...
I've faced this problem with my homework. We're given a weighted, undirected graph $G=(V,\ E,\ w)$ with weight function $w:E\rightarrow \mathbb{R_{\ge0}}$, someone deleted the weights of some edges $T\subseteq E$ so their weights are unknown. Describe an efficient algorithm that finds the following: For every $e\in T$...
Since UNARY SUBSET SUM is in P, and a positive-only SUBSET SUM problem could be represented in unary, I struggle to see why it wouldn't be the case that it is in P, when restricted to positive numbers?
The Canteen Queue Problem There is a common canteen for K hostels. Each hostel (co-ed) has some $N_1,N_2,...,N_K$ students. These students line up to pick up their trays in the common canteen, in a queue. The queue is implemented as follows: If a student sees a person from his/her hostel, she/he joins the queue behind ...
Consider a car that can hold gas to travel a distance of $c \in N$ kilometers (its capacity) on a full tank that's initially empty. The car starts in node $s \in V$ of a graph. Each vertex $V_i$ of the graph has a gas station where the car can (not necessarily fully) refuel at price (i.e. cost) $p(V_i) \in R_{>0}$ per ...
Suppose we want to find the value of $x$ that minimizes $$ f(x)=\frac{1}{2}\|A x-b\|_{2}^{2} . $$ Specialized linear algebra algorithms can solve this problem efficiently; however, we can also explore how to solve it using gradient-based optimization as a simple example of how these techniques work. First, we need to ...
How do I take the average of multiple fast Fourier transforms (ffts)? I have multiple audios that I want to take the fft of and then average these results to smooth out the random noise that appears in each audio. The ffts of the audios are shown in the graph below. However the problem I'm having is that I can't work ...
I would like to know if it is impossible to use K-fold cross-validation for time series of data. It has been discussed that it is not reasonable to predict past from future, but I think this does not make sense since time series data might be repeated in the future. Suppose a past fold is going to be repeated in the fu...
The Canteen Queue Problem: There is a common canteen for $K$ hostels. Each hostel (co-ed) has some $N_1, N_2,...,N_K$ students. These students line up to pick up their trays in the common canteen, in a queue. The queue is implemented as follows: If a student sees a person from his/her hostel, she/he joins the queue beh...
Given a graph $G$ and an integer $k$, is it NP-complete to decide whether there always exist $k$ different disjoint paths between any pair of vertices of $G$?
Consider the context-free grammar G = ({a, +, ∗}, {S}, {S → SS+ | SS∗ | a}, {S}) and consider the string aa+a* generated by this grammar. Is this grammar unambiguous? I have browsed the Internet and I have found that there is no standard procedure for proving if a grammar is unambiguous or not. But sometimes induction ...
I'm struggling with implementing O(n+k) radix sorting algorithm for pairs of numbers which values are constrained . For example below is array of {x,y} before and after using modified radix sort where max_x=10 and max_y=3 {1,2} {1,1} {10,3} {1,2} {1,1} ----> {5,2} {5,2} {5,3} {5,3} {10,3} H...
A finite set of individuals provide bounded non-binary pairwise ratings of other individuals (say, -10 to +10), forming a directed graph (cycles possible). I'd like to determine aggregate ratings for each individual that considers all of that individual's inbound ratings and the aggregate ratings of the upstream indivi...
Can you help me design an algorithm to solve the following problem in polynomial time? Let n be a given natural number. We define an input series of length n to be a string of length n which is built by using only the characters F, S and - (hyphen). At least one F or S is guaranteed to appear in each valid input series...
I'm doing a school project where I have to design a password manager app. I was wondering what the data model would look like. I know that I will have the user database to store authentication informations but where do I put the informations when user create vaults? Would it be something like this? User { username, pas...
So, if I were to represent 23 in binary, what are bits here? Are 0 and 1 called bits? What they mean when they say I have five bits of information?
I have to give the transition diagram of an NFA accepting all strings that are not empty and start and end with the same symbol, I should also use non-determinism as much as possible (language is {0,1}*). I drew the following diagram: Even thought this is an NFA (as all DFAs are NFAs too), I did not really use non-det...
I am working on the following exercise: Let $(S,\mathcal{F})$ be a matroid and let $c:S \rightarrow \mathbb{R}$ be a weight function on $S$. Find an algorithm that solves the following problem: MAXIMISATION PROBLEM FOR INDEPENDENCE SYSTEMS (MAX IS): Find an $F \in \mathcal{F}$ such that $c(F)$ is maximal. From the le...
Let $G = (V,E)$ be a directed graph with source $s$ and sink $t$ and $s \neq t$. For each edge $e \in E$, we have $c(e) \in \Bbb N$. also, we are given a max flow function $f$ on that network. Let $R_f$ be the residual network that represents the max-flow $f$. I would like to prove that if $R_f$ has a directed cycle wi...
What are bits and bytes? How do they differ? What role do these notions play in the computer science world? Why do talk about 8 bits = 1 byte = 256 states or different patterns? What's the rationale behind it? Why not 4 bits = byte? What is so special about 8? How much info can a bit and a byte hold?
Let $d_j \in \mathbb{Z}_{\ge 0} =$ jth duplicate unearthed by a freeware de-duplicator (like AllDup1). $t_j >0 =$ time taken to unearth the jth duplicate. $f \in \mathbb{N} =$ total number of files being searched. $f_j =$ number of files already searched by de-duplicator at $t_j$. Plainly, $\uplus_j \; f_j = f$. M...
I want to learn prolog,two reason for that are -one can always find a counter example to the argument by searching for negation.So,one can learn by debugging the scripts.I heard that prolog is based on horn clause logic ,so want to learn more about it.
I was asked in an exam wether we could improve the SA algorithm by keeping a memory of the best N solutions (so far). I couldn't find any examples of this being done in practice. I could only think that we could use this to avoid areas that seem to converge to higher energy levels, and thus complete the search faster. ...
Assume that in classical Local Search algorithm for MAX-SAT we could flip no more than $r \leq n/2$ variables (let's call it $r$-flip) on every iteration. More precise: on every iteration we're finding $r$-flip which satisfies more clauses then was satisfied before the flip. What is the approximation ratio of this alg...
I've faced this question in my homework. In a graph $G=(V,\ E)$ where every $v\in V$ has a color, a colored path is a path such that it has at least one vertex of each color. We're given a directed graph $G=(V,\ E)$, weight function $w:E\rightarrow \mathbb{N}^+$ (in other words the weights are positive) and every verte...
You have a list of $n$ items you want to sort over $r$ rounds using binary comparisons. In each round, you specify $k$ binary comparisons to be made in parallel. The objective is to fully sort the list. For example, if you want to sort in $r\in \Theta(n \log(n))$ rounds, then you only need to make $k=1$ comparison per ...
I have an NP hard problem $P$ that takes in arbitrary $G = (V, E)$ as input. I have another problem $Q$ that I want to show is NP hard, and this problem has arbitrary complete graphs $G'$ as input. Is this enough to say that $Q$ is also NP hard, since it is a subclass of the NP-hard problem with arbitrary inputs, or is...
Unfortunately copy/paste doesn't work for this paper Inductive Definitions and Type Theory, but here is a snippet. The paper begins by stating: The first sentence of the second paragraph says type theory as a theory of inductive definitions. I have never really paid much attention to how central induction is to type ...
I have seen examples of how to find the solve the recurrence for T(n) = T($\sqrt{n}$) + n, but how do we go about if there is another T(n/2) in there? So I tried to unfold the recurrence out and this was what I got: T(n) = T(n/2) + T($\sqrt{n}$) + n = T(n/4) + T($\sqrt{n/2}$) + T($\sqrt{n}$/2) + T($\sqrt{\sqrt{n}}$) + ...
A pixel is contained of 3 ranges of RGB color synthesis to add colors into a tiny-square small box, as I learned (correct me if I am wrong). But, through these 3 colors admixture can we create any texture of color to display on the screen? So, for example, with these 3 colors, can we make black, pink, purple, saffron, ...
I need to solve an optimization problem, whose search space is all possible topological orderings of a DAG. There is a cost function associated with each ordering, which has no simple mathematical representation -- I have a black box which, given one of the orderings, will return the cost associated with that ordering....
We have a directed graph $G=(V,E)$ and each vertex $v\in V$ has a cost: $price(v)$. Our mission is to find an algorithm that runs in time $\mathcal{O}(|E|+|V|)$ that finds $\forall v\in V$ the minimal price of all vertices $w$ which are reachable from $v$ (all vertives $w$ s.t. there is a path from $v$ to $w$). Note th...
Say you are editing a document like a 1000 page book. There are 20 authors all working furiously to edit the book. Every day they are merging their changes 2 or 3 times with the main branch. According to my understanding of git snapshots, this would create a new copy of the document every merge, so by the end of a year...
I've tried approaching this problem by contradiction, but that did not lead anywhere. Now I am attempting a proof by construction. i.e. given a language $L_1$, construct a language $L_2$ that cannot be mapping reduced to $L_1$.
I have a variable $d_{i} \in \mathbb{Z}$ with an upper and lower bound. I also have a binary variable $v_{i}$ which I want to $=1$ if $d_{i} \geq 0$; else $v_{i} = 0$. How do I enforce this as a linear constraint? I have seen this post but it is different to my problem as I have the inequality ($\geq$) whereas they mer...
Given a 4SAT instance such that: Each clause has 2 negative and 2 positive literals. Thus, the clause is 'balanced'. Each literal occurs exactly 2 times. Is this instance of 4SAT NP-complete? I am aware that the 2P2N-4SAT problem is NP-complete (Proving 2P2N SAT is NP-Complete), but is the balanced cases also NP-Comp...
A friend sent me this question and I've been stuck on it so if anyone could help I'll be thankful. Reminder: As we know Huffman coding is a lossless data compression algorithm. The most frequent character $\sigma \in \Sigma$ gets the smallest code and the least frequent character gets the largest code. The variable-len...
I recently submitted an answer to the following question (homework in algorithms course): A guy has m shirts, n pants, and p belts. he wants to make the maximum amount of outfits while abiding by these rules: Every item can appear at most in one outfit Not every pant can go with the same shirt (we have n X m boolean...
I start with a complete edge-weighted unbalanced bipartite graph. For a known, fixed $n$ on the order of 1000: $$0 \lt n, n \in I$$ Left and right cardinalities might not be equal; for sides $U$ and $V$: $$0 < |U| \le |V| = n$$ All edge weights are known, fixed, integral and non-negative. I need to prune this graph suc...
This problem comes up in the context of game skilltrees, for example in Path of Exile. In this case, one wants to have a subgraph of the entire graph that connects all desired nodes to the origin, but contains as few nodes as possible. Is there an efficient algorithm for this, or a good heuristic? Or is it, as I suspec...
I have the following language L = {a(^i)b(^j)c(^k) | i, j, k ≥ 0, and, if i = 1 then j = k} . How do I use the fact that L′ = {ab(^i)c)^i) | i ≥ 0 to prove that is it not regular? I am given a hint that says that the regular languages are closed under the intersection operation, but quite honestly I have no idea what s...
How do I simplify this $((ba \cup ab)^∗ \cup b)^*$? I can draw the NFA for the '$ba$', '$ab$' and '$b$' term but when it comes to linking the '$ba \cup ab$' to the '$)^∗ \cup b)^*$' i am unsure how to draw the asterisk. Is it just an epsilon transition back to the starting state?
I'm having a question inspired by exercise 14 from section 1.2.1 of Donald Knuth's The Art of Computer Programming. It's phrased in the following way: (R. W. Floyd) Prepare a computer program that accepts, as input, programs in some programming language together with optional assertions, and that attempts to fill in t...
I am looking for a data structure that needs to have very fast and accurate queries to solve the following: The input: A set of 3 Dimensional axis-aligned bounding boxes B A separate 3D axis aligned bounding box b' The output: A list of bounding boxes from B that overlap or are contained in b' Traversal time is the mos...
Consider a bijective function $f:\{0,1\}^n\rightarrow \{0,1\}^n$. Let $d_k$ be the minimal circuit depth of $f$ when expressed in terms of arbitrary $k$ bit gates (i.e. arbitrary bijective functions on $\{0,1\}^k$). Suppose $d_k$ is known for $k=k_0$. Are there known bounds on $d_k$ in terms of $k$ and $d_{k_0}$? The u...
Consider the language $A = \{\langle M\rangle : M$ is a Turing Machine and $| L(M) | = 9\}$. That is, $M$ accepts the language of a set of exactly 9 strings. I want to determine if this language is Turing Recognizable or co-Turing Recognizable or neither. I think it might be Turing Recognizable considering the construc...
I had a computer science test in school and we were asked to give the complexity of a code we had to write. the complexity was undoubtedly O(mn) where m,n were unrelated to each other. I got deducted some points as I should've assumed m=n and therefore the complexity is O(n^2). I was later told we were taught to do so ...
This question is about ideas I regularly think about, and I would like to know what concepts already exist. Also I am not sure at all if this really makes sense, by now it is just a crazy idea Motivation: In all my last jobs as a software developer, I spent much time on staring at log lines, trying to find the 1 releva...
In an example question sheet for my exams our professor included “Know to explain why for non CF languages 1 stack is not enough.” We haven’t delved into CS and reclusively enumerable languages much and I can’t find the answer to this in my book either. I understand how PDAs work for CF languages though and I have a f...
I'm interested in concurrent algorithms where, if a thread is waiting for a shared resource, it must call a blocking primitive, and not busy-wait. I'll call such algorithms spin-free. Specifically, I'm interested in how powerful synchronization primitives are in terms of what spin-free algorithms can be implemented on ...
In my textbook there was the following question: How many Huffman codes can be written for a set of three characters? In the solution they said: The Huffman code is determined by the source's probability vector. The code is determined by the order of the probabilities and their combinations. When given a vector of p...
How do the 1969 and 1979 books by Hopcroft & Ullman compare? Was the 1969 book an earlier version of the 1979 book? 1969: Formal Languages and their Relation to Automata 1979: Introduction to Automata Theory, Languages, and Computation (IATLC) The 1979 book cites the 1969 book but does not describe how these two books ...
I would like to create a data structure representing a sparse matrix, where the number of non-zero values is $\mathcal{O}(n)$ (the matrix is $n\times n$). The matrix should support the following operations with the following time complexities: peek/poke an entry in the matrix - $\mathcal{O}(n)$. add a row of zeros som...
According to my course the question "Is $L(G)$ regular?" undecidable. But I was more interested in knowing the exact algorithm or proof that makes this question undecidable. To further elaborate what I mean it is like saying "Is 2 bigger than 1?" is pretty much decidable intuitively because $2 = 1 +1$.
I saw this proposition on Sedgewick's lecture slides on QuickSort, and I've been wondering why the number of comparisons is linear in the case of a constant number of distinct keys. I tried to establish a linear upper bound but failed to find the appropriate linear lower bound. Here are my workings($N$ is the total nu...
The following exercise in my homework is about string matching using the $KMP$ algorithm with a pattern that can be modified by a linear transformation. Question: We're given a text $T \in \mathbb{N}^*$ where $|T|=n$ and a pattern $P \in \mathbb{N}^*$ where $|P|=m$, in other words $T$ and $P$ are consisted of natural n...