instruction
stringlengths
35
11.4k
Can someone give me suggestions how can I construct a 2-tape Turing machine which simulates PDA ?
$\mathsf{LTIME = DTIME(\log n), NLTIME = NTIME(\log n)}$. For example, it seems that NTM can find an element in unsorted array in log-time by use of non-deterministic binary search (check if first half leads to solution and if second half leads to solution). Obviously, it can't be done by log-time deterministically. I ...
Let us define a "root universal family" as a family of hash function which for every two items $k_i,k_j$ the probability $P(h(k_i)=h(k_j)) \le \frac{1}{\sqrt m}$ where $m$ is the size of the table. Now, let us have $|U| = n$ - (the size of the given universe, note that it is perfect hash). Define an efficient perfect ...
I know what are both locality principles and pipelining techniques. But I can't see any sort of interconnection between the two things. How can locality principles impact pipelining techniques?
The Queen of England wants to organize a set of tables for n guests talking different languages. The tables have to be set in a way that every guest can speak to his neighbor on the right and his neighbor on the left. Four possibilities come up : 1- One table for all guests. 2- One table for all guests, but we alternat...
Set Cover: Consider a set of points X and Si a subset of X. The goal is to get the minimum number of subsets Si such as all points in X are covered. An example is shown by figure bellow. In this case, optimal solution should be OPT = {S3, S4, S5}. Greedy Algorithm: greedy(X, F = {S1, S2, ...}) G_OPT = {} ...
Given a Problem $A$ that has an answer $true$ if and only if both conditions $1$ and $2$ are $false$, for some conditions 1 and 2. Whether condition $2$ is $true$ can be tested with certainty in deterministic polynomial time. Thus, we can say that answer to an instance of $A$ is $false$ in polynomial time (in case cond...
Are there computational models that can be considered useful for solving common programming problems, where it can be proven that computation will terminate for all possible inputs?
For a given positive number n. Numbers from 0 up to n, are streamed one by one in some order without repetition. What would be recommended a strategy to store the order of these n numbers in the most space conservative way? Highest priority is to consume minimal bits to store the order. Second highest priority is to ha...
There seems to be various implementations of algorithms that find the connected components of a graph. I have not found, however, an algorithm or implementation for finding which of the connected components are also complete. Does anybody know of one? Thank you!
I have been trying to find the algorithmic complexity of a problem that I have. I am almost sure it is either NP-hard or NP-complete but I cannot find any proof. Recently, I found that my problem can be something similar to a special instance of the Maximum Capacity Representatives problem, which is NP-complete. Howeve...
While watching MIT's 6.006 Lecture # 4 which is on heaps and heapsort, the professor was explaining why the time complexity of the max_heapify procedure is $O(\lg n)$. It's quite intuitive that it's bounded by $\log n$. But there's a lurking reason also, that affects the implementation, and that reason was the key assu...
Question: Given 2 arrays of size $n$, $A = \langle a_1,a_2,\dots,a_n \rangle$ and $B = \langle b_1,b_2,\dots,b_n\rangle$, where $A$ and $B$ store the binary value of an integer. Find $A + B$ and stores the result in array $C$ of size $[n+1]$, $C = \langle c_1,c_2,\dots,c_{n+1}\rangle$. Pseudocode: ADD-BINARY(A,B) C = n...
Hi! I'm new here, a terrible computer-scientist, and have no idea what I'm doing; I'm more expecting / hoping for links to research on algorithms or data-structures that contribute to problems like this, than a straightforward answer (I don't even know how to properly ask the question.) In some programming-language w...
Currently, it is not proven that $NP \geq O(n \log n)$ in the Turing Machine Model. The weakness of this statement can be illustrated by NP-complete problems, which we think require way more time. But I'm looking for the easiest-to-solve decision problem in P that probably has $\Omega (n \log n)$ as lower bound in the ...
I want to construct a linear bounded automata for the language $L = \{a^nb^{2n} \mid n\geq1 \}$ . I know how LBA works but I don't have an idea how it can count the numbers of a's and check if the b's are 2 times more than a's. I would like to to hear some suggestions.
Let's consider the following algorithm to multiply squares matrix: A is a matrix of NxN. r_i, r_j defines interval of rows. For example r_i = 2, r_j=3 means the second and the third rows. c_i, c_j means the same as r_i, r_j but for columns. We assume that N = 2^s for some s. mul(A, B, r_i, r_j, c_i, c_j){ if(r_i != r_...
I found the following set of lemma in my lambda calculus textbook : Lemma 1.16 Let $x, y, v$ be distinct (the usual notation convention), and let no variable bound in $M$ be free in $vPQ$. Then (a) $[P/v][v/x]M \equiv [P/x]M$ if $v \notin \mathrm{FV}(M)$; (b) $[x/v][v/x]M \equiv M$ if $v \notin \mathrm{FV}(M)$; (c) $[...
I am reading Categorial Grammar: Logical Syntax, Semantics, and Processing by Glyn Morrill and I am stuck with the Fig. 3.9: Can someone explain this set of formulas and |.| function specifically? This figure displays the definition of the |.| function that maps some proof (of some formula) in Lambek calculus (as frag...
This imaginary problem involves a vector of length 5, with each value to be selected from a unique range of values. A real-world example might include 5 different single-digit combination locks. How many different ways could I lock a single gate, assuming that I can use any number of locks? Assuming that each lock tak...
"We need $k$ to be large enough so that $(\frac{1}{2})^k = O(\frac{1}{n})$, and to do this we can choose $k = \log_2 n$. Thus, when $k = \log_2 n$, the size of the active region has been reduced to a constant, at which point the recursion bottoms out and we can search the remainder of the array directly in constant tim...
I am working on a Recommendation System as a personal project (I finish it on time, I'll present it as my final year project). I devised mathematical methods that estimated User's ratings of products based on their previous ratings, without using ML. I developed a host of such algorithms for recommendation (I developed...
In chapter of Hardness of Approximation in V. Vazirani's book it says: For establishing a hardness of approximation result for, say, the vertex cover problem, PCP theorem is used to show the following polynomial time reduction. It maps an instance φ of SAT to a graph G = (V,E) such that • if φ is satisfiable, G has a ...
I came across the following theorem in page 12 of the following pdf : There exists an oracle relative to which there is a problem solvable in polynomial time (with bounded error probability) on a quantum computer, but any probabilistic Turing Machine with bounded error probability solving this problem (using the...
I'm trying to show that the language in the title is not regular but I don't know how to chose a decomposition $x = abc$ to express the word in the language because the $w \in \{a,b,c\}^*$ is kinda tricky for me, I know it means $ \{ a,b,c\} \cup\{ a,b,c\}^2 \cup ... \cup \{ a,b,c\}^k $ but I don't know how to chose th...
Not All Equal SAT is an NP Complete problem. Let us now consider another variant of the problem. Given a Not All Equal SAT (NAESAT) problem (arbitrary number of literals allowed per clause) with an additional constraint that each pair of clauses share at least 1 literal (not variables but literals). Is this problem sti...
Question 1 From busy beaver uncomputablity it follows that we cannot design algorithm that for every input N, generate the appropriate set of TM instructions (the bit value of every bit in every card) that run and output BB(N). As i understand, the number of bits in the cards is growing almost linearly with N, so the ...
To tune the parameters of Particle swarm optimization (PSO), there are two methods offline and online. In offline manner, the meta-optimization is used to tune the parameters of PSO by using another overlying optimizer. In the online manner, there are two techniques, Self-Adaptation, "consisting of adding some or all o...
I'm trying to prove that the language L generated by the CFG $S \to aS | aSbS | \varepsilon$ is the language $L=\{ w \in \{a,b\}^*: \text{every prefix of $w$ has at least as many $a$'s as $b$'s} \}$.I proved the first inclusion $w \in L(G) \implies w \in L$. I can't prove the vice versa. By induction on the lenght of $...
L = {w#x | w,x ∈{0,1}∗ and Turing Machine Mw with input x visits every non-end state at least once} I believe this problem is undecidable. My proof would consist of me reducing L to a Halting Problem; however, the structure of these proofs seem incosistent and inconclusive. I would appreciate if I could have some const...
I know that quick sort has an average case of O(nlogn). And I also know that the average case of comparison-based sorting algorithms are Omega of nlogn. Can we say that quick sort is the best sorting algorithm in average case compared to other comparison-based sorting algorithms? (I think the answer is yes. However, I ...
I found the following set of lemma in my lambda calculus textbook : Lemma 1.16 Let $x, y, v$ be distinct (the usual notation convention), and let no variable bound in $M$ be free in $vPQ$. Then (a) $[P/v][v/x]M \equiv [P/x]M$ if $v \notin \mathrm{FV}(M)$; (b) $[x/v][v/x]M \equiv M$ if $v \notin \mathrm{FV}(M)$; (c) $[...
I'm looking for some guidance to get me going. I assume (and please correct me if I'm wrong) that it'll need 2 tapes and by reading various resources, I found that it might be easier with the binary string reversed. In any programming language, I would first convert the binary string to decimal, but is this needed/a go...
Let's state a collection of key/values. Key is an unsigned integer (0 - 2^32-1). Hense there are comparable. Value is few bytes fixed size. There are 4M items in the collection. Keys are not evenly spread in the key space i.e there is no way to predict hole size between two consecutive keys. This collection is created ...
I'm working on a recommendation system. My system uses user's past rating data, to predict future ratings. I designed mathematical methods for generating recommendation algorithms that allows me to generate an unlimited number of recommendation algorithms (given a large enough set of relevant ratings). I intend to ag...
Main Question We can represent subsets of a vector using, say, a bit mask. Let's say a nested subset is a pair of masks, for example A B C D E F 1 0 0 1 0 1 1 0 0 0 0 1 is a nested subset, where the first mask tells us inclusion in the first set and the second mask tells us inclusion in the first. In this case the fir...
I am reading a paper on recognition of online handwritten characters. One of the features proposed in the paper is "normalized first derivatives, $(\hat{x}'_t,\hat{y}'_t)$", which they have defined as follows: $$ \hat{x}'_t=\frac{x'_t}{\sqrt{(x'_t)^2+(y'_t)^2}}\quad\quad \hat{y}'_t=\frac{y'_t}{\sqrt{(x'_t)^2+(y'_t)^2}}...
A receipt is an array of products. I have an array of receipts. I need to generate a report in where I can find the products often bought together. For instance, for a single receipt where the products bought are [A, A, B, B, B, C], a report would look like Pair - count A&B - 2 A&A - 1 B&B - 1 A&C - 1 B&C - 1 Notice t...
I am aware of the frequent use of "smoke and mirrors" in order to achieve the effect of non-euclidean geometry, but I was wondering it if it possible to implement spherical (sometimes called elliptic) and hyperbolic geometries. If so, how would we do that?
Is $DSPACE(f) \subseteq DTIME(f)$ always? For example, if we have a language $A\in DSPACE(log^2(n))$ can we say that $A\in P$ (and subsequently in NP and coNP) since $DSPACE(log^2(n))\subseteq DSPACE(n^3) \subseteq DTIME(n^3)$? I know about $ DTIME(f) \subseteq DSPACE(f) \subseteq DTIME(2^{O(f)})$ but $DTIME(2^{O(f)})...
Let me first sketch my situation. I have a list of events with time slots, and I need to generate a schedule from these. We can assume that I have already validated and ordered the events from lowest to highest priority, so I will have a list like: Starts Ends Event --------------------------------- 0 12 B...
In the Geometric Spanner Networks book by Giri Narasimhan and Michiel Smid Page 153 says Definition 9.1.3 (Well-Separated Pair Decomposition). Let $S$ be a set of $n$ points in $\mathbb R^d$, and let $s > 0$ be a real number. A well-separated pair decomposition (WSPD) for $S$, with respect to $s$, is a sequence $\{A_1...
I am trying to generate a list of digit triplets to specify stimuli in an auditory (speech-in-noise) perception experiment. Each triplet has to have three different digits (i.e., no repetition within triplets). I have recordings of digits 0-9, recorded in each triplet position (i.e., I have 30 digits, 0 in 1st position...
I need to create a simple text parser that replaces {tokens} with text from a table. The more complicated bit is the {?text?} tag where text must be included only if the preceding AND the following tokens exist and are not empty. You could do {?text} where it looks for a non-empty neighbouring tag only on that side. I ...
I'm writing a paper on the system I designed which upon receiving an event, performs a number of calculations and publishes the result to several subscribers. I can calculate the amount of time it takes from the moment the system is informed about the event, to the moment when all subscribers successfully received the ...
In polar codes, the frozen bits in each message are determined through the worst channel, where the relevant parameter is the Bhattacharyya . How can I estimate Bhattacharyya parameter for BSC channel?
We have Some big hashed array of data with boolean values, we know keys, but don't know values. Oracle who have input of array of keys and can tell how much of them are true (it Answers with number T) Number of keys N, true values M, for example M/N = 0.4 How to find a way to make own array of keys, length be M and ...
Given an array of $n^2$ integers, what is the most efficient way to determine whether any permutation of those integers can form a magic square? "Magic square" being an arrangement of those integers on a square grid such that all rows, columns and diagonals sum to the same value. Note that this isn't asking how to test...
If a language $A\in DSPACE(n^c)$, then $EXP^A\neq EXP$ If a language $A\in DTIME(n^c)$, then $EXP^A= EXP$ What I tried: Since it's impossible to show that $EXP \subseteq EXP^A$ because: We know that $DSPACE(n^c)\subseteq DTIME(2^{n^c})$ exponential functions aren't closed to composition so from the above two, ...
I have a circle with radius $R$ and $N$ points on a 2D plane with known locations $(x_i,y_i), i=1,2,..N$. I want to place the circle such that it maximizes the number of covered points. Let $d_i=(x_i-x)^2+(y_i-y)^2$ be the square of the distance between the point $i$ and the potential center of the circle $(x,y)$. To e...
Dynamic Programming seems to result in good performance algorithms for Weakly NP-hard Problems. Two examples are Subset Sum Problem and 0-1 Knapsack Problem, both problems are solvable in pseudo-polynomial time using Dynamic Programming. It turns out this is a pretty good result in most cases. On the other hand, Stron...
What is the fastest way to select $n$ values from an $n$ by $n$ matrix such that each value comes from a different row and column and the sum of those n values is minimized? For example, given the matrix: $$A=\begin{bmatrix}0 & 1 &5 \\1 & 4 & 3\\2 & 7 & 0\end{bmatrix}$$ The solution is $\{A_{1,2}, A_{2,1}, A_{3,3}\}$,...
I want to know if the recurrence equation $T(n) = 9T(\frac{n}{3}) + nlogn$, can or cannot be solved using master theorem. At first, I naively went for $O(n^2)$ applying case 1 of master theorem. But then someone pointed out that $f(n)=nlogn$ and $n^{\log_3 9}$ do not have polynomial difference and therefore master th...
Given the space A of all programs that could be possibly written in a given language and given the space B of all programs that could be possibly written in the same language but without any mutable state: can we be sure that with just B we can solve all the same problems we could solve with A ?
Unique SAT is defined as: Given any SAT problem, does the SAT problem have exactly 1 solution? As I understand it is co-NPHard. I am unclear how it is in co-NP Assuming the problem has more than 1 solution, any 2 solutions can be a certificate of it being nonUnique. That part is coNP. Now, given a problem can be unsat...
Is every instruction ultimately all read or write instructions? So, how I imagine this is that every place where something can be stored can be either in a read or write state, including the CPU registers. How this is controlled is by the control unit. Every instruction goes through the control unit which is connected ...
I have the following problem: Given an unsorted array A of size n, print the first k elements in A larger than its median. Here's my approach to the problem: 1. Create a minHeap and a maxHeap 2. Iterate over elements in A // O(n) - if maxHeap.count < minHeap.count insert current element t...
I am looking to implement a neural network on hardware using Verilog. I have completed and tested with floating point representation and a 20 bit fixed point representation. I want to further reduce the memory utilisation by using dynamic fixed point. I want to identify the less important weights, and assign them a sma...
Computer Science has a broad spectrum of disciplines ranging from AI, Big Data, Cryptography to Human Computer Interaction and Bioinformatics. I would like to know what projects are ideal for undergrad students of CS among these disciplines that can attract funding from European and American firms.
So let's say you have a histogram distribution represented as an array where each element is equal to the number of numbers from the underlying data set that are equal to that element's index. For example, if your underlying data had 5 0's, 18 1's, 11 2's, 0 3's, etc., then the array representing this distribution woul...
I'm trying to find CFG for the language $$L = \{ a^nb^mc^kd^l | n + k = m + l, (n,m,k,l) \in \mathbb{N} \}$$ and what I have done so far is to make PDA which simply does the following: If on the stream there is "a" -> push $\xi$ in the stack If on the stream there is "b" and the stack is empty -> push $\zeta$ in the s...
i am looking for an algorithm that will generate all possible combinations of words from given dictionary that satisfy given format. Let me explain what i mean with format: For example, if the format is "abcd" means that we are looking for one word, length of the word must be 4 and because all the letters in format ar...
Given a list of entries entryList, determine a 4x4 matrix of which you sum up the entries specified in entryList such that there is no other matrix for which the sum of entries specified in entryList is greater. In other words: entryList specifies some entries, now imagine an arbitrary 4x4 matrix m, entryList tells us ...
Problem: Looking for an efficient algorithm to find the largest value that exists in all columns. Constraints: The values in each column are always decreasing My algorithm: Check the first row for match Use the lowest value from first row to search for match Use the value from row x, column y to search for match I...
I'm trying to figure out optimal round 1 openings for this game: http://generals.io/. For the purposes of this question, I've simplified some of the rules and mechanics of the game, and I assume that there are no opponents. Here are the basic rules/mechanics/assumptions: The game is played on a board of size m * n, 16...
How do I calculate the information density of an encoding system? This question came up as I was reading several papers about encoding data in DNA (I think I have gone through just about every major paper on encoding data in DNA after Church's). All of them mention the information density of their encoding system, whic...
And obviously there will be no trivial vertex which has only 2 edges. I think triangle free graphs are (subjectively) easier than complicated graphs, i wonder if you know some heuristic approaches/steps specificly for triangle free graphs. Thanks in advance
I was reading "Principles of Database & Knowledge-Base Systems, Vol. 1" by Jeffrey D. Ullman. There is a chapter about Datalog negation and as I was seeing the problems of negation I kept thinking that using the predicate $ \neq $ would solve those problems but then I see the following: p(X) :- r(X) & ¬q(X). q(X) :- r(...
Let $A$ be a sorted array of $N$ values. I am interested in finding the index $j$ such that the elements $A_j, A_{j + 1}, ..., A_{j + k - 1}$ have the $k$ closest values to the given target value $T$. Assume that $k$ is comparable, in magnitude, to $N$; i.e. we don't have $k \ll N$. One can naively do this by first (bi...
I have a reduction and can't understand if it is Karp reduction. I want understand if my reduction is Karp reduction as well as understand how to determine which one is so. Let I have formula $\Phi = (l_{1,1}\lor l_{1,2}\lor...\lor l_{1,k_1})\land(l_{2,1}\lor...\lor l_{2,k_2})\land...\land(l_{n,1}\lor...\lor l_{n,k_n})...
I was learning about support vector machines from MIT OpenCourseWare. I figured it out. I understand why we try to minimize $\frac{1}{2} w^2$. I just did not get why we try to maximize Lagrange expression like said at 35:56 in the YouTube video. Margin (width) of the support vector is $2/\|w\|$. We want to maximize wi...
I come to you with a problem I have been struggling with for the past few weeks. I would like to classify (complexity) a special case of Unique Coverage. To set the mood on, I will start by introducing the Exact Set Cover and Unique Coverage problems. I will then go over the special cases I am interested in. Set coveri...
I'm trying to find sup of $\|\mathbb{G}\|$ where $\mathbb{G}$ is CFG in Chomsky Normal Form. So far i have done some work, but I'm really not sure in my proof. Let $G = \langle Q, N, S, R\rangle$ and $$\alpha \rightarrow \beta \in R,\ |\beta| = n$$ $$\|\alpha\| \le \sum_{i=0}^{\log_{2}n}2^{n}\,.$$ I made this conclusio...
Question Is it possible to find an existing point's nearest neighbour within a logarithmic upper bound? What I've tried I have: the set of points $P$, a point $p$, where $p\in P$, a point $q$, where $q\notin P$, a Voronoi diagram, $V(P)$, of the points in $P$. I know it's possible to query for a new point $q$'s neare...
First question, and my apologies if it is off-topic! This question suggests to me I may not be totally off-base. Where did our present regex notation originate? I am particularly wondering how $ came to mean "end," particularly since its most common use in the English-speaking world (as far as I know) is as a prefix ...
My problem is to find a better algorithm to fill the adjacency list. specs: G = (V , E ) //the graph V ={w} //vertex in this case each vertex is an array E={⟨u,v⟩| u,v ∈V ∧ u>v} // edge only if u > v u > v only if foreach i u̸=v ∧ u[i]≥v[i]. // (u>v and v>w => u>w) my naive code whit complexity O((v+1)*v/2) ≈ O(...
I have an old exam question for my pattern recognition course which is stated as follows: Consider a pool of Haar features, determine if these Haar features are independent or not. Is it a problem in boosting algorithms (e.g. AdaBoost)? Why (not)? I have a really hard time figuring out an appropriate response to this...
During a lot of algorithm competitions I met colored tree questions and there have been multiple cases where I though of different approaches. I'm curious what is the best way of solving the following problem: Given a tree with N nodes: 2 <= N <= 100 000. Every node has a color c : 2 <= c <= 100 000. You are supposed a...
Lambda calculus can be used for encoding semantics of natural language, e.g. http://yoavartzi.com/tutorial/ contains full details about semantic parsing of natural language: converting natural language texts into lambda expressions - Cornell Semantic Parsing Framework is used https://github.com/cornell-lic/spf. My ques...
The order of the classes of three does not matter. Example: 1,2,3 and 3,2,1 would be considered one class. I am trying to do fisher discriminant analysis on a set of data and want to begin reducing the parameters to better help with classification. As of now I cannot tell which parameters are the most pertinent, so loo...
The time complexity of a Binary Search is O(log n) and Hashing is O(1) - so I've read. I have also read that Hashing outperforms Binary search when input is large, for example in millions. But I see that log n, when n is around 30 million, is roughly equal to 25. If for such a large value of n, log n is just 25, then i...
As background, in Information Retrieval, there are many metrics to assess how well search results are retrieving information. A simple one is precision, where we calculate the fraction of documents returned that are relevant to our query. There is a second (or more general?) metric, precision@K: For a ranked result se...
I was going through the project lists of Andrew NG from his Stanford machine learning course and I found a project based on recreation of calligraphic characters. To do so firstly we need to extract strokes from characters and I can only understand it in bits and pieces and I cannot understand at all how to implement i...
$L = \{ 0^m10^n|m\geq1 \wedge n\geq1 \}$ Is this a regular language? A language is regular when there is a DFA accepting the language. Since there is a DFA accepting this language I suppose that it is a regular language. But as I have seen in the book it says that it is not regular. So I am confused. Can someone guide ...
Considering the complexity classes $NP$, $co-NP$ and $PP$: $NP$ and $co-NP$ are both contained in $PP$. For any Language $L$ suppose we have the mechanism that: If the oracle of $co-NP$ implies $No$ on a modified version of $L$ (lets call it $L'$), then that we can be certain that for every run of $PP$ on $L$ would re...
Within CSS we talk about binary interactions. Does this prevent synchronizing multiple processes in one step? Example: $P_1 ::= a.D$ $P_2 ::= \overline{a}.D$ $P_3 ::= a.D$ Let's consider the following LTS: $(P_1 | P_2 | P_3)\restriction_a$ Do I get $P_1, P_2, P_3$ $\tau$-synchronized simultaneously if an action $\tau$ ...
The problem Given an undirected graph $G=\left(V, E\right)$ and positive edge weights $w_e$, design a 2-approximation algorithm based on the primal-dual principle. So far I managed to represent the problem with a linear program: Linear Program Primal $\min \underset{e\in E}{\sum} w_e x_e$ s.t. $\underset{e|v\in e}{\s...
Are there some languages not regular and/or not context-free in which the proof by contradiction fails? Why we need a "more specific" version of pumping lemma?
If A is an array with the following elements: $$ a_1,a_2,...,a_n,b_1,b_2,...,b_n $$ How to shuffle A to form: $$ a_1,b_1,a_2,b_2,...,a_n,b_n $$ with minimal swaps and using no additional space? I read this answer and wrote the following code: def shuffle(a,left,right): if right - left>=4: half = (right - left)/2 ...
On an HDD if data is fragmented the discs need to be spun to where the next block in the file is, so how and where data is stored can make a big difference in how long it takes to retrieve the data. With an SSD is the retrieval time for fragmented data constant (due to no moving parts and it being entirely electronic)?...
Prove that given a number we can find whether there're 2 elements in a red/black tree that their sum equals that number in $\Theta(n)$ time and constant space. The original problem appears here, however the solution uses $\lg n$ space. A problem in my course required adjusting the algorithm such that we use constant ...
I'm looking at Jeffrey Erickson's Notes on the master theorem (page 10). Part (b) of the theorem states that if $T(n) = aT(\frac{n}{b})+f(n)$, $af(\frac{n}{b}) = kf(n)$ and $k>1$ then T(n) is $\Theta(n^{\log_b(a)})$. But I get a different result. Using recursion trees we have $$T(n) = \sum_{i=0}^{\log_b(n)} a^i f\left(...
Can there be a genuine algorithm in which number of memory reads far outnumber the no. of operations performed? For example, number of memory reads scale with n^2, while no. of operations scale with only n, where n is the input size. If yes, then how will one decide the time complexity in such a case? Will it be n^2 o...
I've heard of bigO notation but I don't really understand how do I determine it for my code and what exactly does it represent? I heard that there are two: RunTime Memory Complexity How can I learn to use it?
I'm playing around with some historical stock data and attempting to optimize a portfolio. I essentially have created a function that generates certain statistics about a portfolio (right now it's composed of a list of equities with corresponding weights). The portfolio is constant and tracked over a historical time ra...
I'm trying to write a small algorithm to detect and delete duplicate lines inside a subset of consecutive lines in a file. I've come up with 2 similar solutions. After some quick tests, I've noticed that one of them is much faster than the other, especially on large files. But I don't understand why. Here's the quick s...
I am currently doing a course based on algorithms (Coursera). I've come across an algorithm called quick find. The course does have reference to Big O Notation. Despite the fact that I do not have much knowledge of Big O, I have been doing some basic reading. Implementation (Java): Initializes the array: public QuickF...
The Bentley–Ottmann algorithm, for example, has time complexity of $O((n + k) \log n)$. Is the statement $O((n + k) \log n) = O(n \log n)$ true? I know that $k$ is there because it has big enough of an impact on the overall time complexity that it's relevant to include it. But can it be ignored, so that the previously ...
Language $L$ is sparse if there exists a polynomial $p$ such that $|L ∩ \{0,1\}^n| ≤ p(n)$. Thus, if there are at most polynomial number of strings for each length $n$ in the set $S$ (where $S$ represents the language $L$), the set $S$ is a sparse set. Mahaney's theorem states that if an NP-complete language is Karp-re...
What does "n" or "N" in asymptotic notation actually means? It is usually stated that the "n" is the size of the input. Does it mean that it is the size of the algorithm,that it the size of the whole chunk of algorithm,meaning if a algorithm has 20 lines it's "n" is more than a algorithm which have 10 lines.