instruction
stringlengths
35
29.1k
Even though the input I type is a "Y" or "N" string, I can't break out if this while loop. Can anyone tell me why? public String yesOrNo(String message) { String yesOrNo; do { System.out.print(message); yesOrNo = input.next(); } while(yesOrNo != "N" || yesOrNo != "Y"); return yesO...
I'm learning the basics of computers, and now trying to get some oversight of complexity of a CPU. Is there a rough trend for how transistors are allocated in a CPU? Intel 8008 for example, has 3500 transistors. In this image of it, I can see the space each component occupies. The ALU as example, each ALU slice is 20 t...
The following question is from MIT-OCW 6.006, Spring-2008, Problem-Set 2, Q-3.c. Suppose you have a hash table where the load-factor $\alpha$ is related to the number $n$ of elements in the table by the following formula: $$ \alpha = 1 − \frac{1}{\log n} $$ If you resolve collisions by chaining, what is the expected ...
I have typically heard computer performance discussed in terms of FLOPS. However, I have recently seen multiple references instead using OPS i.e. operations per second, typically in the context of Big Data. What is the difference between FLOPS and OPS? Why use one over the other? I appreciate that they are both metrics...
Proove that for every infinite $L \in R$ there is a $L' \subseteq L$ s.t $L' \notin RE$. How can I proove it? if sketched on venn diagram it doesn't make sense... From my point of view everything that is in R suppose to be in Re. $x \in A $ and $A \subseteq B$ then $x \in B$. Why does it fail? and how am I suppose to...
I know this is an amateur question but is it true to say that for any three nonempty languages $L_{1},L_{2},L_{3}$ over an alphabet $\Sigma$ we have $L_{1}(L_{2} \cap L_{3}) = L_{1}L_{2} \cap L_{1}L_{3}$ if and only if $L_{2} \subseteq L_{3}$ or $L_{3} \subseteq L_{2}$? Some theorems in mathematics lead me ask this. If...
If we have all these optimized programs for very specific tasks, what would be the antithesis of them? I've asked a programmer friend of mine, and they thought a good answer had to do with multi-dimensional arrays and nested for-loops in graphics programming. I just want to see what other answers there are. Essentially...
For the following recurrence relation: $$T (n) = T (n/2) + n(2 - \cos n)$$ I see it based on values of $\cos$ function given that it output values in range, but this does not seem to have anything to do with solving the problem. I found a solution which says that comparing this to master method yields that this does no...
I am studying Computer Architecture with MIPS-32. The example system has 32 registers with each register having a width of 32 bit. If I would want 128 registers instead of 32 registers, would I have to increase the width of each register to 128 bit as well? Or do I just need 64 bits, which is enough to address the new ...
Is it possible to write a program that is able to recognize some source code as being its own source-code? Biological organisms evolved the ability of kin-recognition, and later, self-recognition, early on. This led to the evolution of the immune system. Of course the immune system does not go through the DNA of a pote...
I understand this should be a relatively easy proof, but I can't seem to understand how to do it. I know that, by Big O definition: there exists some value $c_1$ where $f(n) \le c_1 \cdot h(n)$ for all $n \ge n_0'$ there exists some value $c_2$ where $g(n) \le c_2 \cdot h(n)$ for all $n >= n_0''$ and I have to find s...
Let's consider this CFG- S->AB [Here, **S** is the starting variable] A->C CB->Cb C->a Now, the question is- Check if ab is a valid string for the given string or not? I thought an answer. And that is- S->AB ->CB [A->C] ->Cb [CB->Cb] ->ab [C->a] My question is, Can we generate string ab from this CFG in this way?...
My question is about the paper Ensembling Ten Math Information Retrieval Systems. I am interested in the task of finding answers. Which of the ten system are able to answer questions using only dot products? (I think CompuBERT is one of them, look)
I am reading the paper Space-Efficient Online Computation of Quantile Summaries and get really stuck trying to understand Lemma 3 onwards. I am sorry it sounds like a lot of questions - this just outline my confusion throughout the proof - you don't have to answer these, an explanation of how the proof actually work wo...
This question is about CompuBERT (new implementation). I have read textual data have high dimensionality so I would like to know the behaviour of CompuBERT which uses a dot product for question answering. If I increase the embedding dimension will CompuBERT suffer from the curse of dimensionality? (I googled for the sa...
Polynomials are usually written as a sum of powers (or various products of generators) and Google gives me lots of results on how to get from that to the form that is a product of degree-$1$ polynomials (where you can see where the polynomial vanishes), e.g., $$ x^2 - 1 = (x + 1) (x - 1) $$ I am looking for the other d...
I was studying CRC and came across modulo 2 arithmetic. When we add two 1 bit numbers like 1 + 1, 0 + 1, then the result is summation modulo 2 which is similar to XORing of the two bits. My doubt is when this is extended to multiple bits why is the solution not summation modulo 2 i.e. one bit result either 0 or 1, inst...
I want to implement an Index using a B+Tree as the underlying data structure. The index will have to support key sizes which are of order of my block size, what means I cannot save all the key as a pivot in the B+Tree inner nodes, since the branching factor would be too small which results in too many IOS for any read/...
Based on the answer by Will Ness, I've been using a JavaScript adaptation for the postponed sieve algorithm: function * primes() { yield 2; yield 3; yield 5; yield 7; const sieve = new Map(); const ps = primes(); ps.next() && ps.next(); for (let p = 3, i = 9; true; i += 2) { let ...
This is from question 3(a) from http://www.cs.cmu.edu/afs/cs/academic/class/15210-s14/www/exams/exam2-practice-sol.pdf, which is: consider an undirected graph $G$ with unique positive weights. Suppose it has a minimum spanning tree $T$ . If we square all the edge weights and compute the MST again, do we still get the s...
Suppose I have a list that reflects the priority of web pages for recrawling: l1 = [3, 2, 1, 4, 2, 5] Now, I have tried to estimate the priorities with two different approaches and have obtained two lists: l2 = [4, 2, 4, 3, 2, 1] l3 = [1, 3, 5, 2, 4, 6] I can use the Spearman correlation or C-Index to know which of l...
My question is about the paper Ensembling Ten Math Information Retrieval Systems. I already know the algorithms in the paper can answer questions only using dot products (look the post). How can I optimize them? Could you add here (and in the next paper you will produce) the complexities of time preprocessing, memory a...
We say $x$ is a majority substring of $y$ if $y \in \Sigma^* x \Sigma^*$ and $|x| \geq \frac 12|y|$. If $B$ is a regular language, is the set of majority substrings of $B$ regular? I was provided the following solution, but I don't understand it: Let M be a DFA that recognizes B. Construct an NFA $N$ that accepts its ...
The recursion is: T(n) = 5T(n/2) + O(n) I solved for the time complexity using Master theorem and found Θ(n^2). but, the question has asked to find the upper bound in terms of Big Oh. Is there any principle to convert it into Big Oh form? I read some examples where they substituted some values and deduced but I couldn...
I am trying to understand how a router's forward table works. As such, I am working on the following problem. Problem: A router’s forwarding table has the following entries. \begin{array} {|r|r|}\hline Network \, Number & Next \, Hop \\ \hline 0.0.0.0/0 & 15.15.1.2 \\ \hline 192.140.20.0/24 & 15.15.1.8 \\ \hline 1...
I am having a hard time wrapping my head around the time-varying edge cost of this question : Suppose we have a connected graph $G = (V, E)$. Each edge e now has a time-varying edge cost given by a function $f_e$. Thus, at time t, it has cost $f_e(t)$. We’ll assume that all these functions are positive over their enti...
I have two recursive algorithms to solve a particular problem. I have calculated their time complexities as $O(n^2\times\log n)$ and $O(n^{2.32})$. I need to find which algorithm is better in terms of time complexity. I tried plotting graphs but two functions seem to be going together.
I am learning algorithm complexities. So far it has been an interesting ride. There is so much going behind the scenes that I need to understand. I find it difficult to understand complexity in recursive function. my_func takes an array parameter A of length $n$. Runtime of some_func() is constant. def my_func(A): i...
If so, I don't understand how, as a large part of back propogation is knowing what the 'real' answer is in comparison to 'predicted' answer. With 1 neuron in a hidden layer, we do not know the 'real answer' so theoretically it is impossible unless another technique is employed?
Given an array unsorted P of integers and a number m. I am trying to write a code that returns indices i, and j to satisfy 8P[i] + 7P[j] = M with time O(n log n). I iterated over P[0] to P[n-1] and searched for P[j] = (M - 8P[i])/7 using binary search. Here, I can get the values of P[i] and P[j], but the original index...
Consider there's an 5 elements list that foreach element are 2-bits. Forexample [01,00,10,00,11], if the list is sorted, we hope the output like this [00,00,01,10,11] Maybe that case seems complicated, let's move to simple case. Consider there's an 2 elements list that foreach element are 1-bit. Forexample [1,0], if th...
Suppose there are 10 (4x4) matrices, where the elements in each matrix are dependent on one variable ($\theta$) non-linearly. All the matrices are independent of each other, so there are 10 $\theta$s ($\theta _{1}$, $\theta _{2}$, $\theta _{3}$, $\theta _{4}$,......). Now, let the input matrix be A, and an output matr...
An array has elements from set {0, 1, 2}. A span SP of an array is any interval [start S, end E] such that the sub array must contain all elements from {0,1,2}. For example: in Array A = (0,1,0,1,1,2,0,1) we can say SP=[1,6] and SP=[5,8] but [1,5] is not a span as elements in array from index 1 to index 5 (0,1,0,1,1) d...
"A theory of type polymorphism in programming" introduced the Hindly-Milner type system whose punchline can be summarized "well-typed terms don’t get stuck". They do this by creating a relatively simple language with just enough features that an untyped stuck expression is possible. For instance, true false is stuck ...
Let $G$ be a directed graph such that every edge is colored (red, yellow or green). I want to compute the shortest walk (possibly with repeated vertices) with the restriction that the colors are alternating: red, green, yellow, red, green , ..., etc (the starting color doesn't matter). So far my idea is to create a new...
This question is about the article Sub-Linear Memory How to Make Performers SLiM. I googled for the fastest transformer and I think almost surely I found. It is called SLiM. The problem is the authors use only GPUs and I don't understand much about GPUs. I don't even know whether there are algorithms that run only on G...
In Haskell, we can use the following code to define fibonacci numbers, fibs = 1 : 1 : zipWith (+) fibs (tail fibs) And its time complexity is linear. I cannot find a way to do it in lambda calculus or combinatory logic. With Y combinator, it leads to exponential steps to evaluate. Is it possible in lambda calculus? Is...
I am trying to implement stacking orders While the most optimal solution would be to consider picking up orders from nearby restaurants that have similar food prep time AND nearby delivery locations. I'd like to start off with something slightly easier - that is stacking orders only from the SAME restaurants that have ...
Let be: Uppercase letters — non-terminal symbols. Lowercase letters — terminal symbols. Possible cases: The number of words is 0 (infinite substitutions). Examples: $$\{S \rightarrow aS\}, \\ \{S \rightarrow aF, F \rightarrow aS \}, \\ \{S \rightarrow aA, S \rightarrow A, A \rightarrow FS, F \rightarrow t\}$$ The nu...
I am working on chapter one of the textbook Computational Complexity: a modern approach by Arora, S., & Barak, B. They begin by defining a turing machine (TM) and then prove equivalence between variations of TMs. They make the following claim. Claim 1.6 Define a single-tape Turing machine to be a TM that has only one re...
Let's have a relation $R = (name, surname, age)$. I want to obtain a new relation with only the $name$ attribute. In relational algebra I would simply do $\Pi_{\mathrm{name}}(R)$ but in relational calculus the general way of doing that is $$ \newcommand{\Set}[2]{% \{\, #1 \mid #2 \, \}% } \Set{t}{\exists z \; (R(z) \...
I keep reading that while bottom-up parsing of a left-recursive grammar can be done in constant O(1) stack space, for a right-recursive grammar, we have to push the entire input stream onto the stack before popping any of them off. Why is this? Let's say that I consider a simple right-recursive grammar List -> elt List...
This question is about de paper Extending Multi-Sense Word Embedding to Phrases and Sentences for Unsupervised Semantic Applications. I am interested in the transformer part of the paper and the main structures of the algorithm is represented in the following image: Before the main questions I have other questions whi...
When I was reviewing a book, I saw that there's a sentence claiming "side effect is a term coming from the domain of functional programming". I would think that the concept existed before the invention of the functional programming paradigm, but the author is asking for a citation that I was not able to find. Does the ...
$ \newcommand{\Set}[2]{% \{\, #1 \mid #2 \, \}% }$ I've been trying to find how to express relational division operation in tuple relational calculus. The only thing I found is this presentation where on the page 4 it is said that for relations $R = (A, B)$ and $S = (B)$ the division is $$ R \div S \equiv \Set{t}{\ex...
Consider the language $$ L = \{2^k : k \text{ is prime}\}. $$ This language contains, for example, $2^3=222$, $2^5=22222$, $2^7=2222222$, and so on. I know that $L$ is irregular and so there must exist a set of strings that are pairwise distinguishable with respect to $L$, but I'm struggling to come up with such a set ...
I am learning computer network, and confused by the queuing delay. In my textbook, it says that when La/R approaches 1, and with random inter-arrival times, then the average queuing delay is closer to infite. Here, R is the transmission rate, a is in units of packets/sec and all packets have L bits data. In my view, if...
Given two recurrences: $T(n) = 2 T(n/2) + n \lg \lg n$ $T(n) = 4 T(n/2) + n \lg \lg n$ I'd think that both works for master theorem, but the solution is that the first one cannot use masters theorem while the second one works with masters theorem. The only difference here is the $a$ value (2 vs 4).
I have written a yacc program for generating palindromic strings consisting of 0s and 1s. Here is the rules section of the yacc program below: %% program: expr NL { printf("Valid string.\n"); exit(0); } ; expr: ZERO expr ZERO | ONE expr ONE | ZERO | ONE | ; %% Here ZERO is the token representing 0, ONE is the token ...
Let $W$ be an array of weights. Store all the weights of $W$ in bins such that in each bin a heavier weight always go before a lighter weight (if $w_i\in W$ is stored before $w_j\in W$ then necessarily $w_i > w_j$), and the original order of the weights in $W$ is preserved ($w_i \in W$ cannot be stored before $w_j \in ...
I am trying to solve the following problem: If all of the jobs listed below are scheduled FCFS (First Come, First Serve) with no switching overhead, the average turnaround time is going to be: Arrival Duration 0 10 1 9 2 8 3 7 4 6 My calculation is: (10 + (10 + 9) + (10 + 9 + 8) + (10 + 9...
I am currently trying to implement a algorithm for the game "Eternal Return: Black Survival" as a kind of exercise in Rust. Since the game may not be familiar to many, here is a quick explenation so you can understand what I want to achieve. Eternal Return is a Multiplayer Online Battle Arena (or MOBA) with battle roya...
So first, just to make sure that I understand the proof, here is the proof as I understand it: Take a program $H(x,y)$, which determines whether $x(y)$ will halt or not halt: if $x(y)$ halts then $H$ returns true, and otherwise it returns false. If $H$ exists, we can construct a new program $H'$ which has one input $x$...
In the Modern Operating System by Andrew Tanenbaum, Herbert Bos the authors provide their explanation of the concept of CPU utilization in the following way: A better model is to look at CPU usage from a probabilistic viewpoint. Suppose that a process spends a fraction $p$ of its time waiting for I/O to complete. With...
Is there any free/open-source environment, tasks, or dataset for evaluating deep RL algorithms in terms of safety? all available environments (like openAI's) are environments for simple games. These can be useful in evaluating the algorithms in terms of sample efficiency, variance and speed of training. However, How c...
I am trying to solve the recurrence $$T(n) = T(n-1) + (-1)^nn, \quad T(0) = 1.$$ I'm stuck in the summation: \begin{align} T(n) &= T(n-1) + (-1)^n n \\ &= T(n-2) + (-1)^{n-1}(n-1) + (-1)^nn \\ &= T(n-3) + (-1)^{n-2}(n-2) + (-1)^{n-1}(n-1) + (-1)^nn \\ &= \\ &\cdots \\ &= T(n-k) + (-1)^{n-(k-1)} (n-(k-1)) + (-1)^{(n-(k-...
I am required to show that the class of singletons $H_{sing}$ is learnable in the realizable case (without invoking the VC-dimension). $H_{sing}$ is defined as $H_{sing} := \{h \in \{0, 1\}^X : |\{x \in X : h(x) = 1\}| \le 1\}$ Also I need to prove if this class also learnable if $X = R$? Can someone please help ?
I apologize for the vagueness of the title, but this question is quite difficult for me to describe. For that reason, I'm unable to directly convey my problem. In an effort to circumvent this, I've created an example. You've been instructed to help style your corporation's new website. It's almost done, but you've rea...
I have $k$ sorted arrays stored as linked lists. I need an algorithm to merge them into one single sorted array, also stored as a linked list. How can I do that? My Code: Function merge(A[k]) Begin: // A is array of list to merge. Array result; temp //array to save element in each list For (i=0:i<k:i++): Temp.add(A[...
Finding a short point on a lattice is hard, but I was wondering if finding a vector on the lattice which the fewest non-zero terms was easier? Are there any good approximations like LLL, but which produce lattice points with lots of zeros?
If given any two language both $L_1$ and $L_2$ are decidable then why both $L_1\leq_m^\mathsf{}L_2$ and $L_2\leq_m^\mathsf{}L_1$ are false. Please provide easy explanation with any counterexample for both cases. Any language $L_3$ is given as Undecidable and $L_4$ is decidable then $L_3\leq_m^\mathsf{}L_4$ is false....
I'm new in theory of computation. Here {0,1} set of input symbols. I tried to make the NFA from L(M)= set of all accepted strings, but unable to complete it. Can someone give some hints that how should I attack this problem? . It will be very helpful.
I'm looking at geometric objects on the sphere and need to determine if a point on the sphere is inside a spherical polygon. In our case a spherical polygon is a an ordered set of vertices $v_1v_2...v_n$ and the edges $v_iv_{i+1}$ are given by great circle arcs. The polygon is uniquely defined by a counterclockwise wal...
I have a question that says that the complement of a regular language given as: $L_1=\{a^nb^m|(n+m)<5\}$ is $L_2=\{a^nb^m|(n+m)\geq5\}$ over $\Sigma=\{a,b\}$, and therefore, we can simply construct finite automaton (FA) of $L_2$ by simply interchanging the accepting and non-accepting states of $L_1$ . However, as per ...
[Updated question] A Dynkin System is, provided all sets are finite, a collection of subsets of a universal set closed under complements with the universal set and closed under union of disjoint sets. In particular, every Dynkin system contains the universal set and the empty set. Fix a finite set $\Omega$ and let $\ma...
In the Wikipedia article on Rogers' theorem, it is stated that the proof given by Rogers is a construction of a partial recursive function which implements the Y combinator. I've just a basic knowledge of both the theory of recursive functions and the lambda calculus, however I (think I) know what the Y combinator is a...
I have an unordered set of n unique, positive integers. I want to partition it into ceil(n / k) unordered sets of up to k numbers (k << n) in a deterministic way (I want to get a sequence of the same ceil(n / k) output sets without depending on a fixed order of the input). Is there a way to do so that has superior algo...
Suppose I have the following Petri net: I wonder whether it is possible to model an inverse relationship between $p2$ and $p3$. Basically what I want to achieve is to make either $t1$ or $t2$ fireable but never both. Currently, I just set a token in $p2$ and leave $p3$ empty if I want to make $t1$ fireable (or vice ve...
I would just like to discuss with you first part of the proof for quick sort please unless you need more details. Probabilistic fact: For a quick sort please, given that the expected number of coin tosses in order to get $k$ heads is $2k$. Definition:A good call to quick sort should give partitions each of size at most...
There is plenty of research into the so-called "random SAT" problem, where we basically try to solve SAT instances with clauses chosen "at random" in some sense. There are all kinds of variations of this problem, mostly referring to how the clauses are chosen. Typically you see it written as the random "$k$-SAT" proble...
In a French course (p. 13) there is a language of words of {a,b,c} containing at least one occurrence of the string bac. The course provide also among other things this right-regular grammar below: T = { a,b,c } N = { S,U,V,W } R = { S → aS | bS | cS | bU U → aV V → cW | c W → aW | bW | cW | a | b | c...
This is related to the discussion of average case of quick sort. Given that we have a sorted sub-array $Z_{ij} = i, i+1, \dots, j$ where $i < j$. Claim: $i$ and $j$ are compared if and only if, among all elements in $Z_{ij}$, the first element to be picked as a pivot is either $i $ or $ j$. Forward direction Proof: T...
Let $T_1$ and $T_2$ be two spanning trees. If $a$ is an edge in $T_1$ that is not in $T_2$, and $b$ is an edge in $T_2$ that is no in $T_1$. I want to prove that $T_1 - \{ a\} + \{ b\}$ is a spanning tree. I have an idea of what is happening but I don't know exactly how to write the proof. I know that $T_1 - \{ a\}$ cr...
I am planning to teach approximation algorithms for problems such as job scheduling and number partitioning. I would like to teach proofs, but the proofs I found in the original papers (e.g. this one) are quite hard to understand - they use complicated weighting schcemes, and there is no explanation of how these partic...
For Turing machines, if the input variables increase, will the state set Q increase ? will the tape alphabet Γ increase? For example, for the SAT problem, the first question is whether the Boolean expression of one variable is satisfied, the second is whether the Boolean expression of three variables is satisfied. Does...
Question: Suppose we have the following array where we want to find the smallest $i$th smallest element in the array using QuickFind algorithm (similar to QuickSort): $$ QuickFind\left( A,n,i \right) =\left\{ \begin{array}{l} QuickFind\left( A,k-1,i \right) ,\ i<k\\ QuickFind\left( A,n-k,k-i \right) ,\ i>k\\ ...
Given recursive equation, $T(n) = 3T(\frac n3 + 5) +\frac n2$ $$ \begin{align} T(n) = 3T(\frac n3 + 5) +\frac n2 \tag{1} \label{1} \\ \lt 3T(n- 15) +\frac n2\\ \lt 3 \left(3T\left(\frac{(n- 15)}{3} +5 \right) + \frac{n-15}{2} \right) + \frac {n}{2} \tag{2}\label{2}\\ \lt 9T(\frac n3) + 3\frac {n-15}{2} + \frac n2 \tag{...
If any language $L_1$ reduces $L_2$ in polynomial time $L_1\leq_p^\mathsf{}L_2.$ If $L_1$ is recursive then $L_2$ is recursive and recursively enumerable, is it true? Because $L_2$ is at least as hard as $L_1.$
My question is about CompuBERT (Three is Better than One Ensembling Math Information Retrieval Systems) It is written on page 21 (table 2): "we assigned a distinct mask for math tokens on input, often used to distinguish between different input languages" I haven't found the implementation of the assignement of a dis...
This question is about de paper Extending Multi-Sense Word Embedding to Phrases and Sentences for Unsupervised Semantic Applications, depicted in the following picture: I am interested in more information about the problem of given a new phrase, find the most similar phrase among billions of phrases. Is it possible to...
Given a $k$-sorted array where each element in the array is $k$ positions from its correct position, we want to sort such array using quick sort. Generally speaking, I understand that running time is very unlikely to be guaranteed for best case and thus in most cases you would end up with $O(n^2)$ running time though q...
I have an input of 128 bits (binary, 0s and 1s) and want to hash this input with 32 bit CRC. But I am not sure if collision rate is moderate or too high ? Is it 2^128/2^32 = 2^98. And does that means 1 collision after 2^98 hashes OR something else ? I am a little bit confused with the math involved. Is there any ot...
well-known that a loop-programm in Theoretical computer science always terminates, but why do that java example not? for( ; ; ){ }
What would happen if the CPU data-bus bit 2 is connected to the RAM data-bit 5 and CPU data-bus bit 5 is connected to RAM data bit 2? Assume the rest of the connections are all right – explain.
I have a cloud of points in $\mathbb{R}^n$ and I want to embed them in Hamming Space. One possible solution is for example found in Inductive Hashing on Manifolds. The problem is: I need an extremely fast evaluation of a new embedding when a new point arrives in my data (the so called out-of-sample extension problem) b...
A naive algorithm for determining whether a graph with $|V|$ vertices has a clique of size $k$ is to list all $k$-subsets of $V$, and check each one to see whether it forms a clique. Why is the running time of this algorithm $\Omega(k^{2}{|V| \choose k})$? Specifically, where are we getting $k^2$?
Given constants $c_i > 0$ and $K > 0$, find $b > 0$ numerically such that $b^{c_1} + b^{c_2} + \dots + b^{c_n} = K$. I'd like to solve this with a non-iterative method if possible. My attempt at isolating b (applying the identity $\log(x + y) = \log x + \log(1 + y/x)$): $$K = b^{c_1} + b^{c_2} + \dots$$ $$\log(K) = \lo...
Def: the stability of algorithm is defined in case of the algorithm preserves same value elements while sorting as the following shows: So for this QuickSort algorithm: public class QuickSort { public static int[] sortedData; public static void sort(int[] data, int low, int high){ sortedData = data; ...
When I look at the following algorithm, I believe I understand how bubble sort works. procedure bubblesort for i := 1 to n − 1 for j := 1 to n − i if a[j] > a[j+1] then interchange a[j] and a[j+1] endif endfor endfor endprocedure However I am ...
I'm starting my masters in CS soon, and I have to decide on a general research topic. In my undergraduate studies, I've enjoyed courses regarding data structures and algorithms the most. I'm also an avid competitor in competitive programming events, which involve a fair chunk of algorithms. I've talked to multiple prof...
Can an instance of the Post Correspondence Problem (PCP) have exactly one solution?
I have a simple program which achieves a certain functionality. I’m interested to know if it can be proven that the steps in the program are the theoretically simplest way to achieve those results. Is it an established practice in computer science to prove that an algorithm or program is the theoretically fastest way t...
In $k$-sorting array algorithms, every element is supposed to be $k$ positions from its correct positions. So with that in mind, if we used a randomized QuickSort, we will have $O(n\log{n})$. Now to prove a lower bound on this, we assume $k \le \frac n2$. Question: Prove that you can not do better than $O(n\log n)$ on ...
It seems like a lot of programming is about converting a high-level human intuition into a very precise, ordered set of steps and conditions for the computer to execute correctly. I think programming could match the way people think more if we could write instructions which refer back to previous parts of the program w...
The language that accepts strings with the number of 0s being congruent with 1%3 and an even number of 1s over the alphabet {0, 1}.
I was wondering what books are there that give you nice overview of the computer science field. I'm not interested so much on the details of the trees, but on the forest. I was thinking it would have to be something like a popular introductory book, preferably up to date. I hope this question is within the forum's scop...
Suppose that the language $L_1$ reduces to the language $L_2$ in polynomial time, $L_1\leq_p L_2$. If $L_2$ is recursive enumerable then so is $L_1$, but why isn't $L_1$ recursive? Because $L_2$ is at least as hard as $L_1$, and so $L_1$ could be easier than $L_2$. Why isn't $L_1$ recursive? Explain with an example.
Do the following measures qualify as computational resources? number of even-numbered states that the machine $M$ visits on input $x$ number of times that the machine $M$, when run on input $x$, rewrites symbols on the tape
I am dealing with a knapsack-like problem with one difference from the conventional problem: the “weights” can be positive or negative and the constraint is $\sum w_i x_i \ge 0$ instead of $\sum w_i x_i \le W$. The "values" can also be positive or negative. Can this be transformed to a knapsack problem or is it some ot...
Corollary:1 We know that if $A\leq_m^\mathsf{}B$ and $B$ is decidable then $A$ is also decidable. This is because if there exists a specific algorithm for solving $B$ and we can also reduce $A$ to $B$ then we can have a solution of $A$ as well. Hence $A$ is decidable. We know that regular languages is always decidable....