I have a piece of code in Java that I have been struggling to understand what is the time complexity... In the best case scenario I believe it might be O(n) and the worst case probably O(n^2) because it could go in recursion for n times... Is this right??  All the other methods are O(1)  public void associateblocks() {     Block block = head;     while (block != null) {         Block block2 = block.getNextBlock();         if (block2 != null) {             if (block.getSize() == block2.getSize() &amp;&amp; block.isFree() &amp;&amp; block2.isFree()) {                 block.setSize(block.getSize() * 2);                 block.setIndex((block.getIndex() - 1) / 2);                 block.setNextBlock(block2.getNextBlock());                 associateblocks();                 freeBlocks.remove(block2);             }         }         block = block.getNextBlock();     } }
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?
Is there any way to tell the compiler, inside the main file body, how to find the class? I would like to use a class that belongs not found in my MiKTeX database. I know I might as well pick up this class and put it in some directory inside the base and update MiKTeX, but I do not want to do that. What I want is to organize it into a subdirectory within the same directory as my main tex file. However, when compiling the tex file, the class is not found. Of course, if I put the direct class in the same directory as the main file I will solve the problem, but that's not what I want. So, I ask: Is there any way to tell the compiler, inside the main file body, how to find the class?  Note: I'm using MiKTeX as an example, but I'm really having the problem in overleaf. There was a revtex upgrade from version 4.1 to 4.2. However, overleaf does not find revtex4-2.cls, which is, in fact, the class I'd like to use.  Below, I show an example of how I would like to organize the files. Note that the class is in a subdirectory. ,  and 1 still show the old bar. 1 See Fisher Information of a function of a parameter Determinant of a specially structured matrix ($a$'s on the diagonal, all other entries equal to $b$) I have the following $n\times n$ matrix:  $$A=\begin{bmatrix} a &amp; b &amp; \ldots &amp; b\\ b &amp; a &amp; \ldots &amp; b\\ \vdots &amp; \vdots &amp; \ddots &amp; \vdots\\ b &amp; b &amp; \ldots &amp; a\end{bmatrix}$$  where $0 &lt; b &lt; a$.  I am interested in the expression for the determinant $\det[A]$ in terms of $a$, $b$ and $n$.  This seems like a trivial problem, as the matrix $A$ has such a nice structure, but my linear algebra skills are pretty rusty and I can't figure it out.  Any help would be appreciated. How can I use an array modifier to create individually manipulatable objects? I've created a new user by using "User Accounts" in "System Settings". How do I grant rights so that this new user can have the same level of access as root? ALTER table - adding AUTOINCREMENT in MySQL Have men and women in the Wizarding World always had relatively equal rights? There are racial struggles and examples of racism, (Muggle-borns, centaurs, hous-elves, goblins, etc.) but are there any examples in the Wizarding World of sexism?  Have witches and wizards always had equal rights? How to calculate stays against 90/180 visa rules? Some destinations have a "90/180 rule" which says you can come and go but you must not spend over 90 days out of any 180 days in the area.  concerns this rule.  At least Schengen and Turkey have this rule, probably depending on where the traveller is from and what kind of visa they apply for.  Maybe I'm a dummy but I've always had a lot of trouble trying to add up how many days I've spent in such places when I've entered and left several times over recent months.  Is there an easy way to do this I'm missing or is it difficult for everybody? I'm guessing something based on counting backwards from the end date might be the trick?  Maybe you know of an app or website that can do this for you. What is the difference between $* and $@? Consider the following code:  foo () {     echo $* }  bar () {     echo $@ }  foo 1 2 3 4 bar 1 2 3 4   It outputs:     1 2 3 4       1 2 3 4   I am using Ksh88, but I am interested in other common shells as well. If you happen to know any particularity for specific shells, please do mention them.  I found the follwing in the Ksh man page on Solaris:     The meaning of $* and  $@  is   identical  when  not  quoted  or  when  used  as a parameter   assignment value or as a file name. However, when used as  a   command argument, $* is equivalent to ``$1d$2d...'', where d   is the first character of the IFS variable,  whereas  $@  is   equivalent  to  $1 $2 ....   I tried modifying the IFS variable, but it doesn't modify the output. Maybe I'm doing something wrong? How do I use F3 to get my coordinates when my laptop makes F3 a special key? How to convert date to timestamp in PHP? How do I get timestamp from e.g. 22-09-2008? How to change Gnome-Terminal title? I have several instances of terminals running in my working environment, what I would like is to set a specific title for each one, in order to have a clear idea what purpose the specific terminal serves i.e. Apache, editing_ini, postgres etc...  Of course from the command line. There's a fairly standard two or three-semester curriculum for introductory quantum field theory, which covers topics such as:   classical field theory background canonical quantization, path integrals the Dirac field quantum electrodynamics computing $S$-matrix elements in perturbation theory, decay rates, cross sections renormalization at one loop Yang-Mills theory spontaneous symmetry breaking the Standard Model   What is a good, complete and comprehensive book that covers topics such as these? If I type something like this:  {\itshape\LARGE   Dunt venim dolorerosto do odit   ametum vulla conum dolore   conulput in vero od el   Dunt venim dolorerosto do odit   ametum vulla conum dolore   conulput in vero od el }   it results in a block of 4 lines with narrow spacing between the 1st and 2nd line and between the 3rd and 4th line. Line spacing between the 2nd and 3rd line is normal.  I can't fully explaing it to myself so I am looking for a short description for this behaviour. I know for example that with a \par at the end of the text (inside the group), the calculation would correct. But I have no idea why... Let $X, Y$ be independent standard normal random variables.  We already know that $X+Y$ is normal with mean 0 and variance 2. However, I am trying to prove this result in a slightly different way than usual, i.e., using convolutions.  We can address the problem in the following way: the sum of the two variables has a density $h(x)$ given by the convolution product of the densities of the two variables, say $f$ and $g$, so that   $$ h(x) = \int_{-\infty}^{\infty} f(x-y)g(y)dy. $$  However,  $$ f(y) = g(y) = \frac{1}{\sqrt {2\pi}}\exp(-y^2/2). $$  Hence now the integral becomes:  $$ h(x) =\frac{1}{2\pi}\int_{-\infty}^{\infty}\exp(-(x-y)^2/2)\exp(-y^2/2)dy. $$  However, I am puzzled here. How should we go on from here? I cannot see how to transform this integral into the integral of a normal r.v of type $N(0,2)$. Thanks in advance for your help. In class we are currently covering upper/lower bounds, big Oh and omega and the like. I am pretty good on the "typical" functions one would do, but at a complete loss at "general" statements. This ons function, for example:  $$\forall f\in\mathcal{F}: \lfloor \sqrt{\lfloor f(n)\rfloor }\rfloor \in O(\sqrt{f(n)}).$$  the domain F by the same is all natural numbers that return a real positive number when inputted. My first instinct with something like this is to remove the floors, the general strategy I though to solve this is remove the outer floor, then get rid of the square root, and then the inner floor. But I have no idea how to go about this or if this is even the right way to do it.  Help please? Thanks in advance. Is there a website that lets you shop for hotels with taxes and fees included in search results? Every time I book a hotel online, the price increases by 25% in "taxes and fees" at checkout, compared to the price featured in search results.  This does not occur when booking flights (I actually think there's a regulation against it for flights).  Is there a website that lets you compare the ACTUAL price of hotels with taxes and fees included, and also lets you book? Let $\mathbb S = \varnothing$.      Then from the definition: $ \bigcap \mathbb S = \left\{{x: \forall X \in \mathbb S: x \in X}\right\}$      Consider any $x \in \mathbb U$.      Then as $\mathbb S = \varnothing$, it follows that: $\forall X \in \mathbb S: x \in X$ from the definition of vacuous truth.      It follows directly that: $\bigcap \mathbb S = \left\{{x: x \in \mathbb U}\right\}$      That is: $\bigcap \mathbb S = \mathbb U$. ()   Proofwiki uses the above "proof" to "prove" that intersection of the empty set is the whole universe.   My question is, is the use of vacuous truth really allowed in axiomatic set theory, like ZFC? I don't see how the use of vacuous truth is justified.   The next problem I can think of is that we cannot really "define" the elements of empty set (to my knowledge, there is no element in empty set) so how can we then prove as the above proof did? This seems to contradict the use of vacuous truth.  And of course, there is issue of using the whole universe as a set, and I don't think this is allowed.... (Maybe proof above is using a different axiomatic set theory, as I am using ZF-minded thoughts...) Series convergence or divergence how to test I have the following series defined.   $$\displaystyle\sum_{k=1}^{n} \cos \left( {\frac{\pi}{2}} k \right) \frac{k}{k+1000} \frac{1}{\sqrt{k}}$$ where $n = 1,2...$  How to test whether this series converges or diverges ?