def Arithmetic (n):     for i in range (1, n):           for j in range (1, (i + 1) / 3):               a = n^i - j/3       return a   How do I determine the Big O for this algorithm? Given that the second loop has a maximum with the first loop result.
304
Most people with a degree in CS will certainly know what . It helps us to measure how well an algorithm scales.   But I'm curious, how do you calculate or approximate the complexity of your algorithms?
71433
How do you prove $\lim_{n\rightarrow\infty} n(2^{1/n} - 1) = \log 2$ ?  Background: in computer science, if you allocate CPU time to $n$ processes by , all the processes get sufficient amount of time when the quantity $U$ called CPU utilization is less than or equal to $n(2^{1/n} - 1)$.  It is monotonously decreasing and tends to $\log 2$ when $n\rightarrow\infty$, so if $U \le \log 2$, you can be sure all the processes will be given sufficient CPU time.
84766
I am having trouble and was wondering if someone could go over the steps slowly to show that:  $$2n + 3 &lt; 2^n \ \text{for} \ n \geq 4$$  Any help would be amazing!
30799
This is a homework question. But I am completely stuck.  My only intuition was to go about it inductively from a "greedy algorithm" maybe know as the deletion-contraction algorithm. And to somehow use the information about the jth cycle to solve the j+1th. But I'm not sure how I'd do it. Thank you very much for looking this over.
33744
To each vertex of a pentagon,we assign an integer $x_{i}$ with sum $s=\sum x_{i}&gt;0$. If x,y,z are the numbers assigned to 3 successive vertices and if $y&lt;0$,then we replace $(x,y,z)$ by $(x+y,-y,y+z)$.This step is repeated as long as there is a y&lt;0.Decide if the algorithm always stops.
15071
Suppose $m, n$ are infinite ordinal numbers. $$a) m=n → |m|=|n|$$ $$b)|m|=|n| →m=n$$ $$c)m&lt;n→ |m|&lt;|n|$$ $$d)|\max{(m,n)}|&lt; |m|+|n|$$ $$e)|m|&lt;|n| →|m|^{|n|}&lt;|n|^m$$  Which of the above statements are true? (a) looks true but I do not know the way to work it out. Please help
26974
Okay, so I needed to find the smallest value of n such that algorithm 100*n^2 is faster than 2^n.   [what I have tried]  So, I instantly thought '0'. But, I then realized it can't be 0, 0 implies that there are no digits being entered in the algorithm, it also implies that the program does not run or terminate.   I typed in 2^32 and got a number over 4 billion. Okay, this is good, I'm finding numbers that have 100*n^2 being faster than 2^n.   I halved that, n = 20.  I kept inserting values counting down until I got to n = 15.   I also counted up from n = 10, the answer is undoubtedly n = 15, but I have a problem . . . .I solved this using brute force and that isn't good. What if I was given a bigger number and a larger bredth of numbers?  [What I need]  I need a way of finding the value instantaneously by only doing the math, I tried using logarithms, but my answer was wrong, my knowledge of logs is a bit rusty and I need a little help.  Think of it as a student trying to solve a question on an SAT or having a timer for a test.
51733
Consider all possible values for $(a_1,\ldots,a_n)$ (where each $a_i$ may be a positive integer or 0) when  $a_1 + \cdots + a_n = n$.  Consider $(a_j,\ldots,a_k)$ the values in $(a_1,\ldots,a_n)$ which are non-zero.  Given a set of values for all $a_i$, $j\le i\le k$ can we check whether they maximise $\operatorname{lcm}(a_j,\ldots,a_k)$ without testing all other cases?  Is there a computationally viable way  to always pick values for all $a_i$ which maximise $\operatorname{lcm}(a_1,\ldots,a_k)$?
37239
In a few programming contexts, I've come across code along these lines:  total = 0 for i from 1 to n     total := total + n / i   Where the division here is integer division. Mathematically, this boils down to evaluating  $$\sum_{i = 1}^{n}\left\lfloor\, n \over i\,\right\rfloor.$$  This is upper-bounded by $n H_{n}$ and lower-bounded by $nH_{n} - n$ using the standard inequalities for $\texttt{floor}$'s, but that upper bound likely has a large gap to the true value.  Is there a way to either get an exact value for this summation or find some simpler function it's asymptotically equivalent to?
60872
I've tried solving it, but I'm not familiar with these kind of progressions and I couldn't get to a result. Also, I've found that the result is just $N/2$, but I don't get why would that be the answer, as it doesn't work for $N=1$ or $N=2$. Appreciate your help :)
10400
Suppose I have $$ \large\sum_{i=1}^{10} 2. $$ Do I just add $2$ to itself $10$ times? I have worked on more complex ones with $n$ and such in the place where the $2$ is, but I have never done it when there is just a number there.
74131
I was doing some software engineering and wanted to have a thread do something in the background to basically just waste CPU time for a certain test.  While I could have done something really boring like for(i &lt; 10000000) { j = 2 * i }, I ended up having the program start with $1$, and then for a million steps choose a random real number $r$ in the interval $[0,R]$ (uniformly distributed) and multiply the result by $r$ at each step.   When $R = 2$, it converged to $0$. When $R = 3$, it exploded to infinity.    So of course, the question anyone with a modicum of curiosity would ask: for what $R$ do we have the transition. And then, I tried the first number between $2$ and $3$ that we would all think of, Euler's number $e$, and sure enough, this conjecture was right. Would love to see a proof of this.    Now when I should be working, I'm instead wondering about the behavior of this script.   Ironically, rather than wasting my CPUs time, I'm wasting my own time. But it's a beautiful phenomenon. I don't regret it. $\ddot\smile$
57062
Today I needed a simple algorithm for checking if a number is a power of 2.  The algorithm needs to be:   Simple Correct for any ulong value.   I came up with this simple algorithm:  private bool IsPowerOfTwo(ulong number) {     if (number == 0)         return false;      for (ulong power = 1; power &gt; 0; power = power &lt;&lt; 1)     {         // This for loop used shifting for powers of 2, meaning         // that the value will become 0 after the last shift         // (from binary 1000...0000 to 0000...0000) then, the 'for'         // loop will break out.          if (power == number)             return true;         if (power &gt; number)             return false;     }     return false; }   But then I thought, how about checking if log2 x is an exactly round number? But when I checked for 2^63+1, Math.Log returned exactly 63 because of rounding. So I checked if 2 to the power 63 is equal to the original number - and it is, because the calculation is done in doubles and not in exact numbers:  private bool IsPowerOfTwo_2(ulong number) {     double log = Math.Log(number, 2);     double pow = Math.Pow(2, Math.Round(log));     return pow == number; }   This returned true for the given wrong value: 9223372036854775809.  Is there a better algorithm?
40045
I wonder whether there is any automatic way of determining (at least roughly) the Big-O time complexity of a given function?  If I graphed an O(n) function vs. an O(n lg n) function I think I would be able to visually ascertain which is which; I'm thinking there must be some heuristic solution which enables this to be done automatically.  Any ideas?  Edit: I am happy to find a semi-automated solution, just wondering whether there is some way of avoiding doing a fully manual analysis.
71717
I've written some code that takes two integer arrays (one of moduli and one of remainders) and returns a number that solves this set of congruences.  It's working, but it's not giving me the smallest possible answer, and I'm not quite sure how to achieve this.  I followed what was written  to write my code.  The code looks like this:  def crt(m: Array[Int], r: Array[Int]): Int = {     assert(m.length == r.length)     for (a &lt;- m; b &lt;- m if b != a) assert(coprime(a, b))     for (a &lt;- m) assert(coprime(m.product / a, a))     val parts = for (i &lt;- 0 until m.length) yield {         r(i) * modinv(m.product / m(i), m(i)) * (m.product / m(i))     }     parts.sum }   For example, crt([3,5,7], [1,3,5]) returns 157, which isn't incorrect, but the lowest possible (and thus the "best" answer) is 52.  I don't know what I'm doing wrong or what I could do to change this, and whether or not it's the algorithm over at MathWorld or a fault in my implementation.
76571
This question is about asymptotic notation in general. For simplicity I will use examples about big-O notation for function growth as $n\to\infty$ (seen in algorithmic complexity), but the issues that arise are the same for things like $\Omega$ and $\Theta$ growth as $n\to\infty$, or for little-o as $x\to 0$ (often seen in analysis), or any other combination.  The interaction between big-O notation and equals signs can be confusing. We write things like $$\tag{1} 3n^2+4 = O(n^2)$$ $$\tag{2} 5n^2+7n = O(n^2)$$ But we're not allowed to conclude from these two statements that $3n^2+4=5n^2+7n$. Thus it seems that transitivity of equality fails when big-O is involved. Also, we never write things such as $$\tag{3} O(n^2)=3n^2+4,$$ so apparently commutativity is also at risk.  Many textbooks point this out and declare, with varying degrees of indignation, that notations such as $(1)$ and $(2)$ constitute an "abuse of notation" that students are just going to have to get used to. Very well, but then what are the rules that govern this abuse? Mathematicians seem to be able to communicate using it, so it can't be completely random.  One simple way out is to define that the notation $O(n^2)$ properly denotes the set of functions that grow at most quadratically, and that equations like $(1)$ are just conventional abbreviations for $$\tag{4} (n\mapsto 3n^2+4)\in O(n^2)$$ Some authors even insist that writing $(1)$ is plain wrong, and that $(4)$ is the only correct way to express the estimate.  However, other authors blithely write things like $$\tag{5} 5 + O(n) + O(n^2)\log(O(n^3)) = O(n^2\log n)$$ which does not seem to be easily interpretable in terms of sets of functions.  The question: How can we assign meaning to such statements in a principled way such that $(1)$, $(2)$ and $(4)$ are true but $(3)$ is not?
101929
I need a way to compute the nth root of a long integer in Python.   I tried pow(m, 1.0/n), but it doesn't work:     OverflowError: long int too large to convert to float   Any ideas?  By long integer I mean REALLY long integers like:     11968003966030964356885611480383408833172346450467339251   196093144141045683463085291115677488411620264826942334897996389   485046262847265769280883237649461122479734279424416861834396522   819159219215308460065265520143082728303864638821979329804885526   557893649662037092457130509980883789368448042961108430809620626   059287437887495827369474189818588006905358793385574832590121472   680866521970802708379837148646191567765584039175249171110593159   305029014037881475265618958103073425958633163441030267478942720   703134493880117805010891574606323700178176718412858948243785754   898788359757528163558061136758276299059029113119763557411729353   915848889261125855717014320045292143759177464380434854573300054   940683350937992500211758727939459249163046465047204851616590276   724564411037216844005877918224201569391107769029955591465502737   961776799311859881060956465198859727495735498887960494256488224   613682478900505821893815926193600121890632