instruction
stringlengths
35
11.4k
If i have a propositional logic formula, every time i add a variable the number of interpretation grow up by 2. So if i have a propositional formula with 3 variables i have 8 interpretations. So, is the time complexity of the SAT problem of propositional logic a $O(2^{x})$ ?
Suppose I have a 2D array M[n][n] of integers (in fact, binary is fine, but I doubt it matters). I am interested in repeated queries of the form: given a coordinate pair $k,l$, what is $$ \sum_{i = 0}^{k-1} \sum_{j = 0}^{l-1} M[i][j]? $$ Of course, all these values can be computed in $\mathcal O(n^2)$ time total, and a...
I have the following algorithm: func() { for(i=1; i<n; i=i*2) print("aa"); } How can I find Big-Oh using summation?
Suppose that $T$ is a tree of diameter four and $G$ is a graph. Deciding, whether $T$ can be injectively mapped to $G$ is NP-hard (there is a simple reduction from the problem of finding an independent set). I want to use this result as a side remark in my Bachelor's thesis. I believe that this should be a well-known p...
As we know, $\epsilon$ is the empty string, with length 0. It is not part of any any alphabet by default, unless specifically defined so. However, it is a string over any alphabet. For example, Given that I need to design a Deterministic or Nondeterministic finite state automaton (without $\epsilon$ transitions) that a...
How could one reasonably define and construct the complement of a deterministic Mealy machine? My intuition is that the complement should give exactly the opposite of output strings after a specific input string. I think this means the complement is non-deterministic. So let's define a (non-deterministic) Mealy machine...
After deleting an element from a B-tree,I could rearrange the tree in several ways,that would still complies to the rules of B-trees.But,we are supposed to follow a certain set of rules for rearranging the tree after deleting an element. Why is that ?
We use the following notation to describe a minimum convex optimization problem: minimize f0(x) subject to fi(x) ≤ 0, i = 1, . . . ,m hi(x) = 0, i = 1, . . . , p to describe the problem of finding an x that minimizes f0(x) among all x that sa...
Show that $L = L_\phi \cup L_{\{\sum^*\}} \notin RE$ with Rice theorem. Well I did show that with reduction, by using $HP'$. Simply by creating a function from $f(\langle M \rangle, x) = (M')$ Thus, if $M$ stops on $x$ then $M'$ simulates the machine that stops on the empty word and accepts/rejects like it. $(\langle ...
Let $S[1..n] \in \Sigma^*$ be a string of $n$ symbols over the alphabet $\Sigma$ where $|\Sigma| \in \mathcal{O}(1)$. Determine a shortest string which cannot be obtained from $S$ by deleting some (possibly no) symbols. For instance, we are given $\Sigma = \{ A, C, G, T \}$ and $S = ACGTACGT$. In this case, one valid a...
Although I have found a very similar question to what I want to ask here (https://codereview.stackexchange.com/questions/96064/dijkstras-algorithm-without-relaxation), yet I didn't find a satisfactory answer there, hence comes this question. So I have done competitive programming for fun for a while, whenever I need to...
I'm working through a proof that is a simplified version of David Maeirs LCS reduction from the VERTEX-COVER problem and I had a question about a specific set of instructions and how to execute them by hand. Background Information This works out to look like the below as a graph (please excuse the grid lines) The part...
This qns is from my school's exam paper. Context: In a game of Hangman, player tries to uncover a hidden word by guessing the letters in the word. Assume all words and letters are lowercase. The function remove takes as inputs 2 strings, a letter and a word, and outputs the word with all occurrences of letter removed....
I have a variation the shortest path problem, formulated as an ILP. The system model is as follows: There is a connected digraph consisting of 20 nodes, with each link having an associated weight delay which is a float. The graph is modeled as a python networkx object as follows: g = nx.DiGraph(nx.barabasi_albert_gra...
Given two NP-Complete languages A and B, show that the language: $L = A\bigoplus B =\{a\bigoplus b \mid a \in A, b \in B, |a|=|b|\}$ is not necessarily NP-Complete. Remember $a\bigoplus b$ when $|a|=|b|$ gives 0 when they have the same digit and 1 otherwise. Example: 0110$\bigoplus$ 0101 = 0011 I have tried to solve ...
I studied that Integer problems are properly NP-HARD problems. I know that NP-HARD include problems that arent solvable, like the halting problem. This mean that there are instances of Integer problems that arent solvable ?
Why is integer programming (IP) more difficult than (real) linear programming (LP)? I searched a lot on the web, but I didn't find an answer.
Scenario Consider one or more curved shapes in 2D space, clipped to a rectangular viewport. For example: Unfortunately, data that would describe these shapes precisely, is not available. Input data All that is available are the intersections of the shapes with a few horizonal and vertical lines, sampled at coarse inte...
For a while now, I have been struggling to find a source explaining the complexity of the following 2 elementary operations Calculating the $n^\text{th}$ root of an integer $x$, $$ \sqrt[\leftroot{-3}\uproot{3}n]{x} $$ Checking whether $$ a \equiv b \mod r $$ for $a,b,r \in \mathbb{N}$ I now think I may have come clo...
I organize amateur tournaments every week with random players. Every week, players sign up, and I get a list with: Name Rank (1, 2 or 3) Role (s) (DPS, TANK and HEALER) I need to get balanced teams of 6. Ideally, there are 2 DPS, 2 TANKS and 2 HEALERS but in practice there are not enough healers and I have to make 3 ...
$T(n)=\sqrt{2T(n-1)}$ what will be the time complexity if $T(n)$ is given as this? I tried substitution but no result was reached.
I have made an algorithm by which I recently finished counting solutions to 28 queens problem and I have the number. How do I verify that it is correct? I have heard that it can be done in quadratic time. That is, given a solution to an nqueen problem it can be verified in polynomial time. I would like to know the algo...
Can I get help to give an analysis of the running time Big-O? I'm not sure if all my answers are correct. I got for a) $ O(n)$, b) $O(n^3)$, c) $O(n^{1/2})$ and d) $O(log(n))$ (a) sum=0; for ( i =0; i<n ; i +=10) sum++; (b) sum=0; for ( i =0; i<n*n;++ i ) ...
A $64$-bit computer has a virtual mem space of $2^{64}$ bytes and the computer also uses memory paging with size of $2^7$ $(128)$ bytes. Work out the bits of the memory address which are used for the page number? No. of bits of the memory address which are used for the offset? Can someone explain how I would go about ...
I am trying to make a programming language for the first time and wonder how it handles whitespace. I can see CFG by default seem to just ignore whitespaces, but what if I want it to use it sometimes? Like when you declare an int people usually write "int b", and the whitespace separate these two items, but if I write ...
I have a very complex search problem which I can't wrap my head around: While reading please remember I'm not asking for a specific solution! Only a general approach how such a problem can be solved and what kinds of algorithms to use (more below) I have a sphere with around 120 000 weighted and named points mapped ...
I am going through beta reduction in lambda calculus . And beta reduction to my understanding is an act of substitution like in the following : $ (\lambda x.P) M $ is said to be beta reduced to : $ [M/x]P $ So then my course was led to encoding the Booleans in lambda calculus . And the following two expressions were...
I am trying to research a new topic using machine learning. The problem is, I have a very small dataset, consisting of 5 months of data. I have been told that my dataset is too small. I want to know if there is any way of making my dataset larger, using an automated tool/algorithm I can implement fast, and more than th...
Suppose I have a directed graph $G = (V,E)$. Suppose that $v_1$ and $v_2$ are two nodes in the graph. Am I correct the number of simple paths (that is, it has no cycles) from $v_1$ to $v_2$ is $O(E)$? Is it true for the special case of directed acyclic graphs? Bob
so i know that the set of all strings over any finite alphabet is countable, but this question is different so if our language is set of all regular languages(or set of all regular expressions) on a specific and finite alphabet, then is this set regular? if not then what is it? CFL? i really can't come up with any FA t...
I have a lot of numerical vectors, each of dimension 1000. I would like to compare them according to their Pearson distance. This works fine but comparing all vectors to each other is quadratic time and too slow. Ideally I would like to be able to perform efficient approximate nearest neighbour searches instead. If I...
Given directed graph G, vertex s, and all v∈V(G) are 1 edge distant from vertex s. Is it possible to find a specific edges order (from E(G)) such that a single iteration of Bellman Ford pass over these edges in this order finds all the shortest paths (in weight) from vertex s to all vertices? I couldn't find a countere...
I've just hashed up the following hair-brained idea of how to sort n-tuples of integers, as demonstrated below with a set of 3-tuples: [ 4 , 1 , 3 ] [ 1 , 2 , 1 ] [ 2 , 2 , 1 ] [ 2 , 1 , 1 ] [ 1 , 1 , 1 ] [ 2 , 1 , 2 ] [ 3 , 1 , 3 ] [ 1 , 2 , 2 ] [ 1 , 1 , 3 ] [ 1 , 1 , 2 ] [ 3 , 1 , 1 ] [ 3 , 1 , 4 ] First "partition...
I am going through the following lecture notes on lambda calculus by Barendregt and Barendsen : http://www.cse.chalmers.se/research/group/logic/TypesSS05/Extra/geuvers.pdf Here at page 12 , after introducing fixed point theorem a small exercise which is an attempt to prove the following has been posted : $ \exists G \...
Let $G$ be a undirected edge-weighted tree, where all edge weights are positive. A move of an edge $\{u,v\} \in E(G)$ is the operation of deletion of $\{u,v\}$ and the addition of a new edge $\{x,y\}$, where $x,y \in V(G)$. Intuitively, we can think of the move meaning the deletion of an edge, and the re-insertion of i...
I'm stuck with another homework question - "Design an NFA with $n$ states such that the corresponding equivalent DFA constructed using the subset-construction method has less than $n$ states." What I have learnt is that using subset (or powerset) construction, you can convert a given NFA with $n$ states to it's equival...
We have to prove that the language represented having equal number of $0$'s and $1$'s and starting with a $0$ is not regular. Attempt: We assume that the language is regular. Thus it would satisfy the pumping lemma. Assume the pumping length to be $p$. Let us take the string would be length $p+1$ as $0 0^p 1^{p+1}$. N...
Trying to figure out how to make a deterministic single-tape Turing machine for the language of words comprising as many $a$'s as $b$'s. I am very confused, because I can't figure out how I would keep track of how many $a$'s and $b$'s there would be. The method for finding $a^nb^n$ goes right and back left to do this b...
I want to prove in which relation the two functions stand to each other with the help of a proof. But how?
I have been strugling with this LL(1) transformation for far longer than expected and am getting quite desperate. We are given a grammar $ G = \left\{V_N, V_T, S, \Phi \right\}$, with the non-terminal set $V_N = \left\{S\right\}$, terminal set $V_T = \left\{\underline{o}, \underline{l}, \underline{r}, \underline{i}\rig...
I consider simplified Pacman game: movement is discrete (on the grid), ghosts move deterministically based on difference between their and Pacmans coordinates, ghosts move every second turn, ghosts always chase Pacman, never reversed, the maze has no exit, success is when Pacman collects all the dots. The most natura...
The C memcmp function (and strcmp) does a comparison similar to the function below for comparing integers: int compare(const int a, const int b) { if (a > b) return 1; if (b > a) return -1; return 0; } Microsoft information for their strcmp says: The strcmp function performs an ordinal comparison of st...
Code for finding $\phi$(n) is int phi(int n) { int result = n; // Initialize result as n // Consider all prime factors of n and subtract their // multiples from result for (int p=2; p*p<=n; ++p) { // Check if p is a prime factor. if (n % p == 0...
Assume the $\mathcal{F} = \{\, f_{s} \,\}_{s \in \{\, 0,1 \,\}^{*}}$ be a family of computable functions, where $f_{s} \colon \{\, 0,1 \,\}^{|s|} \rightarrow \{\, 0,1 \,\}^{|s|}$. Let $F_{n}$ be a distribution of functions $f_s$ where $s$ is uniformly distributed over $\{\, 0,1 \,\}^{n}$, and let $RF_n$ denote the unif...
I'm new to the concept of loop invariant and I'm trying to figure out the loop invariant for a program that returns if an integer is prime and, if not, one possible factorization. My intuition is that as a loop invariant condition we need i in the range [2,floor(sqrt(n))] and then n mod i !=0 implies n is prime bool Is...
We're studying Heuristic in my Theoretical CS class, more specifically Greedy-Algorithms for the Traveling Salesperson Problem. The first one is the "next neighbor heuristic", where you start at any given point and connect it with the nearest point and then connect that to the next nearest one until all points are cove...
Most descriptions of modern RNNs present a "folded" characterisation, that is to say, a single cell with a loop back to itself transmitting the hidden state from one step to the next. However, in implementations the RNN is computed "unfolded", so a new cell is created for every step of the sequence up to some maximum s...
In his paper Computer Machinery and Intelligence, Turing addresses some arguments against the ability of a computer to pass the Turing test, such as the Theological Argument, the Mathematical Objection and the Argument from Consciousness. I wonder what is the current status of this debate; are there strong counterargum...
I understand that using a bad case for subset construction as provided through an example in the book - Introduction to Automata Theory, Languages and Computation, we can definitely have an NFA with $n+1$ states, and get a corresponding minimal DFA with $2^n$ states due to the power set logic. But, my question is, is ...
I guess this is kinda like asking if 3 (or more) rectangles are collinear. The question is, given n rectangles on the 2D plane (given as the rectangle's top-left corner coordinates and it's width/height), does there exist a line that goes through all of them? Notes: The rectangles' sides are perpendicular or parallel ...
The following question is from the book "Introduction to Algorithms" By Cormen and three other authors. $26.2-10$ Show how to find a maximum flow in a network $G = (V,E)$ by a sequence of at most $|E|$ augmenting paths. (Hint: Determine the paths after finding the maximum flow.) I find this question confusing because t...
I am trying to understand how the Z-combinator (Y-combinator for applicative order languages) definition came about. As Python is applicative I am using Python for this. So I know Python's evaluation order is applicative. But I seem to be overlooking something in how applicative order works. To compensate for applicati...
Let $X=\{x_1,\ldots,x_n\}$ be a finite set of alphabet and $X^\ast$ denote the set of all words (including empty word) over $X$. Clearly, $X^\ast$ is a regular language. Is there a subclass, say $C$, of deterministic context-free (DCF) languages over $X$ such that if $L \in C$, then $ X^{\ast}LX^{\ast} \in C$ and the g...
In a geographical graph, where each edge's cost is equal to the physical distance between its nodes, one can be tempted to manipulate the cost of some of the edges, to make it a bit lower, in order to introduce preferred paths. So that, in the following graph, the final route would be the one in green instead of the on...
Since a processing core with hyperthreading enabled is presented as two or more cores to the operating system, it can run completely different processes with different, isolated virtual memory spaces. There must be a mechanism that guarantees process address space isolation. How is it done in Intel hyperthreaded CPUs w...
I have been looking through different websites and forums but I can't seem to find any post about the similarities between bubble sort and selection sort. Can someone help me plese? Thanks
i am trying find the Cost of an algorithm. it contains break statements. is there any cost of break and Continue statement in a Algorithm?
I know that the time required to check if there exists an edge between two nodes in an adjacency matrix is $O(1)$ because we can access it directly (i.e: $M[i][j]$). However, I didn't really get why time complexity in an adjacency list to check would be $O(|V|)$, where $V$ represents the vertices. Shouldn't it be $O(|E...
Looking at the kernel function (Gaussian, polynomial. chi-squared, etc) how do we figure out that changing which value will cause overfitting? In my perspective, if we increase (for example) the variance term in Gaussian kernel expression, bias increases and overfit decreases. Is my understanding correct? Can the same ...
Given two sets of items $A = { a_1, .., a_N }, B = { b_1, .., b_M },$ and assuming a connection weight $w{_i}_j \ge 0$ between any possible pair $(a_i, b_j)$ that contains one item of each set, how can I identify the set of pairs $S$ that maximizes the sum of all involved weights: $\sum_{S}w{_i}_j$, under the condition...
In my theoretical computer science class and we were covering "Heuristics". In it we covered "Greedy Heuristics" for the "Vertex Cover Problem", "Interval Scheduling" and the "Traveling Salesperson Problem". In it we covered the "Nearest Neighbor", "Closest Pair" and "Insertion" heuristics approach to solve the TSP Pr...
Thanks a lot for your help. I want to understand what really causes what I suppose to be a deadlock: I have standards objects, let's call it 'Words' that contains 3 letters and a key; (it doesn t really matter for my problem) I have a container (list) of Couples, where a Couple simply is: 2 Words and 1 couple-Key. I ha...
My textbook has a problem to find the regular expression that describes the set of all strings of 0's and 1's whose number of 0's is divisible by 5 and whose number of 1's is even. I can write a regular expression for each condition a. $0^*(10^*1)^*$ b. $1^*(01^*01^*01^*01^*01^*)^*$ I am having trouble understanding h...
I'm hoping for examples that aren't too abstract or useless in day-to-day programming, though not with a lot of hope, since in Bartosz Milewski's book, it is stated that generally speaking, the category Set is good enough, but mentions polymorphic functions and there not being a set that includes all sets as being one ...
An edge cover of a graph is a set of edges such that every vertex of the graph is incident to at least one edge of the set. I am interested in finding the minimum edge cover of a tree such that each vertex is incident to an odd number of edges. Is anything similar studied in Computer Science?
I'm trying to help my daughter with her CS assignment on hashing. She has an input list of about 4000 English words, each 5 letters long. The prof has limited her to 4000 output buckets (digests? -- it's been a long time since I did this stuff). And the output from the hashing function is an int modulo 4000. Her naive ...
L is the language of all turing machines that its computing time on all inputs is O(n^2). my thoughts is that the language is in CO-RE / RE. the language cannot be accepted because in order to make sure that there is no word W such that M halts on it after n^2 steps, you need to scan all words in the universe - infite ...
First we generate a key, $$k \leftarrow \{\, 0,1 \,\}^{n}$$ And we construct two PPT algorithms $A$ and $B$ as follow: $$A_{k}\left( \cdot \right) \colon y_{A} \leftarrow k, \text{ return } y_{A}$$ and $$B_{k}\left( \cdot \right): y_{B} \leftarrow \{\, 0,1 \,\}^{n}, \text{ return } y_{B}$$ For fixed $k$, let $D_{A}$ b...
In page $4$ of this paper, Lemma 2.1 claims to establish a reduction from $k$-$SUM$ to $k$-$Clique$ problem: For any integers $n,c,d,p \geq 1$ such that $p ≥ 3n^{\lceil > c/d\rceil}$, there is a set of $s = 2^{o(d)}$ mappings $f_1,\cdots,f_s:[−n^c, n^c] → [−p/3, p/3]^d$ and $s$ target vectors $t_1,\cdots,t_s \in [...
Let $\textit{G(V,E)}$ be an undirected connected graph with distinct costs on its edges. Initialize $\textit{T}$ to be any spanning tree of $\textit{G}$. Consider an algorithm which replaces an edge $\textit{e}$ in $\textit{T}$ by an edge $\textit{e'}$ not in $\textit{T}$, if $\textit{e' < e}$ and replacing it sti...
I am trying to prove that a certain problem is $NP$-complete. The problem is that in a given order of elements like $(a>b>c)$, $(c>d>b>a)$, there will be inconsistencies. From these orders, you can conclude that $a>a$, which is an inconsistency. Removing all inconsistencies by removing the fewest amount of orders is th...
We have a map of a branching river without any islands (tree of confluences, see picture), there are piers on the river bank ( not necessarily on the confluences). We are given the distances between individual confluences and distances between piers and confluences on any particular river segment. How would we algorit...
Given input sequence $x_1,...,x_n$, find the longest contigous subsequence $x_i,... x_l$ where each pair $(x_j,x_k)$ satisfies that $|x_j - x_k| \le p$. I have come up with simple $\mathcal{O}(n^2)$ solution. I'm sure there is a better way so I'm looking for $\mathcal{O}(n)$ or at least $\mathcal{O(n \log n)}$ solut...
I'm reviewing my background in Algorithms and DS design. Specifically I never went through the van Emde Boas Tree. Though I can undestand the proto-vEB with related picture. I'm struggling to understand the actual data structure. I have no clue how the "min" and "max" members are actually used, I'm not talking about th...
Contruct a Turing Machine that halts if and only if the tape it is on contains at least two '1's. My attempt: The gist of this turing machine is that it has to check all of the cells, and since it is infinite in both directions, one way of indexing it is a follows Thus it has occurred to me to write a pseudocode for...
Let us consider the lambda calculus expression . $ (\lambda func.\lambda arg$ $( func$ $ arg)$ $\lambda x.x)$ Now $\lambda x.x$ is seen as an argument . How to decide which bound variable should the value of the argument go to ? The books I am going through suggest that in this kind of case when there is one argument a...
In a question, it is given that L is a finite language over the unary alphabet and L+ is not regular. We know that L+ = LL* Since L is finite, it must be regular because all finite languages are regular. If L is regular L* is also regular. Then how can be L+ not regular? It is the concatenation of two regular languages...
Polar codes, invented by Arikan, with low encoding and decoding complexity. But the minimum distance of polar codes is not great. The normalized minimum distance goes to 0 with the block size. Yet, the existing decoding algorithms for polar codes can asymptotically achieve channel capacity. Generally, a code with minim...
There is this "folklore" result that gradient descent on a non-convex function takes $O(\frac n {\epsilon^2})$ steps to get to a point whose gradient norm is below $\epsilon$ and with SGD this takes $O(\frac {1}{\epsilon^4})$ steps. Can someone share a reference where this is proven? I am aware of the recent refer...
Is there a cipher that well suited for preschool-aged children to work out on pencil and paper, to learn concepts of block chains? It must have the following requirements: Able to be easily verified a. For example, Joe submitted red, but Suzy submitted blue. Everyone knows Suzy is right...somehow. (Color-specific resu...
Let $A$ denote a set that contains a relatively large number of different strings. Let $S_i$ denote these strings. Let $B$ denote a set of sets such that each subset contains a (relatively small, usually not greater than 100) number of different strings. Let $B_i$ denote these subsets. The problem is the following:...
Sorry if this is the wrong place to ask, was unsure...let me know if it belongs some where else. So i am trying to work out a way to write an algorithm to place a series of small circles of a set radius (all the small circles have the same radius), inside a larger circle. The small circles cannot overlap each other or ...
I'm reading through CLRS again and I was wondering if there's a formal justification or construction of the accounting method, explaining why it works. For some reason it seems to me that CLRS basically expose the method explaining the intuition behind it, but it doesn't seem rigorous to me. Also is it correct to say t...
I have a sum: $$S = \sum_{i=1}^n{\lfloor a/i \rfloor i^2},$$ where $a$ is a constant. Is there a way to speed this up? That is, can we avoid iterating overl all $i$s, possibly calculating it in logarithmic or better time, something manageable when $a$ is big, n = a/2? I tried lots with pen and paper, but I cannot see ...
I'm studying a declarative programming language (Prolog) and in thinking about how certain things are programmed at a low level, a question came to me: are programming languages ultimately procedural ?
What is the goal of the SAT Problem? Check if it is possible to have output '1'? Above + find the right combination of inputs for that? Witch one? Cheers
i am new to analysis of algorithm . i am having an if condition. If (I !=j AND A[i]==A[j]) i am counting the operations as i) accessing element from Array A[] ii)compairing i!=j iii) compairing a[i]==a[j] according to me this statement is performing 3 Actions. is it so ? if not than please clarify... thanks
in order for M to belong to L, it must halts on all inputs after 5 steps exactly. is the problem not decidable ? how can it be proved ? I could not succeed in doing a reduction from Htm as the attempt to count M(w) steps failed. update: apparently the language is in R. can anyone provide a proof?
With reference to chapter 17 of CLRS, (Amortized analysis). I'm trying to understand the differences between the accounting method and the potential method. Let's start with standard analysis of the stack, three operations supported namely $\text{push}(x), \text{pop}(),\text{multipop}(k)$ the cost of this operations is...
I have a collection of objects, with certain properties (let say 3 - zone, type, owner) only having a small predetermined possible set of values (like enum). This is just a simple (javascript) array of gaming cards (think "magic the gathering"), that could be in different zones (deck, hand, grave, play), and they could...
I've got a numeric matrix with 72 rows and 2 columns where the first column is the index value and the other column has sequence from 0 to 5 repeated 12 times. The dataset is like above: 1 0 2 1 .... 6 5 7 0 .... 72 5 I add the dataset graph I would like to use machine learning with a clustering algo...
I have a list of nodes l = [1, 2, 3, ... , n] and a list of tuples p = [(1, 2), (2, 3), ...], where the latter represents which pairs of nodes have an edge between them. I would like to write a function that takes the above as input and returns a subset of the powerset of l where each set has nodes which construct a co...
I need to prove the following: reverse(append(zs, z)) = Cons(z, reverse(zs)) Where: sealed abstract class IntList case object Nil extends IntList case class Cons(x: Int, xs: IntList) extends IntList def append(xs: IntList, x: Int): IntList = xs match { case Nil => Cons(x, Nil) case Cons(y, ys) => Cons(y, appe...
I'm studying some papers related to graph partitioning (GP). It is well-known that the GP problem is NP-Complete. Based on my understanding, it means that there is no polynomial time solution to solve this problem, or there is no optimal solution for that. The following paper mentioned this fact in its introduction: "...
From my understanding of the proof that halting problem is not computable, this problem is not computable because if we have a program P(x) which computes if the program x halts or not, we got a paradox when giving P as an input to the same P, having: P(P), trying to decide if P halts or not using P itself. So my quest...
I understand that for every regular language, there exists an equivalent regular expression. However, can that be used in the opposite direction? Does every regular expression have an equivalent regular language? Or is the set of regular languages a subset of regular expressions? If this is not the case, is there a goo...
Which notation can be used for expressing how many times that function or subroutine called during a run of a program? Example program pseudocode: $ a \gets 0 \\ \textbf{While } a \neq 5 \textbf{ do} \\ \quad \textit{function1()} \\ \quad a \gets a + 1 \\ \textbf{end} $ $g: functions \rightarrow \mathbb{N}$ and for th...
Given positive intgers $N$ and $S$ i need to count in how many ways $N$ can be decomposed as sum of $S$ positive integers not greater than $\frac{N}{2}$: $$ N = x_1 + \dots + x_S, ~~~~ 0 \leq x_i \leq \frac{N}{2} $$ Two partitions are considered distinct if any of the summands has distinct values in them. For example, ...
In object-oriented programming, dot notation is used when accessing the properties or methods of a class: Dog dog print dog.name >> "Fido" dog.walk() >> Walking the dog now... What is the origin of that syntax and why the . to notate it? It must date to some early object-oriented language, but I couldn't find mention ...
I am currently working on the following problem that involves developing a dynamic programming algorithm for finding the length of the shortest fully bracketed expression (FBE), $y$ that contains a given string $x = x_1x_2...x_n$. An FBE is defined as a string over the characters (,),[, and ] that is either the empty...