I can't seem to find the answer to my problem so here I am. I have a tree that has been filled in with strings from a file and need to count how many times a string is seen. So everything works fine except me counting the strings right. So here is the code where I attempt to count the occurrences of each string.  /* Function for postorder traversal */ public void postorder(Scanner file) {     postorder(root,file); }  private void postorder(BSTNode r,Scanner file) {     int counter = 0;     String key;     if (r != null)     {         key = file.next();         postorder(r.getLeft(),file);         postorder(r.getRight(),file);         if(key.compareTo(r.getData()) == 0)         {             counter++;         }     System.out.println(r.getData() +", " + counter);      } }   If it'll help this is the output to the console I'm getting:  McGurkus, 0  Kircus, 0 call, 0 I'll, 0 I, 0 circus, 0 it, 0 my, 0 for, 0 put, 0 tents, 0 think, 0 the, 0 up, 0 to, 0 ready, 1 All, 1   Everything is supposed to be 1. Any help or guidance to where I can derive the solution will be greatly appreciated.
First of all, I swear this is not homework, it's a question I was asked in an interview. I think I made a mess of it (though I did realise the solution requires recursion). Here is the question:  Implement the count() method which returns the number of nodes in a tree. If a node doesn't have either a left or right child, the relevant getXXChild() method will return null  class Tree {    Tree getRightChild() {     // Assume this is already implemented   }    Tree getLeftChild() {     // Assume this is already implemented   }    int count() {     // Implement me   } }   My reason for asking the question is simply curious to see the correct solution, and thereby measure how bad mine was.  Cheers, Tony
"To be subject to" vs. "to be subjected to" I read an article from  today which stated:     TTC workers are subject to alcohol and drug testing.   A later paragraph of the same article repeated it, except it used subjected to instead of subject to.  I have rarely seen the use of subjected to before. Is it legitimate in English as well? Why didn’t the author just keep it consistent by using subject to throughout the article? Does using varieties of forms enrich the expressions within an article? How to create vector graphics In Photoshop? I know people prefer using CorelDraw or Adobe Illustrator, but I want to know if there is a technique I can follow to use Adobe Photoshop to make vector Images. In my cover letter I want to write that I am a graduate student in statistics. But I am not sure about the "in". So what is correct?     I am a graduate student in statistics.      I am a graduate student of statistics. Windows 7 won't boot after installing Ubuntu 11 Fantasy/scifi combo - band of travelers who must get from "sphere" or domain to domain - each geographic area is ruled by a magician - it turns out later these are people who are unwittingly tapping into the computer grid they all live on to alter their own reality? Why do regex constructors need to be double escaped? Let's say I have code like this:  $dbh = new PDO("blahblah");  $stmt = $dbh-&gt;prepare('SELECT * FROM users where username = :username'); $stmt-&gt;execute( array(':username' =&gt; $_REQUEST['username']) );   The PDO documentation says:     The parameters to prepared statements don't need to be quoted; the driver handles it for you.   Is that truly all I need to do to avoid SQL injections?  Is it really that easy?  You can assume MySQL if it makes a difference.  Also, I'm really only curious about the use of prepared statements against SQL injection.  In this context, I don't care about XSS or other possible vulnerabilities. How to find which RAM to get for my computer? I don't have any knowledge in hardware and would like to know which RAM should I buy for my laptop.  How do I discover what RAM I need &amp; how much my machine can take?  I have a Razer Blade 15 (RZ09-02705F76) 2018 but don't know if there is a specific type or format of RAM that suits it and don't know where to find this information. Worldwide Dissertation Database? or French, German, Italian ones? Is there a global/worldwide database of dissertations? If not, how can I access French, German, Italian, etc. dissertations online? Can I use two 7805 ICs in parallel to get double current capacity? I use a 7805 for a project where the circuit needs a higher current (~2.8&nbsp;A) at 5&nbsp;V. So I assume that if I use both ICs in parallel I can increase the maximum current capacity. Would it work? Dispatcher.BeginInvoke: Cannot convert lambda to System.Delegate When are infinities okay? I'm a little confused about how to handle infinities in physics. On the one hand, I always here things like infinities are not physically tenable answers. GR can't answer anything about the origin of the universe because of singularities. Throw away the radial solution that gives an infinite potential when solving the Laplace equation in spherical coordinates. But then there are other times that the infinities are okay. For instance, it is usually okay to set the reference point for your potential at infinity. There are certain times in David Tong's quantum field theory lecture notes where he seems to almost to hand wave away infinities. So, philosophically, physically, and mathematically when are infinities okay, and when are they not okay? Disable ClearType (blurry fonts) in Internet Explorer 10 on windows 7 I've installed recently the latest Internet Explorer 10 and found out again what was my issue with the previous upgrade -- blurry fonts aka ClearType! Unfortunately there are some apps that use IE engine and thus all content there is blurry too :/  I know about  but unfortunately it seems that it is only for IE9. Is there any other solution to disable CT in IE10?  (and for clarity - I don't like CT, I've tried tweaking it but for me it's just blurry and case pain in my eyes no matter what I do... it's probably related to the low dpi of my monitor) Differentiability of $g:=f(\sqrt{x^2+y^2})$ for a $C^1$ function with $f'(0)=0$ NBHM $2008$ Let $f:\mathbb{R}\rightarrow \mathbb{R}$ be a continuously differentiable function such that $f'(0)=0$.  Define for all $x,y\in \mathbb{R}$,  $$g(x,y)=f(\sqrt{x^2+y^2})$$ Pick out the true statements :   $g$ is differentiable on $\mathbb{R}^2$ $g$ is differentiable on $\mathbb{R}^2$ if and only if $f(0)=0$ $g$ is differentiable on $\mathbb{R}^2- \{ (0,0)\}$   I do not have much idea of differentiation of multivariable calculus.  I just tried out some examples to get some idea..  I have to take some function whose derivative at $0$ has to be zero.  for simplicity I would take $f(x)=x^2$ Then I would get :     $g(x,y)=x^2+y^2$ which is differentiable on $\mathbb{R}^2$   This would suggest me that second option has more chances as $f(0)=0$ in this case.  I would now take $f(x)=x^2+1$ then :     $g(x,y)=x^2+y^2+1$ which is differentiable on $\mathbb{R}^2$ though $f(0)\neq 0$   So, I would now eliminate second option and third option also...  So, It is now got confirmed that i have to work out to "Prove" that first option is correct.  Now, I have to prove that $g(x,y)=f(\sqrt{x^2+y^2})$ is differentiable.  I have to look for partial derivatives first :  $$\frac{\partial g}{\partial x}= f'(\sqrt{x^2+y^2}).\frac{2x}{2\sqrt{x^2+y^2}}=f'(\sqrt{x^2+y^2}).\frac{x}{\sqrt{x^2+y^2}}$$  $$\frac{\partial g}{\partial y}= f'(\sqrt{x^2+y^2}).\frac{2y}{2\sqrt{x^2+y^2}}=f'(\sqrt{x^2+y^2}).\frac{y}{\sqrt{x^2+y^2}}$$  I have used here that $f$ is differentiable on $\mathbb{R}$  As $f$ is continuously differentiable, we have $f'$ is continuous and I know that :  $\frac{x}{\sqrt{x^2+y^2}}$ and $\frac{y}{\sqrt{x^2+y^2}}$ are also continuous.     As $f'$ and $\frac{x}{\sqrt{x^2+y^2}}$ are continuous So is the product $\frac{\partial g}{\partial x}=f'(\sqrt{x^2+y^2}).\frac{x}{\sqrt{x^2+y^2}}$      As $f'$ and $\frac{y}{\sqrt{x^2+y^2}}$ are continuous So is the product $\frac{\partial g}{\partial y}=f'(\sqrt{x^2+y^2}).\frac{y}{\sqrt{x^2+y^2}}$   So we have continuous partial derivatives for $g(x,y)$..  So, I am willing to conclude that:     $g(x,y)$ is  differentiable on $\mathbb{R}^2$   I would be thankful if some one can confirm if the answer correct.  I would be much more thankful if some one can let me know if there are any gaps in my argument.  This is just a proof verification Question..  Thank you. How to limit Docker total resources? I'm trying to limit the total resources accessible from docker (for example only 90% of the RAM and 1500% of the CPU). I cannot use CPU and RAM limit when I'm launching my containers, that's why I need to limit the total resources available for docker containers.  I have around 20 containers which can consume the maximum CPU and memory but not at the same time, so I cannot set the CPU and RAM limit, that's why I need to limit the total resource used by docker  First of all I've created a slice: I tried the instruction above, but impossible to limit both the RAM and the CPU usage  # /etc/systemd/system/docker_limit.slice [Unit] Description=Slice that limits docker resources Before=slices.target  [Slice] CPUAccounting=true CPUQuota=700% #Memory Management MemoryAccounting=true MemoryHigh=20G MemoryMax=25G MemoryMaxSwap=10G   And my daemon.json  {   "insecure-registries" : [ "url1", "url2"],   "cgroup-parent": "docker_limit.slice" }   But when I try from a container:  stress --vm-bytes $(awk '/MemAvailable/{printf "%d\n", $2 * 0.9;}' &lt; /proc/meminfo)k --vm-keep -m 1   I can see from docker stats it's using 111Go of Ram (full capacity of my server)  stress --cpu 16   I can see from docker stats it's using near 1600 % (full capacity of my server)  I think I've missed something but I don't know what How can I make a macOS Mojave bootable USB installer in Windows 10? Writing XML to a file without overwriting previous data Undefined reference to static class member Determine number of real roots of $f(x)=x^{5}+x^{3}-2x+1$.   I used Descartes's rule of sign to determine the number of positive and negative roots; there is only 1 negative (hence minimum 1 real root) and two positive roots. These 2 positive roots can be anything- a complex pair, or two real roots- but what about the other 2 roots? Is there any flaw in my understanding of rule of signs? How can I find the exact number of real roots?  Thanks in advance. In the category $\mathbf{Set}$ is "the product of an empty set of sets a one-element set"? I was reading  on Category Theory and it said (paraphrased to add context):     Exercise 4: Explain why in $\textbf{Set}$ (the Category of Sets), the product of an empty set of sets is a one-element set.   which I think is incorrect. The product of two empty sets (or any number) is empty because we are considering:  $$ \emptyset \times \emptyset = \{ (a,b) : a \in \emptyset, b \in \emptyset \} = \emptyset$$  where $a \in \emptyset , b \in \emptyset$ are false, so the above is the $\emptyset$ which is NOT a one element set (its a zero element set).   This should be trivial so I am assuming I am somewhere mis reading the natural language of the exercise. Someone help me catch where is it and what the answer should be? i.e. whats being asked and the answer?