instruction
stringlengths
35
29.1k
I'm trying to understand the difference of DFA from NFA I have this example in my coursebook Are the empty symbols at the start necessary? or can we do away with them to have something like this
A function can generally be defined to receive parameters by value or by reference. If we want to mutate an object inside the function and have those changes reflected outside the function, then it must be passed by reference. If we don't want to mutate the object then we can choose between passing by value or by refer...
Question: Let $$S = \{\langle M\rangle\mid \text{TM }M\text{ on input 3 at some point writes symbol “3” on the third cell of its tape} \}.$$ Show that $S$ is r.e. (Turing acceptable) but not recursive (decidable). I'm bit confused about this question, I'm not even sure how exactly should I start an approach to it. As I...
I have the following graphical model, in which I wish to compute $p(Intelligence = 1|Letter = 1, SAT = 1)$ But I'm not sure how to rewrite $p(Intelligence = 1|Letter = 1, SAT = 1)$? I was told to consider the formula $p(D,I,G,L,S)=p(D)p(I)p(G|D,I)p(S|I)p(L|G)$ (which applies to this model), but I don't see how someone...
Please can anyone help me to solve the following question, I have no idea to solve that .
Problem: Input : $n$, $k$ Check : Is $\frac{k}{4h -1} = n^{\frac{1}{h}}$? for any $ 0 \le h <= n$. Question: What is the fastest algorithm for the above problem assuming the model of computation is RAM?
I understand that GPUs are generally used to do LOTS of calculations in parallel. I understand why we would want to parallelize processes in order to speed things up. However, GPUs aren't always better than CPUs, as far as I know. What kinds of tasks are GPUs bad at? When would we prefer CPU over GPU for processing?
I have a bipartite graph, where I want to assign nodes in Left set to Right set of nodes. There is a "b" constraint, which limits the maximum possible node degrees on the Right set. Since it is a classic problem, I expected to find a lot of algorithms on it, but was not successful. Any ideas how to solve it?
Consider the Traveling Salesman Problem: Input: $n$ cities, distances $c_{ij}$ for each ordered pair $(i,j)$ of them. Output: Find a shortest round tour visiting every city exactly once. I came across the following ILP formulation, where we introduce a variable $x_{ij} \in \{0,1\}$ for each pair of cities $i,j$ where $...
We assume that we have the same graph G. In introduction to Algorithms by Cormen it's said that it`s possible depending on how it breaks ties when the edges are sorted into order. I have trouble visualizing the answer given: Suppose that A is an empty set of edges. Then, make any cut that has (u, v) crossing it. The...
I am struggling to understand the idea of conflict-driven clause learning, in particular, I can not understand why the clause we 'learned' is a substantially new (i.e. the clause database does not already contain it, neither any subset of it). Here is what Knuth in his book says: A conflict clause $c$ on decision leve...
I am trying to understand the difference between weakly fair and strongly fair scheduling. For example, what scheduling policy would ensure that a process delayed at its first await statement will eventually be able to proceed? weakly fair: A condition becomes true and remains true at least until after the conditiona...
The bit-graph of $f\colon \{0,1\}^* \rightarrow \{0,1\}^*$ is the language: $\text{BIT}_f := \{\langle x,i \rangle : 1\leq i \leq|f(x)| \text{ and the $i$-th bit of } f(x) \text{ is } 1\}$ It is said that $f$ is logspace computable if $\text{BIT}_f$ is decidable in space $O(\log n)$. Decidable means that there exist a ...
Sedgewick and Wayne talk about how sorting algorithms and, specifically, priority queues are used in devising ways to improve accuracy in floating-point calculations: https://algs4.cs.princeton.edu/25applications/ Scientific computing is often concerned with accuracy (how close are we to the true answer?). Accuracy is...
This is an exercise from Software foundations for my discrete math & functional programming class. I am a little stuck with the end of the code because it works for the first two examples but it doesn't work for my false case and I can't figure out why... (** **** Exercise: 2 stars, standard (eqblist) Fill in th...
We have a graph with $N$ nodes and $N-1$ undirected edges, where it's possible to reach one node from any other node. Each node will get assigned a value randomly from [1,...,10]. We want the value of every node to end up at 10. The way we update is as follows, whenever we visit a node, we increment the value of that n...
I have to set up a system of a laser line/ plane projector and a web camera to localize the 3D position of the laser in the camera image. I've read / come across several resources but the idea is still not quite concrete in my head. So my intuition is that since we have a set up of a laser projector and the camera, an...
My math prof said it is trivial to optimize a modular exponentiation (a^b mod c) problem for large values using fft, but I can't figure out how to do this. I looked it up and found a few papers on it (namely [1], [2], and [3]), but 2 of them use Montgomery multiplication, although in different ways, and the third one u...
I want to formalize some undergraduate maths in cubical agda, and learning cubical type theory in the proccess. The problem is that I will need univalent excluded middle and univalent choice (and maybe propositional resizing). I know these are consistent with homotopy type theory (although computation is lost when axio...
I don't know relevant keywords about this algorithm. I can show you visually Any ideas are appreciated
For some representation scheme $\ulcorner \cdot \urcorner$, a self interpreter $R$ is a lambda expression where $R \ulcorner A \urcorner \underset{\beta}{=} A$, while a self reducer $E$ is a lambda expression where $E \ulcorner A \urcorner \underset{\beta}{=} \ulcorner {NF}_A \urcorner$ (${NF}_A$ being the normal form ...
I am currently looking into the $k$-Sum Problem and some of its variants. However i stumbled onto an inconsistency, that i can not seem to fix. If we begin with $3$-Sum, the 'textbook'-definition goes something along the way of Let a set $S$ of $n$ integers be given. Are there $a,b,c\in S$ such that $a+b+c=0$. From ...
A one-way-function is an easy to compute function $y=f(x)$ which is hard to invert. In 2000 Levin showed an example of a function which is one-way if there are one-way functions. As far as I know, it is still not clear whether true one way-functions exist. Now with Friedberg numbering, which roughly speaking, is a prog...
Say I have n objects, each with an unknown value, and a n by n matrix Z. Such that Z(i,j)=1 if the value of object i is less than the value of object j, and Z(i,j)=0 otherwise. How can I sort these n objects, given only the matrix Z?
Alice and bob play a game. Bob has a well-shuffled deck of $M=4999$ white cards and $N=4999$ green cards. Each permutation of cards in the deck is equally likely. Alice has set some rules for Bob. Every time Bob flips a white card he gets one coin, otherwise he loses one coin. At any moment (even at the beginning), ...
Original Problem Given a set $N=\{a_1,...,a_{n}\}$ with $n$ positive numbers and $\sum_i a_i=1$, find a subset whose sum is $x_*$, where $x_*$ is a known fixed irrational number and $x_*\approx 0.52$. I proved its hardness by the following arguments. Instance Given a set $N=\{a_1,...,a_{n+2}\}$ with $n+2$ numbers whe...
when a new process is created using a fork() function, there is a cold start penalty, what is this and why does it happen?
Can the same node appear twice in a tree? I'm asking about the node object itself, not the node's value. For example, in the following code, a's left and right are the same node, b. a = new TreeNode(1); b = new TreeNode(2); a.left = b; a.right = b; Is this valid? Why or why not?
Most reductions for NP-hardness proofs I encountered are effective in the sense that given an instance of our hard problem, they give a polynomial time algorithm for our problem under question by using reductions. All reductions in the 21 classic problems considered by R. Karp work this way. A very simple example migh...
My math/cs professor said it is trivial to optimize a modular exponentiation ($a^b \bmod c$) problem using fft, yet I am not able to understand how to do this. I found 3 papers on this ([1], [2], and [3]). Papers 1 and 3 use Montgomery reduction, that too in different ways, and paper 2 seems to use a unique method com...
I'm having hard time understanding time complexity of my solution for combination sum problem. The problem is as follows: Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. The same repe...
I was reading the book "Foundations of Logic Programming" written by J.W. Lloyd. In the book, there were definitions of interpretation and model, and when it comes to herbrand interpretation and model, I am having difficulties. It provided an example, but I did not understand it. Example. Let $S$ be $\{ p(a), \exists x...
I would like to know if there is a turing machine which can do the following: take as input a turing machine T and integer n: return true if the turing machine halts before time n and false otherwise Clearly such a TM (turning machine) exists. Take the TM that simply runs T for n steps, then if it has halted return tru...
See some related questions in Cont: NP-hard or not: partition with irrational input or parameter Given a set $N=\{a_1,...,a_{n}\}$ with $n$ positive numbers and $\sum_i a_i=1$, find a subset $S\subseteq N$ such that $F(\sum_{i\in S} a_i;\alpha)$ is maxmized, where $F(\cdot;\alpha)$ is a known fixed function with param...
Say, I would like to check a hypothesis concerning primes. Something like "there exists a prime between $n$ and $2n$ for every choice of $n$". I would like to run a code in MATLAB for choices of $n$ upto $2^{32}$ and then use that data and publish the conjecture in a journal. The question is, what should I use to check...
I was going through this piece of code from an algorithms books and something doesn't look clear Please ignore the spelling errors, How does 0(x + 2x + nx) reduce to o(xn^2) ? My analogy, assuming x is a constant 1 and n is 2 (x + 2x) == 3 assuming x is a constant 1 From the book (x2^2) == 4 assuming x is a constant ...
I'm trying to design a method to represent polygons as vectors. There are many ways to do this, but I have a few goals and I'm not sure what representation is best to fulfil these. The objectives are: I want there to be a simple (efficiently computable) distance function between polygons that gives a measure of how di...
for(i = 0; i<n; i++) { for(j = 1; j<i*i; j++) { if(j % i == 0) { for(k = 0; k<j; k++) { //statement; } } } } Here, it's been asked to find the time complexity. I think it's O(n^4), but prof. said it's wrong. Can someone explain how this works ?
I am currently trying to learn a bit more about the theoretical side of computer science and I have stumbled upon this example I found online: $5n^2 + 5n = O(0.5n^2)$ I do have basic understanding of how time complexity works but it is the only example I have found that has a number attached to the $n$ (right side). ...
What's the hardness of the following problem: $\textbf{argmin}_x\{|x^2-2|\}$. By analytical calculation, I know the solution is $\pm \sqrt{2}$. But I am quite confused about whether it is hard with regarding to its computation complexity.
we know RAM contains instruction for we ask computer to do operations we know ROM contains instructions which for computer to work does this mean RAM contains address of instruction sitting in ROM? ROM tell how to add and RAM points to that address of ROM which tells cpu to add
this is a question given in a PDF about streaming algorithms (this isnt an assignment but im trying to understand) Exercise 4.4.1 : Suppose our stream consists of the integers 3, 1, 4, 1, 5, 9, 2, 6, 5. Our hash functions will all be of the form h(x) = ax+ b mod 32 for some a and b. You should treat the result as ...
Given a set $=\{_1,⋯,_\}$ where all $_$s are rational positive numbers and $\sum_{i\in N}a_i=1$, find a subset ⊆ such that $(\sqrt{2\sum_{i\in S}a_i}-1)^2$ is minimized. Does the appearance of √ make the problem ill-defined with regrading to complexity?
In following answer (LINK: https://bitcoin.stackexchange.com/a/58908/41513), it has been shown that for Asynchronous Byzantine Agreement: "we cannot tolerate 1/3 or more of the nodes being dishonest or we lose either safety or liveness." For this proof, the following conditions/requirements has been considered: O...
I am starting to learn recurrence relations in class and I am having issue with this example: T(N) = 2N - 1 + T(N-1) I am bit confused as to get the base case. I'm sorry if this seems elementary, but I am having a difficult time grasping this concept. Thank you for your help!
In a lecture on HPC parallel programming (for CPUs) we discussed various models available from Pthreads to OpenMP to MPI and others like Charm++, X10, UPC, Chapel…. The main focus was clearly on the first three. Intrigued by the topic I did some research on my own but could find sources, examples and discussions mainly...
Consider the following code snippet: for(int i=0;i<n;i++) The question I have is: whether this loop is executed $n$ times or $(n+1)$ times? According to what I understand: when $i=n$, the for loop would increment $i$ to $n+1$ and check if $i<n$ which would evaluate to false and the loop will be exited. So the incremen...
Please take a look at NP-hard or not: partition with irrational input or parameter first. In Will irrational parameters make a problem not well-defined on complexity, I got an answer of "No". Then I checked that some well-defined problems indeed have irrational paprameters(e.g., In the sum of square root problem, it...
Consider the following problem: Input: A graph $G=(V,E)$ and an integer $k \in \mathbb{N}$ Output: Are there $k$ vertex-disjoint triangles in $G$? Assume we want to use color coding to develop an FPT Algorithm for that, as done here (starting from slide 60). The reference material proposes the following method: Choose...
READ ME FIRST: I have just found the official solutions online (have been looking for them for a while, but after posting this I quickly found it), and I'm currently trying to understand it. As I can tell, it uses a much simpler DP, which only uses an O(N) array. EDIT 2 I kinda figured out what and how it does, but I s...
I am trying to understand how does Pollard's rho algorithm actually work, but I just can not wrap my head around it. I already read its section in the CLRS book and also on internet but still can not understand its structure or analysis. This is a java implementation of the pseudocode from the CLRS book along with euc...
There are many ways of solving Sudoku puzzles, however two good approaches are the Algorithm X and solving using Linear programming. Is it possible to solve the KenKen puzzle using Algorithm X (turning the problem into an exact cover problem) or using Linear programming and how could that be done if possible? Edit: Li...
An example from Sipser's book, Introduction to the Theory of Computation, shows that it is not decidable for a $TM$ to recognize whether a $CFG$ (or a type 2 grammar) generates $\Sigma^*$, where $\Sigma$ is the alphabet. Call this language $CFG_{all}$ But the above language is also not computably enumerable. There can...
Is it possible to constract Moore or Mealy machine to take input tape: 0011 and output: 00001111 (or vice versa). In other words, input and output have different size. I want to construct FSMs to produce different transformation patters: copy 2 times: 11 -> 11011, 101 -> 1010101 trim: 011100 -> 111, 000110 -> 11 fill...
Hello I solved this leetcode https://leetcode.com/problems/tree-diameter/ question reserved for people who pay the subscription. The question: Given an undirected tree (tree is not disjoint), return its diameter: the number of edges in a longest path in that tree. The tree is given as an array of edges where edges[i...
Is the statement true? I feel that the statement is true. I want to prove it but I don't know how to start the proof. Any help would be appreciated.
I am working currently as a research intern on Binarized Neural Networks where the weights and the activations of the network are binary. The architecture of this type of networks makes them memory efficient and computationally efficient, which makes them ideal for resource constrained environments, like embedded devic...
I am currently studying for an exam and stumbled upon the following task: Given the following problem: Input A set of points $P \subseteq \mathcal{Q}^2$ and $k \in \mathbb{N}$ Question Find the maximum subset $S \subseteq P$ such that no three points in $S$ are collinear. The task is to find a polynomial time 3-approx...
I'm working on a problem to generate all powersets of a given set. The algorithm itself is relatively straightforward: def power_sets(A): """Returns the power set of A as a list of lists""" if len(A) == 0: return [[]] else: ps_n1 = power_sets(A[:-1]) # Powerset of set without last element ...
I know if there is a decidable relation R(x,y) for x in A, then A is semi-decidable. But how can I prove the relation is polynomial time? For R(x,y), x is where M is a TM, y is the accepting configuration of M. Is this a polynomial-time relation?
I am following Section 13.2 of Mark Wilde's book. I reproduce the question here for completeness. Consider a wiretap channel $X\rightarrow Y,Z$ defined by the conditional probabilities $p(y,z|x)$ for inputs chosen according to some $p(x)$. The goal of maximizing private information is to transmit information from $X$ t...
$A$ is a set of all $\langle M \rangle$ that $M$ is a TM halting on all input strings $w$ such that $\lvert w \rvert \le q(M)$ where $q(M)$ is the number of states in $M$. Is $A$ semi-decidable? Is a complement of $A$ semidecidable? I think $A$ is semi-decidable. We can construct $M1$. $M1$ = "On input $\langle M \rang...
The Sipser text (3rd edition) contains a proof that 3-SAT is NP-Complete based on Boolean circuits. Part of the proof contains the remark that the reduction from the circuit to the Boolean formula can be done in polynomial time. First question: is it correct to say that if a circuit C of polynomial size exists, then th...
According to Chris Hankin in his book (Lambda Calculus a Guide for Computer Scientists). A reduction sequence $\sigma: M_0 \to^{\Delta_0} M_1 \to^{\Delta_1}M_2 \to^{\Delta_2}\ldots $ is a standard reduction if for any pair $(\Delta_i, \Delta_{i+1})$, $\Delta_{i+1}$ is not a residual of a redex to left of $\Delta_{i}$ r...
I watched a video for BFS from MIT and the algorithm the lecturer presented was really complicated compared to what I came up. My solution seems to work fine and walk through the vertices in the correct order. Am I missing something? public static void BFS(GraphNode currentNode, GraphNode searchedNode) { if (curren...
I am looking for an algorithm that will get an optimal projective undirected dependency parse. That is, given the sentence 'Mary does love John', and an edge-weight function $f$ (that is, a function from pairs of words in the sentence to real numbers), like $f$(Mary,does) = 1 $f$(Mary,love) = 5 $f$(Mary,John) = 2...
Let's assume that you found out that some problem $\mathit{\Pi}$ is PSPACE-complete (with respect to your favorite kind of reductions, say, logspace reductions). However, as there are dozens of well-known and very different PSPACE-complete problems, this characterization doesn't tell you much about the real hardness of...
Definitions of Rateless encoding and Online encoding are as follows. Error-correcting codes that employ no fixed block length are called rateless or fountain codes. Online encoding refers to the property that a symbol is encoded at once and without knowledge of previous encodings. Do both properties indicate the same t...
I'm working on an example which says that a string x is obtained from a string w by deleting symbols if it is possible to remove zero or more symbols from w so that just the string x remains. For example, the following strings can all be obtained from 0110 by deleting symbols: λ, 0, 1, 00, 01, 10, 11, 010, 011, 110, an...
I need a toolbox or software that takes a dataset as input, detect independencies among its random variables and produces the relative Markov Random Field graphical structure from that. Can anyone suggest a proper toolbox for doing this task automatically?
From the following link: https://www.csie.ntu.edu.tw/~lyuu/complexity/2016/20161129s.pdf So basically, in our iff proof, we have to show two directions: Forward: If Hamiltonian Path has a yes-instance, so does longest path. This makes sense because we can just let "k" = |V| - 1 if hamiltonian path is yes. Then clearly...
I'm practicing leet code questions and want to understand more fully how to determine Big O notation. What is the algorithmic complexity of my solution to the following problem? O(n^2) ? For every item in n I could loop an additional n[i] times. Or is it O(n) ? Given an array of non-negative integers, you are initiall...
I want to know, what if the DFA is merged states. So if my DFA starts with q0 and then have (q0,q1) state it goes to with an 'a' for example. How do I do the table filling method. I tried to rename the merged state, for example turning (q0,q1) to q4 for example. But then the issue is when I try to do the table filling....
I am looking at a problem that is often asked in interview settings. The problem statement is: Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. I want to talk about the naive solution, where we generate all contigous subarrays, ta...
The paper A LOGICAL CALCULUS OF THE IDEAS IMMANENT IN NERVOUS ACTIVITY has the following description of neurons, which I question if there is errata or perhaps I need more information to understand this. Looking at the picture below (b) is described as an OR gate. I'm confused because with either threshold being met o...
I am given an undirected graph. Initially all vertices are white. I need to color them black in such an order that the maximum number of vertices which are on the border between black and white regions is minimal. Is there an algorithm to find an optimal order for that? More formally. We are given an undirected, connec...
The question is: Return the length of the longest, non-empty, contiguous subarray of A with sum at most K. For example: A=[5,2,-1,0,3],K=1, the result is [2,-1,0] I am inspired by Shortest Subarray with Sum at Least K. Is it possible to solve this corresponding problem with a monotonic queue? If True, how? If not, Wh...
This is an artificial neuron of a NOT function from Rojas's ML book. I have a question on it's behavior. It's my understanding that the neuron produces a signal if it's inputs $x_1$ summed are $\geq 0$. In the following picture, if $x_1$ is 0, then the threshold 0 is met and there is an 1 output signal from this neur...
I've come to understand that programs are graphs on several layers. Call-graphs are an example that come to mind without a textbook handy, another is mutation flow. So I do understand that code is a graph, and that compilers and interpreters usually end up traversing the graph according to the rules of the language. ...
I've been thinking about path planning and am trying to make good heuristics for cases with multiple agents. Suppose there are sets $S_i$ of coordinates in $\mathbb R^2$ or $\mathbb R^3$, each of the same size n, for each possible value of $i$ where $i \in [0, ... k]$. A path is defined as k line segments connecting ...
There's a programming problem 'Restore IP Addresses' where given a string containing only digits, restore it by returning all possible valid IP address combinations. Example, "25525511135" returns ["255.255.11.135", "255.255.111.35"]. My solution basically breaks up the string (upto 3 chars at a time) and moves to the ...
I claim that the greedy algorithm for solving the set cover problem given below has time complexity proportional to $M^2N$, where $M$ denotes the number of sets, and $N$ the overall number of elements. Question: true or false? Approximation Algorithms, Vazirani, 2001, 1e, p.16, Algorithm 2.2: $C \leftarrow \varnothin...
Given a truth table, find the smallest size circuit computing it. Recently it was shown that for multiple output function the problem MSCP (Minimum Size Circuit Problem) is NP-Complete. The article is available online see. Question: What will be the impact of this problem? or I am not able to follow why this problem MS...
I am studying approximation Set Covering problem, from "Introduction to Algorithms by Thomas H. Cormen" book. What I cannot understand is why they use harmonic numbers to the proof? What harmonic numbers have to do with this?? I am totally confused..
I have seen several implementations of binary search where they can use either (left != right) or (left <= right). For example, in normal binary search where you check if target value is in the array, using inclusive right bound (right initially set to array size-1), you will use left <= right. When you want to find th...
I created something similar to Sipser's proof for the undecidability of $A_{TM}$ (theorem 6.5), "proving" the undecidability of a set that must be finite. Presumably, it's wrong, but I can't figure out why for the life of me. $A_R := \{\langle M \rangle | M = R \land M \text{ accepts "foobar"}\}$ Assume $D$ decides $A...
Pre-information: I'm sure someone has asked something along these lines, but no matter how I word it, I can't seem to find a definitive answer Question: Does RAM get some kind of indication as to how much data the CPU requires or is there a set amount of data and if the CPU needs more, it needs to call again (and what ...
Is there a good data structure for storing overlapping sets? Consider having multiple sets which can overlap in various ways and would like to store them in the memory and access efficient way. Example: A = {a, b, c, d} B = {a, b, c} C = {b, c, d} D = {a, b, d, e, f} Storage: W = {e} X = {b, c} Y = {d} Z = {a} B = Z ...
Here is a more readable version of the question: Prove that for all functions $g: \mathbb{N}\to\mathbb{R}^{\geq 0}$, and all numbers $a \in \mathbb{R}^{\geq 0}$, if $g \in \Omega(1)$ then $a + g \in \Theta(g)$ What I've done so far: In order for $a + g\in\Theta(g)$, $a+g \in \mathcal{O}(g) \wedge a + g \in \Omega(g)$. ...
Given the definition: Let Σ be the alphabet defined as follows: Σ = {e, l, v} We now define the set of strings P according to the following: BASIS STEP: If x ∈ Σ then x ∈ P RECURSIVE STEP: If w ∈ P and x ∈ Σ, then xwx ∈ P How to show that the string level is in P. I do understand what is being asked and that I m...
I'm not asking this question for the purpose of any particular project. Rather, I'm trying to understand how to translate non-trivial programs in imperative style to functional style. By functional program/style I mean one in which all objects are immutable and functions are pure, and so forth. The only example I've se...
I would really appreciate any thought on this, or under which category does this problem fall (Interval scheduling, Interval partitioning,...) I am really out of thoughts I have X number of classes each with starting, and finishing time, and N number of free classrooms. And I want to find the maximum number of non-conf...
I am trying to solve a modified version of the TSP. In my version, multiple visits to a city are allowed, as long as the path is the shortest, and also, only subset of the cities are compulsory to visit, as in, you can go through other cities to visit all the subset cities if path is shorter, but if not, the other citi...
I am trying to solve this recurrence assuming n is odd: $T(n) = T(n - 4) + \Theta n$ What I did so far was: First, $T(n - 4) = T(n - 8) + (n - 4) $, thus we get $T(n) = T(n - 8) + (n - 4) + n$ Next, $T(n - 8) = T(n - 12) + (n - 8)$, thus we get $T(n) = T(n - 12) + (n - 8) + (n - 4) + n$ Next, $T(n - 12) = T(n - 16) + (...
I am trying to build my own λ-calculus interpreter. So far it supports both call-by-value and normal order. I now want to try recursion via fixed points. The $Y$ combinator works with normal order, tested with the faculty function $$\text{fac} = \lambda f.\lambda n.\text{iszero}\,n\,1 (\text{mul}\,n\, (f(\text{pred}\,n...
I am trying to implement a completely fair scheduler. I want to know how to calculate the initial value of virtual run time of a process in order to insert the process into a red black tree
In this question, I asked about a reference for translating imperative code to functional code. I want to ask a more specific question here. How, in general, do we translate into functional style, a statement of the form: if (cond) then do x; else do y; I know that functional languages have if-then-else statem...
Turing machines are perhaps the most popular model of computation for theoretical computer science. Turing machines don't have random access memory, since we can only do a read where the slider is currently located. This seem unwieldy to me. Why don't theoretical computer scientists use a model with random access memor...
I have trouble putting this into formal mathematical terms, so let's suppose that I found the shortest path from A to E as A > C > D > B > F > E with Dijkstra's algorithm. Am I correct in assuming that the shortest path from C to B would be C > D > B, and that the shortest path from D to F would be D > B > F?
Imagine I have a 2D area where I have many simple polygons ("simple" meaning not self-intersecting, they are not necessarily concave). A polygon is given to me as a series of points. I have between 25 and 150 polygons in my area. I also have several thousand points that I need to figure out if they are inside any of th...