instruction
stringlengths
35
29.1k
I am wondering if there exists an example attribute grammar that is non-circular but not l-ordered (l-ORD) as well. The reason I am asking this is one can find an attribute grammar that is circular, then it will obviously not be an l-ORD. But I am wondering if there even exists a non-circular AG that is also not l-ORD....
I have a function that needs to be represented in theta form. The below is my answer. But the correct answer is (n.2^n) Can someone please explain me how??
Let's have a static function f(n) which for a given n returns only these answers "lower" or "higher" comparing against an imaginary number x In a sorted list l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] It is obvious that using binary search we can find the position of the element in O'lo...
In problems like the 15 Tile Problem or Larry's Array problem, we use inversions in the array as a method to solve. But what's the principle behind this method and how do I know when to use inversions?
The object I am studying is a bit more complicated than a bidimensional function, but I think I can explain what I need better with a simplified example. I can provide more details if asked. So imagine I have a function of two variables with real output, $f(x,y)$, and I know that, $f(x_0, y_0) = 0$. Now I also know tha...
My doubt is related to the given SPOJ problem: Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,...,xN (0 <= xi <= 1,000,000,000). His C (2 <= C <= N) cows don't like this barn layout and become aggressive towards each other once put...
The book CLRS claims these statements before introducing the topic of universal hashing: If a malicious adversary chooses the keys to be hashed by some fixed hash function, then the adversary can choose n keys that all hash to the same slot, yielding an average retrieval time of $\Theta(n)$. Any fixed hash function is ...
I have this question from CLRS book please. Question: The square of a directed graph $G=\left< V, E\right>$ is the graph $G=\left< V, E^2\right>$ such that $(u,w) \in E^2 $ iff for some $v \in V$, both $(u,v) \in E$ and $(v,w) \in E$. That is $G$ contains a path with EXACTLY two edges between $u$ and $w$. Describe...
How is a homeomorphic embedding (in the sense of term algebra) a homeomorphism? Definition of homeomorphic embedding: Alt text: Homeomorphic embedding = `<|` =def -------- Variable x <| y s <| t_i for some i --------------------------- Driving s <| sigma (t_i,..., t_n) s1 <| t1,..., s_n <| t_n ------------------...
I do have some intuition(although I would like to be corrected) regarding why $NL!=Dtime(n^{log n})$ as for some $L \in Dtime(n^{log n})$ it might be required for the TM deciding it to read inputs of size $O(n^{log n})$ which isn't possible in logarithmic space constraints. Having an oracle access surely saves a lot of...
Q. Given two arrays, $A$ and $B$, of equal length, find the largest possible contiguous subset of indices $[i,j]$ such that $\max(A[i: j]) < \min(B[i: j])$. Example: $A = [10, 21, 5, 1, 3], B = [3, 1, 4, 23, 56]$. Explanation: $A[4] = 1, A[5] = 3$, $B[4] = 23, B[5] = 56$, $\max(A[4], A[5]) < \min(B[4], B[5])$. The indi...
Given an undirected graph $G(V, E)$, two vertices $u$ and $v$ and a natural number $k$, does a path of at least length $k$ exists between these two vertices? How can we solve this problem? I think maybe that it's in $NPC$ with a reduction of HamiltonPath but I'm not sure.
In Bubble sort, the number of swaps/comparisons is equal to the number of inversions. 1st pass it will do (n -1) comparison 2nd pass it will do (n-2) comparison....so on (n-1)n = n^2 - n Worst case of bubble sort is theta(n^2) How is the number of inversions theta(n^2) too?? please explain the logic behind this
I would like to discuss a solution with you below please. Describing the matrix product $BB^T$ of the incidence matrix of a directed graph $G=\left< V,E \right>$. Question: The incidence matrix of a directed graph $G=\langle V,E \rangle$ with no self-loops is a $|V| \times |E|$ matrix $B=(b_{ij})$ such that, $$ b_{ij}=...
Really confused about the meaning of offset in email headers. Header date reads as: Sat, 8 Jun 2019 11:45:15 −0500 Does the time shown 11:45:15 is the actual time at timezone -0500 OR Actual time at time zone -0500 is calculated by subtracting offset?? Thanks.
If the worst case arrays {5 4 3 2 1} have number of inversions as Θ(n^2) => n(n-1)/2 swaps The best case arrays {1 2 3 4 5} have number of inversions 0(no swap) What kind of arrays have number of inversions Θ(n)? {2 1 3 4 5} can this be an array with number of inversions Θ(n) as there will be only 1 swap.
This looks to me as some tweaking or generalization of Ladner's result on NP-I languages, can some help me in the right direction? or redirect me to some sources where this generalization is explicitly proven?
I would like to know what determines bus speed in a CPU. I know about bus width, that all makes sense, but since electrical pulses travel at light speed I don't understand why bus speed is measured rather than just light speed. What on the bus means the signals aren't sent at light speed? Thanks in advance.
Having a matrix $M$, with unique rows, how to calculate a minimal subset of colums $D$ such that every row is unique? Also, how to maximize the amount of unique rows, if the number of chosen columns is limited? For example: $M$ = 0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 1 0 0 0 0 0 2 0 0 $D$ (columns {4, 6} from $M$) = 0 1 0 2 1...
From what I understand, in a pipelined CPU, every stage takes 1 cycle. But instructions are fetched from memory which takes up to ~150 cycles. The CPU fetches most instructions from the L1-cache, but I've read that it takes around 4 cycles. From that logic, a new instruction should only start every 4th cycle, which obv...
I am reading Distributed Algorithms by Nancy Lynch. In chapter 16, I came across the pipe symbol. Does this mean the same as "or" in some programming languages or could someone explain that line please?
This was the algorithm for bubble sort in textbook. I tried the with WHILE loop, then I tried the same with the for loop. My answer is not sorted. Why? I follow the above algorithm in Python 3.0. My attempt Step1: I created a swap() function. it was working perfectly. Step2: I made bubble_sort() function following th...
The definition given below is present in the exercise of the text Database System Concepts by Korth et. al. Let $\alpha$ and $\beta$ be sets of attributes such that $\alpha \rightarrow \beta$ holds, but $\beta \rightarrow \alpha$ does not hold. Let $A$ be an attribute that is not in $\alpha$, is not in $\beta$, and fo...
Let $A\leq_P B$ mean that the language $A$ is polynomial time reducible to $B$. It is a theorem that $A\leq_P B$ and $B\in \text{P}$ then $A\in \text{P}$. My question is, if $A\leq_P B$ and $B\in \text{NP}$, is $A\in \text{NP}$? What if $B$ is $\text{NP}$-complete?
An array with bubblesort time $\Theta(n)$ is nothing but a sorted array like: A = 1 2 3 4 5 No swaps are done so only $n - 1$ comparisons. An array with insertionsort run time $\Theta(n^2)$ is a reverse sorted array: A = 5 4 3 2 1 Each element is swapped in every iteration. There cannot be any array that can have I...
Let's say there is a sender sending messages with commands to a recipient. The sender knows a set of commands but doesn't know anything about the recipient. A command is simply an opaque uniform random 128-bit string. E.g., the sender might know these commands and what they do: (1) 0x'BC04672BCEB7AEE08E555599F051F1CF...
Suppose, I have a 4-bit binary Incrementor that uses XOR gates to increment the inputted number by the value of 1 (b0001, to be precise). Suppose, we connect it to 4 D-Flip-Flops (DFF) to create a counter that goes up every time we send the clock pulse. This is straightforward: Just connect the outputs of DFFs to the c...
I would like to discuss resizing strategies for arrays please. If you have an array of $k$ initial size and it gets full, so you would like to choose from one of the following approaches: Approach 1: if array get full, then we resize the array by $k$ constant. Approach 2: if array get full, then we resize the array by ...
Subject pretty much says it all. My strong impression is that for any algorithm and any choice of programming language or computational model, if it's Turing-complete, then there must be infinitely many ways to implement the algorithm such that a fixed interpreter for the language will necessarily return the same outp...
Let's say I have a file which is exactly 1 MB in size. Contents of file are : 0001001000... upto 128 bytes (128 bytes per line in file). If I sort it in ascending or descending order (using notepad++): Line 1: 0000000.... Line 2: 0000001.... and more. Now if I compress it I get a 110 to 120 KB file. I want to kn...
If we want to detect and odd cycle if an undirected graph $G=<V,E>$. Suppose we run BFS algorithm from CLRS book as follows, Q: Now my question is suppose we have the following graphs: The figure to the left above: $d[v] \bmod{2} == d[u] \bmod{2}$ equal and gives odd cycle. $d[v] \bmod{2} == d[a] \bmod{2}$ not equal...
What are all the functions $f:\{0,1\}^n\rightarrow\{0,1\}$ that can be expressed as a product of affine Boolean functions? For example, if $x_1,x_2,x_3\in\{0,1\}$ then $x_1x_2x_3\oplus x_2x_3 \oplus x_2=(x_1\oplus x_2)(x_1\oplus 1)(x_3\oplus 1)$. Here $\oplus$ denotes the XOR operation. I would guess that not any funct...
Consider a variant of interval scheduling except now the intervals are arcs on a circle. The goal is to find the maximum number of arcs that do not overlap. Let $C$ be the circle on the plane centered at the origin with unit radius. Let $A_1, ..., A_n$ be a collection of arcs on the circle where an arc $A_i$ is specifi...
I understand what $O(f(x))$ means... $O(f(x))=\{g(x): g(x) ≤ cf(x), c,x_0>0 \}$. But I can't find a clear explanation on the meaning of: $f(O(x)).$ Can you explain the exact definition of this? When does $f(O(x))=O(f(x))$? Can you provide examples of when this holds and say why?
In this article about FFT the author used FFT on this polynomial. $A(x) = 3+2x+3x^2+4x^3$ Using $ A(x)= Aeven(x^2) + xAodd(x^2)$ the author determined the following for $Aeven(x)$ and $Aodd(x)$ $ Aeven(x) = 3+3x$ $ Aodd(x) = 2+4x $ How were $Aeven(x)$ and $Aodd(x)$ determined? Shouldn't $Aeven(x) = 3+3x^2$ and $Aodd(x)...
In phrasing an information model for consumption-optimized RDF-like data (full context at 1 for the curious), I'm looking for any established term for X as used here: Given is a directed rooted graph. An X is a (finite) sequence of edges, which go down the tree and then jump up again to a point where they've been just...
Must a partial halt decider be a pure function of its inputs? A partial halt decider correctly decides the halt status of some of its inputs. I am trying to write C code that would be acceptable to computer scientists in the field of the theory of computation. In computer programming, a pure function is a function that...
I'm not too familiar with minimum cost flows, so please bear with me. I need to calculate the minimum cost flow for a network that looks like this: (The numbers in parentheses next to nodes indicate supply, and the numbers on the arcs indicate the capacity and cost of that arc.) There are essentially $\binom{4}{2} = 6...
You are given a string S initially and some Q queries. For each query you will have 2 integers L and R. For each query, you have to perform the following operations: Arrange the letters from L to R inclusive to make a Palindrome. If you can form many such palindromes, then take the one that is lexicographically minimum...
While reading the text Modern Compiler Implementation in C by Andrew Appel I came across the hierarchy of grammar given below. The above diagram is very helpful in understanding the correlation among the various parser grammars. All the grammar above are context free grammars. From theory of computation texts, I have ...
Given following program: while n > 0 do for i = 1 to n do print '*' n = n / 2 where $/$ is integer division as usual. We want to calculate exactly how many * are printed. By summing up $n+n/2+n/4+...+n/2^{\lfloor\log_2n\rfloor}$ we get $2n-1$ but only if $n$ is a perfect power of $2$. In this case we ca...
The given problem is from CLRS, exercise 4.3-2. Show that the solution of T(n)=T(⌈n/2⌉)+1=O(log(n)) I decided to prove T(n) ≤ clog(n) and this is the result I got: T(n)≤clog(n/2)+1 = clog(n)-clog(2)+1 = clog(n)-c+1 ≤ clog(n) From my understanding of how the substitution method and induction works is that, clog(n)-c+...
Here the probability of frame being lost is $P.$ So the probability of frame reaching safely would be $(1-P).$ Now lets consider that the frame will reach safely in $k$-th transmission. That means that the frame being lost $k-1$ times and reached in $k$-th time with probability $(1-P).$ Now a frame requires $k$-transmi...
I was reading SICP and was solving a problem that asked to create a function in lisp for finding elements of Pascal's triangle. The way I went about it is to take input as the row number and then print each element of the row iteratively, whose value would be found recursively. (define (pascDisp n) (define i 1)...
I have an array A with n elements. I am trying to write an efficient algorithm to find the index of elements that matches condition A[j-1]>=A[j]<=A[j+1]. Example: A = [12,11,9,7,5,54,67,87,23,54,20,22] Should return 4 because subarray [7,5,54] matches the condition where A[4] = 5. Below is the solution I tried. It has...
I admit I didn't know much before what a Map is living with just the terminology Hash Tables, even when I first Google it I found this https://www.mathworks.com/help/matlab/matlab_prog/overview-of-the-map-data-structure.html#:~:text=A%20Map%20is%20a%20type,indexing%20into%20its%20individual%20elements.&text=These%20key...
The question is basically in the title. I know that a computers hardware is of course some physical object, where as the interpreter is some abstract thing that does something abstract with the code it is given. Yet, can we say that the way the processor is build is the implementation of an interpreter? Machine languag...
The following commentator writes: Monads are a unification of a bunch of computer stuff, including sequencing, IO, non-determinism, state, concurrency and exceptions. When I say "unification", I mean it in the sense that Newton's theory of gravity unified the motion of the planets with a falling apple (previously they...
Based on theory, the implementation using adjacency matrix has a time complexity of E+V^2 and the implementation using min heap has a time complexity of (E+V)logV where E is the number of edges and V is the number of vertices. When E>>V, such as for a complete graph the time complexity would be V^2 and (V^2)logV. This ...
I have $f(n) = O(g(n))$ and $g(n) = O(h(n))$. Is $h(n) = \Omega(f(n))$ true, and if so, what constants would make it true? I was thinking that since $f(n) = O(g(n))$ and $g(n) = O(h(n))$ are true, then $f(n) = O(h(n))$. I can state $h(n) = \Omega(O(h(n)))$ but I don't know what to do from here. Any pointers?
Let $L$ be defined as follows: $\small L = \{(\phi, k) \mid \phi \in SAT \mbox{ and there is a satisfying assignment for $\phi$ having exactly $k$ true variables} \}$ I am struggling to show that $SAT\leq_{p} L$, I can't figure what $k$ should be and how to reconstruct $\phi$.
The number of ways in which the numbers $1,2,3,4,5,6,7$ can be inserted in an empty binary search tree, such that the resulting tree has height 5, is _________. Note: The height of a tree with a single node is 0. What I have tried: Since It has height=5, we have 4 options for root $1,2,6,or$ $7$. One element will be al...
Using the Boltzmann selection in genetic algorithms, the probability of visiting a point in optimization space $X_j$ is $p(X_j)=\frac{\exp\frac{-f(X_j)}{T}}{\sum_i \exp \frac{-f(X_i)}{T}}$ my question is: how do we set the initial temperature T?
To what extent is the MAP data type implementation language dependant??? If we know that C++ implements maps as Red Black Trees, unordered maps as hash tables, How C++ and alike maps are actually stored in memory? what about other languages? Go as an example?
As far as I know, the admissability of a path-system is an example of a P-complete problem. However, I am not sure under which kind of reductions (many-one or turing-reductions? logspace or AC$^0$ reductions ... ?). Can anyone explain me under which reductions are Path-systems P-complete, please?
I know from the book by Neapolitan that for any algorithm input size is defined as the number of bits to encode the input. In graph algorithms, the input size is defined as $|V(G)| + |E(G)|$ for the input graph $G$. On the other hand, we save graphs in computers by their either adjacency lists or adjacency matrices whi...
Problem 1 Let $G(V,E)$ be a directed graph. Let $T \subseteq V$ be a subset of vertices called terminals. Find a subgraph $H$ of $G$, such that $T \subseteq V(H)$, $H$ is a strongly connected component and the number of edges in $H$ is minimized. Here $V(H)$ stands for the set of vertices of $H$. Problem 2 Everything ...
How to find the recurrence relation using domain range substitution method for the below: $$ T(n) = 2T\left(\frac{n}{2} +1\right) + n -2 $$ I am unable to get a pattern with this relation as it is really confusing. I am guessing the below for $T(n/2 + 1)$: $$ T\left(\frac{n}{2} +1\right) = 2T\left(\frac{n+2}{4}+1\right...
This question is just for discussing algorithms please and not for proposing algorithms. I saw very similar post to mine, but still the answer explains definitions online for topological ordering. Suppose we have a DAG (directed acyclic graph). Regarding the problem of finding shortest paths, Dijkstra's and Bellman-For...
According to my evaluation ,the overall asymptotic running time of the below algorithm is O(n) ,since x (number of recursive calls) is 1, and y ( the number of splits) is 2 , and finally z ( the power of amount of work done outside of the recursion call) is 1, hence x<y^{d}, but my answer turned out to be wr...
I was wondering if someone could please explain what the time complexity is for the code below. I think it would be $O(n)$ because the algorithm will take as much time to execute as there are elements in $n$. sample_list = [0, 1, 2, 3, 4, 5, 5, 6] check_list = [] ...
Hello my question is that if i have two for loops inside each other like this: for(int i = 0 ; i < 100000; i++){ for(int j = 0; j < n ; j++){ \\-------------} } and another one like this: for(int i = 0 ; i < n ; i++){ for(int j = 0 ; j < n ; j++){ \\-------------} } where n can have any value ...
I have the following implementation of Bubble sort where it calls a helper method named swap. public static int[] bubbleSort(int[] array) { boolean didSwap = true; int j; int unsortedUntilIndex = array.length - 1; // i goes from 0 to array.length - 2 // j goes from 1 to ...
I am confused as to why 2 threads waiting for a lock from each other will result in a deadlock. Let's say I have a Thread 1 that needs to execute contents in Lock 1 and then Lock 2 and a Thread 2 that needs to execute contents in Lock 2 and then Lock 1. Why does this situation result in a deadlock? Once Thread 1 is don...
This is not a difficult problem, but I would like please to discuss with you how I solved it: Solving recurrence relation $T(n) = 5T(\frac{n}{3}) + 2n$, $T(1)=2$. What is the value of $T(9)$? This can be done directly by applying $T(9)$ to get 98. However, I did it recursively as follows: $$ \begin{align} T(n) = 5\left...
On math.se, Sybren Zwetsloot has asked for help with an unusual optimal subtree problem. Here's my understanding of what he's asking: We have a weighted bipartite graph on two sets $N$ and $B$, call them "nodes" and "buses", with $|N| \geq |B| + 1$. Furthermore (I believe), every bus $b \in B$ has degree $\geq 2$. We ...
Given a $d$-dimensional vector $v = (v_1,\dots,v_d) \in \Bbb{R}^d$, we define $f(v) = \min_{i\in [d]} \{v_i\}$ to be the smallest coordinate of $v$. Let $v^1,\dots,v^n \in \Bbb{R}^d_{\ge 0}$ be non-negative vectors (meaning $f(v^i) \ge 0$ for $i\in [n]$). I want to find non-negative $c_1,\dots,c_n \ge 0$ satisfying $c_...
I have the below recurrence: \begin{align} T(n, 1) &= 3n \\ T(1, m) &= 3m \\ T(n, m) &= 3n + T(\tfrac{n}{3}, \tfrac{m}{3}) \end{align} How to get a tight asymptotic bound for $T(n, n^2)$ assuming that $n$ is a power of 3? Using the substitution method for $T(m,n)$, I get a very weird relation: $$T(n,m) = 3n + \frac{m}{...
If we have the following subgraph of a graph where I will just show 2 nodes please, where the capacity is 7 and 2 respectively: Now, if we have received flow at node 1 of value 5, then we will have: Problem: could you please explain why this will cause the capacity to be added to edge 2 and thus edge 2 will have now ...
In the problem find-all-anagrams-in-a-string, one tries to find all anagrams of a string $p$ (of length $k$) in a string $s$ (of length $n$) and return a list of the anagrams' starting indices. The solution is to use a sliding window of length $k$ and move that window from the first index all the way up index $n - k + ...
In a homework assignment, it's asked For any alphabet $\Sigma$; for all languages $L$, $M$ on $\Sigma$ Prove that $\forall n>1$, $L^n=M^n\nRightarrow L=M$ The student and I tried in vain to make a proof for $n=2$ by exhibiting distinct $L$ and $M$ with $L^2=M^2$; so much that I now think the statement may be wrong. W...
Context I have an array of objects (or a list of dictionaries), sorted in order based on a property of each object, say, time. In JSON, it would look something like this: [ {'details': 'some details', 'time': 69}, {'details': 'some details', 'time': 79}, {'details': 'some details', 'time': 107}, {'details': 's...
Given two languages $L_1, L_2$ such that $L_1L_2\notin RE$, is it always true that $L_2L_1 \notin RE$? I wasn't able to prove it or find a valid counterexample.
I have some operations defined as SQL queries which takes data from various tables combines it with the data from a base table and generates new rows, which are written back to the base table. In the words, a set of operations which populates base table with new data based on existing data. In the process of testing I ...
In graph theory, a source of a directed graph $D = (V(D), E(D))$ is a vertex of it whose in-degree is zero. The book CLRS makes these statements: Given a graph $G = (V, E)$ and a distinguished source vertex $s$, breadth-first search systematically explores the edges of $G$ to “discover” every vertex that is reachable f...
We just saw the Morris algorithm in class and we were asked the following: In class, we saw a constant factor approximate randomized counting algorithm with space complexity $O(\log \log n)$, where $n$ is the maximum value of the counter. Prove that any deterministic algorithm that provides a factor $1\pm\frac{1}{10}$...
Here https://uk.wikipedia.org/wiki/RBFS and here https://www.eecs.yorku.ca/course_archive/2013-14/F/3401/slides/15b-RBFS.pdf it's said that f[s] ← max(g(s)+h(s) , f[node] ) Why is it so? I can see a point in it, in a way that F-value is responsible for telling us what is the best accessible way along the path, and if...
what algorithm would you use to solve this problem which I recently faced in an interview? There's a council where people go to have meetings. A person comes at time x and needs to be in a meeting for duration y. The council has a set number of meeting rooms where 1 meeting room can only host one meeting/person. You ne...
Consider a discrete memoryless channel $N$. We use a code to send messages over this channel. Shannon showed that if we have a code $C$ with a finite number of codewords $|C|$ such that the average error is $\varepsilon$, then we can throw away half the codewords to obtain a code with $|C|/2$ codewords but now, the wor...
I have a GPS dataset that corresponds to a route taken by a vehicle in a day. It consist of a set of coordinates. Then say I have a coordinate and I want to know how close this coordinate is to this route. So basically I am calculating the distance to each point on the route and get the minimum value. But I have to do ...
This is a similar question to A variant of the house robber problem but instead of the general case, I'm wondering how you would solve the standard house robber problem, but when you cannot rob from houses on both the left and the right at the same time. The problem is modified from leetcode as follows: "You are a pro...
Could someone point me to a software/library which lets one to generate the Ising model/spin model for random $k$-sat problems or $k$-sat problem of a given structure? I understand that it will be based on the following mapping from Chapter 3 of Saitta et. al. and the coefficients will be based on a quenched disordered...
In this FFT algorithm (as per CLRS), in line number 4, shouldn't the angle be $-2\pi i/n$ and not $+2\pi i/n$? The same algorithm is used in cp-algorithms as well, but in python, numpy.fft.fft uses $-2\pi i/n$ as the angle. Can someone explain which algorithm is correct and which is wrong?
I have an alphabet $\Sigma = \{a,b,\#\}$. I'm trying to write a regex that only accepts strings that have the same pattern before and after the $\#$ without using back references. For example, $aab\#aab$ is accepted, but not $aba\#aab$. How in the world do you handle this? I thought you could maybe do something like $(...
I have two processors (two different physical processors) with base frequencies 3.2 Ghz and 4.0 Ghz. I want to ask if there exist a method which I can use to the 3.2 Ghz processor for ML acceleration ? I don't have a good gpu for this task. Will it be slower than a GPU ?
I have come across the description of a function $F: \mathbb{N} \to \mathbb{N}$ where the function is defined one way for $n \in \mathcal{H}$ and another way for $n \notin \mathcal{H}.$ In this notation $\mathcal{H}$ is meant to denote the halting problem. However, I am not sure what it means for an integer to be a mem...
Consider the following algorithm: The given items are inserted one by one into a list by performing comparisons like a binary search for the right position. Example: Imagine six elements are already sorted in descending order. We now compare the next element to one of the middle elements. Assume it's smaller than #3 (...
$a^n$ is a regular expression. $b^n$ is a regular expression. their concatenation is $a^nb^n$ which is not a regular expression.
It is widely known that the emptiness of counter automata is undecidable since two counters are enough to simulate a Turing machine (see the classic book from Hopcroft and Ullman, for example). However, what happens if we put a bound $k$ on the values stored by the counters? In this restricted model, the counters canno...
My intuition is that you can't call a function that has not yet been defined, although I have yet to find a source confirming this. Is this true? Thanks, friends :)
It is well known that the subgraph isomorphism problem is NP-complete. And so a polynomial-time algorithm for solving it would mean P = NP. Thus I'm interested in whether a bounded version of the problem has a polynomial time algorithm that is known about. Many applications of graphs don't require more than say 50 ...
A Graph is Eulerian iff $\exists$ an Eulerian Cycle or all the vertices of Graph have even degree. What is an Euler graph? Wiki has a definition for the Eulerian graph but not for the Euler graph.
Let's say I have a country with a set of cities, which I represent on the network graph below as a set of nodes. Furthermore, the weighed edge between pairs of nodes, represent the distance by road between them. I'll define the capital city as node A. There is no direct route between A and C so there is no edge between...
I'm trying to determine an asymptotic bound on the cardinality of the following set of functions. It is the functions with $n$-bit inputs, $\{0,1\}$ output, and requires precisely $n^2$ NAND gates. I'm trying to show that this is $2^{o(n^3)}$. I've thought about just counting all functions but that's too big, $2^{2^n}$...
In a project I am working on, we are looking at multiple different (optimal with respect to some cost measure) triangulations of a fixed pointset $S$. I would like to cluster similar triangulations. My first Idea was something like the edge flip distance, i.e. the minimal number of edge-flips in a quadrilateral needed ...
I'm still very early in understanding some computer science basics. I find it easiest to learn things when I have some oversight of what I can expect. Is there any trend to the number of logical gates that processors have, from 1-bit to 2-bit, 4-bit, 8-bit, 16-bit, 32-bit, 64-bit. This processor, https://en.wikipedia.o...
I'm trying to solve the following problem: https://cses.fi/problemset/task/1084/ My first idea to solve this was to sort the applicants and apartments in increasing order. Then, I iterate through all the applicants and for each one, pair it up with the smallest apartment that would satisfy them (if it exists). This gre...
Kolmogorov complexity of a string is the length of the shortest algorithm that generates it. Here I'm focusing instead on randomly distributed strings $x$, with length $n$, with a probability distribution $P(x)$. What is the shortest algorithm, with access to a random number generator, that is able to generate a random...
I have points in a 3d world where their position is defined by 3 integers: X, Y, Z. I'm searching for an algorithm / data structure to store these points in a way I can quickly find (e.g.: O(log(N)) the neighbour points in any direction aligned with the world axis (X-/left, X+/right, Y-/bottom, Y+/top, Z-/front, Z+/ba...
This is the variant of SSP: Given $n$ positive integer points $a_1, \ldots, a_n$ which are all at most $n$, does there exist a subset $\{a_i\}_{i \in P}$, such that its summation is exactly $n+1$? My question is, for general $n$, is this problem NP-hard?