instruction
stringlengths
35
29.1k
Let A be a nonempty alphabet, $X ⊆ A^*$ a decidable set, and $Y ⊆ A^*$ be a semi-decidable set. We assume that $Y ⊆ X$ and that $X \setminus Y ⊆ A^*$ is semi-decidable. Show that then the set Y ⊆ A∗ is decidable. I am looking for some ideas where to start this problem. I think we need 2 TM's which check each input sim...
I am considering geometric graphs $G=(V,E)$ where $V$ is a set of points in $\mathbb{R}^2$ and the edges are straight line segments between vertices. See the image: Now I want to calculate all pairs of edges that cross, i.e. intersect in their interior. I want to do this as efficient as possible. I could brute-force i...
What is the logic behind using a loop invariant proof for proving the correctness of an algorithm? How is it proved that using the loop invariant proof indeed proves the correctness of a loop?
For a state of the art compiler, can they successfully do type inference on all of these cases, or are there some in which they can't? If there is a place which collects a bunch of test cases which a compiler should handle, please let me know, that would be wonderfully useful in building a compiler, and would also prob...
My question is about the algorithm in the article Linear-Time Self Attention with Codeword Histogram for Efficient Recommendation, as described in the picture below. It is written at beginning section 3.1 in the article $X$ is a matrix but It is seen the figure 2 a sequence of codeword indices represented as a vector ...
I am a final semester pure math undergrad, and I became interested in Linear Cellular Automatas.I became interested after reading Klaus Sutner's article. In the article, a little abstract algebra is used, linear mappings, a vector space over $F_2$, I did use a bit of group theory to prove tiny things here and there. Qu...
I want to study operating systems in depth, in particular windows, linux and android OS. What is the best way to get started?
The Word type (in kind lang) looks like this: type Word ~ (size: Nat) { e ~ (size = Nat.zero), o<size: Nat>(pred: Word(size)) ~ (size = Nat.succ(size)), i<size: Nat>(pred: Word(size)) ~ (size = Nat.succ(size)), } The syntax is defined here. All it says is: type Name (A: Par0, B: Par...
This problem is based off of the following problem on stack overflow: https://stackoverflow.com/questions/64797299/greedy-algorithm-to-maximize-score. The second answer is incorrect because the answer $[3,4,1,6]$ does not satisfy the constraint that games must be played at or before their deadline, and game $1$ is pl...
Can we solve this recurrence relation : $T_n = \exp(T_{n-1})$ ? Thanks!
What follows is a pretty complicated object (in an object-oriented, imperative, typed language), which I would like to create a type for with some sort of type annotations. I am open to how it is done, just trying to see how to get fine-grained in the types we specify, as they are relations between far-reaching parts o...
This exercise come from Sipser (1.68). In essence, show that if $A$ is regular, then $CUT(A) := \{yxz | xyz \in A\}$ is regular. I've managed to show that $B = \{yx | xyz \in A\}$ is regular. Furthermore, I've shown that $SUFFIX(A) = \{z | xz \in A\}$ is regular. My idea was to then say that $CUT(A)$ is precisely the c...
I have used different machine learning algorithms to predict solar panels' power output. There are ten independent features for weather data. In all models, I set time as an index and have used the following rule for splitting the data : X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.18, random_s...
I need a book recommendation for graph theory which supposes background in set theory. I want to cover those questions first as graph theory is part of combinatorics. Can you recommend me a book which is beginner-friendly without going much into combinatorics? I heard about Harris and West but these books use too much ...
I want to generate all solutions of $x_1+x_2+\ldots+x_{100}=6$ where $x_i$s are non-negative integers. Finding the number of such solutions is not difficult. But is there any easy way to get all solutions?
I am relatively new to writing proofs and I am stuck trying to prove that if $x$ ~ $y$, then $x^R$ ~ $y^R$. Any help would be appreciated!
I haven't been able to track down if there is a generally accepted practice for assigning a Big O value when dealing with functions of unknown runtime. Given the following pseudocode, with two functions that operate in an unknown time, is it typical to assume the processing is constant time, or would it be more correct...
I am trying to create a calculator in excel for use in Minecraft later and I was wondering if the was any way to create and how I would create a base 10 to base 2 converter with only logic gates. if you need the .xlsx file for reference I will put it in the comments.
In the paper by Cho et.al., section 2.3 details the equations for the modified LSTM cell in RNN used in the paper's implementation. The equation in question is : Here, the output of the reset gate (r) is element wise multiplied with the previous hidden state h<t-1>, and then matrix multiplied with the U matrix. Later ...
Formatting code or things like TeX have some interesting problems. For instance in auto-formatting code you want to use up as much line space as possible but not go over a certain limit if possible. This turns out to be a little bit less trivial than it sounds but has been worked on (see here and here) and very nice in...
I was able to understand the problem of at most k edges and exactly k edges but I am not able to wrap my head around how do I solve the problem of getting shortest paths with at least k edges. You can traverse same edge twice until you reach the minimum required number of edges. An example of implementation is going fr...
On modern architectures, random number generators get seeded by the current system time as a source of randomness, which is nice because it is kind of unpredictable when a process will switch to the current process. When this timer is in milliseconds or nanoseconds for example, you will get a good random number seed. ...
For example, the following grammar will never stop deriving a complete sentence: S -> A b A -> a A Some other CFGs can derive a complete sentence, but it still is possible to wind up in a infinite loop, e.g. S -> A b | b A -> a A Currently I am writing a LR parser generator. If it doesn't check if the input CFG is in...
For our web application we are maintaining some data, pertaining to our subscribers, on our server. Some of this data is sensitive and we would like to implement some "security measures" for this data. One is encryption, and we know how to do that. The other is non-repudiation of the content, and we don't know how t...
Consider the set of all possible two-to-one functions that map inputs from $\{0, 1\}^{n}$ (domain) to outputs in $\{0, 1\}^{m}$ (co-domain) and let $m > n$. If I pick a function randomly from this set, what is the probability that it can be computed by a Boolean circuit of size $\text{poly}(m)$? Note that while the co-...
I tried to solve the recurrence $T\left(n\right)=\sqrt{n}\cdot T\left(\sqrt{n}\right)+c\log n$ using the Master Theorem. I tried the following way: $n = 2^k$ $2^{\frac{2}{k}}\cdot T\left(2^k\right)+\log2^k$ $2^{\frac{2}{k}}\cdot T\left(2^k\right)+k$ At that point i'm stuck and not sure how to handle the $2^{\frac{2}{k...
Let B be an undirected tree with |V| nodes given as adjacency list. I want to develop a greedy algorithm using pseudo code to find a maximal matching in runtime O(|V|). I understand that the solution is: Find all leaves. For each leaf if the parent edge has not been seen by another leaf, mark the edge to its parent as ...
In "Types and Programming Languages" by Benjamin C. Pierce (WorldCat) 5.3.2 Definition: The set of free variables of a term t, written FV(t), is defined as follows: FV(x) = {x} FV(λx.t₁) = FV(t₁) \ {x} FV(t₁ t₂) = FV(t₁) ∪ FV(t₂) \ is relative complement Based on above definition of free variables my understa...
I am trying to traverse through all uint64_t with k 1s. Then I find that if x and y are circular shifts of each other, they will output the same result. So I'm trying to optimize my code. The problem is I don't know how to exactly traverse through the set of numbers that has exactly k 1s, and also unique under circular...
As far as I know, Immerman showed that first-order logics extended with transitive closure (TC) captures (non deterministic) logspace (over ordered domains) [1]. That is, any database query that can be computed with $k*log(n)$ space, can be defined through a first-order logic query with TC. To show so, Immerman emulate...
I am trying to find the runtime of: $T\left(n\right)\:=\:n\:+\:\sum _{i=1}^{n-1}\left(T\left(i\right)\right)$ $T(1)= 1$ What is the way to solve this kind of problems?
So, we have the tables: Person (SIN, Name, Address, Owner_id) Owner (Owner_id) Vehicle (Vehicle_id, Plate_number) Car (Vehicle_id, Cmodel, Cyear) Truck (Vehicle_id, Tmodel, Tyear) Owns (Owner_id, Vehicle_id) How do I format a relational algebra statement so that I get the number of people who only own cars (not truck...
For some reason—at least when classes are involved (which I don't know the reason for yet)—in IPv4 the number of host addresses available per network is given by $2^\textrm{host bits} - 2$. Why don't we have $2^\textrm{host bits}$ host addresses available?
Statement Consider the following modified node structure for the linked list: struct Node { int value; Node* next; Node* random; } The next field points to the next element in the list. The random field points to some other node, which is guaranteed to be in the same list. E.g. (black arrows denote next, purp...
Similar to this question but items don't have value $v$. Max weight $W$, every item has weight $w$, must add exactly $L$ items to the knapsack, need to get max weight as possible.
I want to implement all of the data structures from scratch but testing them is not an easy task. So, I wanted to ask if any of you know repository containing Class, Method Stubs for popular data structures and also their tests. Especially, unit tests are of a great importance. Thanks in advance
Let me put it this way. I have two arrays A and B. Array A contains manufacturing dates of cars, and Array B contains corresponding car model names. A and B are in correspondence. Now I want to sort array A but at the same time the coordination of both arrays should not break. Whats the best way to do that? Example: Ar...
I am looking to write a program analysis for Java programs that tracks assignments and is able to discern: whether a class field (static or not) is read and where the read originated whether a class field (static or not) is written and where the write originated properties of the value that is written: 1) is it a scal...
I have a converter between two context-free grammars which are both describing the same language but one uses infixes other than prefixes, has different symbols and sometimes switches order of nonterminals. It's a converter in a sense that it takes an expression in one grammar and outputs its equivalent counterpart in ...
You are given a team's win probability for each game on their schedule in the form P[1..n] where P[i] is the likelihood they win game i. Give a dynamic programming algorithm that returns the most likely number of wins, and the probability of this outcome, using O(n) space. For example, if n = 2 and P = [0.4, 0.2], the ...
I am trying to solve a recurrence relationship as follows: T(n)=T(n^1/2)+O(loglogn) I can solve the T(n^1/2) part quite easily, but I am completely lost as to what to do with an O(loglogn). I cant use the masters theorem since loglogn cannot be expressed in the form of n^x and using trees, I don't believe I can just dr...
I want to prove this: For any binary tree T, let f(T) denote the sum of the depths of all of the leaves of T. (The root is at depth 0, the children of the root are at depth 1, the grandchildren of the root are at depth 2, etc) Prove that f(T) = Ω(l log l) for any l-leaf binary tree T. Any suggestions?
Given I have two sets of objects $A =\{a, b, c\}$ and $B = \{a, b, c, a\}$ Based on the set equality, I want the fingerprint of these sets to be the same $F(A) = F(B)$. Additionally I want to be able merge fingerprints in order to calculate the fingerprint of the union. $F(\{a,b\} \cup \{c,a\}) = Merge(F(\{a,b\}), F(\...
A sports league wants to use an algorithm to decide when & where each team will be playing another team in the league. Each team will play the other team in either the first team's home city or the second team's home city. For example, if this is the National (American) Football League, the Houston Texans would play th...
Let $F$ be a field. Suppose we have a machine $T$ that works with words that are elements of $F$, for exmaple $F = \Bbb{Z}/2, \Bbb{Q}$ (using arbitrary precision arithmetic), or $\Bbb{Z}/p$ for a prime $p$. Empty memory is represented by the vector space $F^0 := 0$. If an algorithm addresses $n$ memory slots, that w...
I'm currently taking my algorithms class, and I learnt that Big theta is defined as follows: $f(n) = \Theta(g(n))$ if there exist constants $c_1, c_2, n_0 > 0$ such that $0 ≤ c_1g(n) ≤ f(n) ≤ c_2g(n)$ for all $n ≥ n_0$. So if our $f(n)$ and $g(n)$ are of the same order, say $n$ and $2n$, we can easily find a constant...
This is what I got from another forum, but honestly doesn't make much sense to me. Time complexity for a single tree doesn't make a lot of sense, since the function in the big O notation might be nowhere near the actual computation time. Time complexity is all about how the algorithm scales as the inputs get larger. ...
In a market there are N different items where each item is unique and identified by id (1-N). There are also K buyers with names (1-K). Each buyer has 2 items that they want to buy (A, B), where A is the id of the first item and B is the id of the second item. Each buyer will either buy one or no item. If the first ite...
I have $k$ sets of similar sizes, that cover a universe $U$. e.g. for $k=3$ and $U = \{1, 2, 3, 4, 5, 6\}$: $S_0 = \{1, 2, 4\}$ $S_1 = \{2, 3, 4\}$ $S_2 = \{4, 5, 6\}$ I have another larger set $C$ guaranteed to be subset of $U$. $C \subseteq \bigcup\limits_{i=0}^{k} s_{i}$. e.g. $C = \{1, 2, 3, 4, 5\}$ I want to be ab...
I want to prove that the following problem is NP-Complete. Input: Set $S = \{s_1, \dots, s_n \}$, set $T \subset S \times S$, that contains ordered pairs $(s_i, s_j) : s_i \neq s_j$, and an integer $k \geq 1$. Output: Is there a permutation $p:\{1, \dots, n\} \rightarrow \{1, \dots, n\}$ for the elements of $S$, so th...
I have just started my masters without any substantial experience in programming and I am struggling to understand certain concepts. I have been given the following language $$L = \{a^i b^j c^k \mid i, j, k ≥ 0, \text{ if } i = 1 \text{ then } j = k\}.$$ However, I am struggling to find a way to prove that it is not re...
Given two bitmap images (two arbitrarily sized two-dimensional matrices of integer values ranging from 0 to some maximum number), I want to determine their maximum overlaps. An overlap is a relative positioning of the images (a translation of the second image) producing a nonempty intersection on which both images are ...
I want to show that a subproblem of the known, $\mathcal {NP}$-Complete, Sparse Subgraph problem is also $\mathcal {NP}$-Complete. Sparse Subgraph problem: Input: Undirected graph $G(V,E)$, two integers $k, l$. Output: Is there a subset $S \subseteq V$, where $|S| \geq k$, such that there are at most $l$ edges between...
I'm writing a web app that requires a component that let's the user input a piece of text thats automatically formatted based on something the client calls "macros". These macros have a very specific syntax. Examples: "{{ greetings_alternatives}}, my name is {{ names_alternatives|cap }}" -In this example, {{ greetings...
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$...