<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Varun Kanade - Homepage</title>
    <description>Personal homepage of Varun Kanade, Associate Professor in the Department of Computer Science, University of Oxford. Research interests include machine learning and theoretical computer science. Tutor and Fellow at Lady Margaret Hall.
</description>
    <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/</link>
    <atom:link href="http://www.cs.ox.ac.uk/people/varun.kanade/website/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Tue, 13 Oct 2026 15:47:38 +0100</pubDate>
    <lastBuildDate>Tue, 13 Oct 2026 15:47:38 +0100</lastBuildDate>
    <generator>Jekyll v4.4.1</generator>
    
      <item>
        <title>Discussion about Interview Question 4</title>
        <description>&lt;div&gt;
	&lt;p&gt;
	We used this as the first question in CS interviews at &lt;a href=&quot;https://www.cs.ox.ac.uk/&quot;&gt;LMH&lt;/a&gt; in December 2018. The question below is from &lt;a href=&quot;/people/varun.kanade/website/post/2022/09/16/interview-question4.html&quot;&gt;this post&lt;/a&gt;.
	&lt;/p&gt;

	&lt;p&gt;&lt;b&gt;Question&lt;/b&gt;:&lt;/p&gt;
	&lt;ol&gt;
		&lt;li&gt;Consider the following ten-digit number:&lt;br&gt;
			&lt;center&gt;
				\( 7~1~0~6~4~1~9~9~0~2\).
			&lt;/center&gt;
			You should remove three of the digits so as to get the largest possible seven digit number. As a first step, you may want to try to delete two digits from the following five digit number to get the largest possible three digit number:&lt;br&gt;
			&lt;center&gt;
				\(7~1~9~3~4\).
			&lt;/center&gt;
		&lt;/li&gt;
		&lt;li&gt;Now consider the more general question when you are given an \(n\) digit number and asked to delete \(k &lt; n\) out of the \(n\) digits, so as to leave the largest possible \(n - k\) digit number. Explain your general strategy. Evaluate the number of steps requried to perform your strategy and try to minimise this number as much as you can.
		&lt;/li&gt;
	&lt;/ol&gt;

	&lt;p&gt;&lt;b&gt;Solution&lt;/b&gt;:&lt;/p&gt;
	&lt;ol&gt;
		&lt;li&gt;The answers in the two specific instances are \( 9~3~4 \) by removing the \(7 \) from the first position and the \(1 \) from the second position, and \( 7~6~4~9~9~0~2 \), by removing the \(1\) in the second position, the \(0\) in the third position and the \(1\) from the sixth position.&lt;/li&gt;
		&lt;li&gt;
			We will assume that the digits are \(0 \) to \( 9 \), though the procedure remains the same even when considering numbers represented in an arbitrary base \( b \). Here is python code that implements a correct procedure.
			&lt;pre class=&quot;prettyprint&quot;&gt;
				&lt;code class=&quot;language-py&quot;&gt;
def delete_digits(digits, k):
	n = len(digits)

	output = [0]*(n-k)

	i = 0
	deleted = 0
	max_val = max(digits) + 1  # larger than any digit
	last_output_digit = max_val
	while i &lt; n:
		if digits[i] &gt; last_output_digit and deleted &lt; k:
			deleted += 1
			if deleted == i:
				last_output_digit = max_val
			else:
				last_output_digit = output[i - deleted - 1]
		else:
			output[i - deleted] = digits[i]
			last_output_digit = digits[i]
			i += 1
	return output
				&lt;/code&gt;
			&lt;/pre&gt;
			We&apos;ll discuss below how we arrived at this procedure as well as its correctness. For now we can observe that every time we enter the &lt;tt&gt;while&lt;/tt&gt; loop, we increment exactly one of &lt;tt&gt;deleted&lt;/tt&gt; and &lt;tt&gt;i&lt;/tt&gt; by exactly \(1\). Since both are \(0\) at the start of the loop and we know that &lt;tt&gt;deleted&lt;/tt&gt; can be at most \(k \) and &lt;tt&gt;i&lt;/tt&gt; can be at most \(n \), the &lt;tt&gt;while&lt;/tt&gt; loop runs for at most \( n + k \) iterations. Since the number of operations performed in one iteration of the &lt;tt&gt;while&lt;/tt&gt; loop is at most a constant (in this case about \(10 \) comparison or assignment operations), the total running time cannot be more than linear in \(n + k \), or really just linear in \(n \) as \( k &lt; n \). 
		&lt;/li&gt;
	&lt;/ol&gt;

	&lt;p&gt;&lt;b&gt;Discussion&lt;/b&gt;: This question is relatively straightforward, but there are still a few potential pitfalls. And coming up with the algorithm above requires some thought process and insight.&lt;/p&gt;

	&lt;p&gt;First, there were a few candidates, though not many, who instinctively suggested deleting all the \(0\)&apos;s first, then all the \(1\)&apos;s and so on until we get to the correct number of digits. This is quite natural as a first thought, but obviously doesn&apos;t work as the location of the digits being deleted is as important as their value. For instance if we started with the number \(9890\) and had to remove on digit, then we are better of removing the \(8\) to get \(990\) than removing the \(0\) to get \(989\).
	&lt;/p&gt;





&lt;/div&gt;


</description>
        <pubDate>Fri, 15 Aug 2025 06:00:00 +0100</pubDate>
        <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2025/08/15/interview-question4-discussion.html</link>
        <guid isPermaLink="true">http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2025/08/15/interview-question4-discussion.html</guid>
        
        <category>oxford</category>
        
        <category>cs</category>
        
        <category>maths</category>
        
        <category>interview</category>
        
        
        <category>post</category>
        
      </item>
    
      <item>
        <title>Interview Question 6</title>
        <description>&lt;div&gt;
	Suppose \(a_1, \ldots, a_8\) are positive real numbers that add up to \( 27 \). Can you find the minimum of the following expression?

	\[ \sqrt{1^2 + a_1^2} + \sqrt{2^2 + a_2^2} + \cdots + \sqrt{8^2 + a_8^2} \]

	Can the values of \(a_i\) that minimise this expression be rational?&lt;br&gt;&lt;br&gt;

	This question was used in CS interviews at &lt;a href=&quot;https://www.lmh.ox.ac.uk/&quot;&gt;Lady Margaret Hall&lt;/a&gt; in December 2021. The question is due to &lt;a href=&quot;https://www.cs.ox.ac.uk/people/thomas.orton/&quot;&gt;Tom Orton&lt;/a&gt;.


&lt;/div&gt;
</description>
        <pubDate>Wed, 28 Jun 2023 11:30:00 +0100</pubDate>
        <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2023/06/28/interview-question6.html</link>
        <guid isPermaLink="true">http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2023/06/28/interview-question6.html</guid>
        
        <category>oxford</category>
        
        <category>cs</category>
        
        <category>maths</category>
        
        <category>interview</category>
        
        
        <category>post</category>
        
      </item>
    
      <item>
        <title>Interview Question 5</title>
        <description>&lt;div&gt;
	An &lt;i&gt;increasing tree&lt;/i&gt; is a rooted labelled tree whose labels increase along paths away from the root. For simplicity, if the tree has \(n\) vertices we will take the root to be labelled \(1\) and the other vertices to be labelled by \(2, \ldots, n\). An example is shown below.
		&lt;!--\node [vertex] (0, 0) {$1$};--&gt;
		&lt;center&gt;&lt;img src=&quot;/people/varun.kanade/website/pics/posts/increasing_tree1.png&quot; width=&quot;50%&quot;&gt;&lt;/center&gt;&lt;br&gt;&lt;br&gt;

		Note that when a node has more than one child, the order in which the children are represented is irrelevant, so that, for example, the following two trees are equivalent.&lt;br&gt;&lt;br&gt;

	&lt;center&gt;&lt;img src=&quot;/people/varun.kanade/website/pics/posts/increasing_tree2.png&quot; width=&quot;50%&quot;&gt;&lt;/center&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;

	&lt;ol&gt;
		&lt;li&gt;
			&lt;p&gt;Can you draw all the increasing trees with \(4\) vertices?&lt;/p&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;p&gt;How many increasing trees on \(n\) vertices are there?&lt;/p&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;p&gt;Suppose now that \(n\) is even. How many of these can be split by removing a single edge into a tree labelled only by odd numbers and a tree labelled only by even numbers?&lt;/p&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;p&gt;Suppose now that we want to generate an increasing tree on \(n\) vertices picked uniformly at random, i.e. pick each of the possible trees with equal probability. Can you give an algorithm to do this?&lt;/p&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;p&gt;When a random tree is picked as in the previous part, what is the average number of neighbours of the root?&lt;/p&gt;
		&lt;/li&gt;
	&lt;/ol&gt;

	This question was used in Maths &amp;amp; CS interviews at &lt;a href=&quot;https://www.lmh.ox.ac.uk/&quot;&gt;Lady Margaret Hall&lt;/a&gt; in December 2021. The question is due to &lt;a href=&quot;https://www.stats.ox.ac.uk/~goldschm/&quot;&gt;Christina Goldschmidt&lt;/a&gt;.

&lt;/div&gt;
</description>
        <pubDate>Wed, 28 Jun 2023 09:44:00 +0100</pubDate>
        <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2023/06/28/interview-question5.html</link>
        <guid isPermaLink="true">http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2023/06/28/interview-question5.html</guid>
        
        <category>oxford</category>
        
        <category>cs</category>
        
        <category>maths</category>
        
        <category>interview</category>
        
        
        <category>post</category>
        
      </item>
    
      <item>
        <title>Discussion about Interview Question 3</title>
        <description>&lt;div&gt;
	&lt;p&gt;
	We used this as the first question in the Maths &amp;amp; CS interview at &lt;a href=&quot;https://www.lmh.ox.ac.uk/&quot;&gt;LMH&lt;/a&gt; in December 2020. The question below is from &lt;a href=&quot;/people/varun.kanade/website/post/2022/09/16/interview-question3.html&quot;&gt;this post&lt;/a&gt;. The question is due to &lt;a href=&quot;https://www.stats.ox.ac.uk/~goldschm/&quot;&gt;Christina Goldschmidt&lt;/a&gt;, as is the solution and discussion presented here. 
	&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Question&lt;/b&gt;:&lt;/p&gt;

	&lt;p&gt;This question is about the function \(Z\) defined by \( \displaystyle Z(s) = \sum_{k = 1}^\infty \frac{1}{k^s}, \) for \( s &gt; 1 \).&lt;/p&gt;

	&lt;ol&gt;
		&lt;li&gt;Can you find a lower bound on this function which is valid for all \( s &gt; 1 \)?&lt;/li&gt;
		&lt;li&gt;Why have we excluded \( s = 1\) from the domain?&lt;/li&gt;
	&lt;/ol&gt;
	From now on, we will concentrate on \( Z(2) \).&lt;br&gt;&lt;br&gt;
	&lt;ol start=&quot;3&quot;&gt;
		&lt;li&gt;Can you find an upper bound on \(Z(2) \)?&lt;/li&gt;
	&lt;/ol&gt;

	In fact, \( \displaystyle Z(2) = \frac{\pi^2}{6} \), i.e., \( \displaystyle \sum_{k=1}^n \frac{1}{k^2} \rightarrow \frac{\pi^2}{6} \) as \( n \rightarrow \infty \).&lt;br&gt;&lt;br&gt;
	&lt;ol start=&quot;4&quot;&gt;
		&lt;li&gt;One proof of this fact relies on the inequalities
			&lt;center&gt;
				\( \sin \theta &lt; \theta &lt; \tan \theta,~~~~\)for \(\theta \in (0, \pi/2)\).
			&lt;/center&gt;
			Can you show why this is true geometrically?
		&lt;/li&gt;
		&lt;li&gt;Can you use this to get upper and lower bounds on \(1/\theta^2\) in terms only of \(\tan \theta\)?
		&lt;/li&gt;
		&lt;li&gt;
			Now let \( \theta_k = \frac{k \pi}{2 n + 1} \) for \(1 \leq k \leq n \). Find upper and lower bounds on
			\[ \sum_{k=1}^n \frac{1}{k^2}. \]
		&lt;/li&gt;
		&lt;li&gt;It turns out that the numbers 
			\[ r_k = \frac{1}{\tan^2 \left( \frac{\pi k}{2n + 1 } \right) }, ~~ 1 \leq k \leq n, \]
			are roots of the polynomial
			\[ p_n(x) = { 2n + 1 \choose 1} x^n - {2n + 1 \choose 3} x^{n-1} + \cdots +  (-1)^n {2n + 1 \choose 2n + 1}. \]
			Can you use this to show that
			&lt;center&gt;
				\( \displaystyle \sum_{k=1}^n \frac{1}{k^2} \rightarrow \frac{\pi^2}{6} \) as \( n \rightarrow \infty \)?
			&lt;/center&gt;
	&lt;/ol&gt;

	&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;

	&lt;ol&gt;
		&lt;li&gt; The first term in the sum is \(1\) and the others are all strictly positive, so \(Z(s) \gt 1\) for all \(s \gt 1\).&lt;/li&gt;
		&lt;li&gt;
			&lt;p&gt;Because the sum in that case is infinite. Note that the sum of the first \(n\) terms is the \(n\)th harmonic number \(H_n\) and \(H_n \sim \log n\) as \(n \) gets large. Since \(\log n \rightarrow \infty \) as \( n \rightarrow \infty\), we have \(H_n \rightarrow \infty\). &lt;/p&gt;

			&lt;p&gt;In order to prove this, note that

			\[ \sum_{k=1}^n \frac{1}{k} \geq \int_{1}^{n+1} \frac{1}{x} dx = \log(n + 1). \]
			&lt;/p&gt;

			&lt;p&gt;Alternatively,
			\begin{align*}
			&amp;1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \frac{1}{5} + \frac{1}{6} + \frac{1}{7} + \frac{1}{8} + \cdots\\
			\geq&amp; 1 + \frac{1}{2} + \underbrace{\frac{1}{4} + \frac{1}{4}}_{2} + \underbrace{\frac{1}{8} + \frac{1}{8} + \frac{1}{8} + \frac{1}{8}}_{4} + \underbrace{\frac{1}{16} + \cdots + \frac{1}{16}}_{8} + \cdots \\
			=&amp;1 + \frac{1}{2} + \frac{1}{2} + \frac{1}{2} + \cdots = \infty.
			\end{align*}
		&lt;/li&gt;
		&lt;li&gt;\(Z(2) \leq 2\). In order to see this, note that
			\[ \sum_{k=1}^\infty \frac{1}{k^2} \leq 1 + \sum_{k=2}^\infty \frac{1}{k (k-1)} = 1 + \sum_{k=2}^\infty \left( \frac{1}{k-1} - \frac{1}{k} \right) = 2,\]
			since the sum telescopes. Alternatively,
			\begin{align*}
			&amp;1 + \underbrace{\frac{1}{2^2} + \frac{1}{3^2}}_{} + \underbrace{\frac{1}{4^2} + \frac{1}{5^2} + \frac{1}{6^2} + \frac{1}{7^2}}_{} + \frac{1}{8^2} + \cdots\\
			\leq&amp; 1 + \underbrace{\frac{1}{2^2} + \frac{1}{2^2}}_{2} + \underbrace{\frac{1}{4^2} + \frac{1}{4^2} + \frac{1}{4^2} + \frac{1}{4^2}}_{4} + \underbrace{\frac{1}{8^2} + \cdots + \frac{1}{8^2}}_{8} + \cdots \\
			=&amp;1 + \frac{1}{2} + \frac{1}{2^2} + \frac{1}{2^3} + \cdots = 2.
			\end{align*}
			Or
			\[ \sum_{k=1}^n \frac{1}{k^2} \leq 1 + \int_{1}^n \frac{1}{x^2} dx = 2 - \frac{1}{n} \rightarrow 2 \]
			as \( n \rightarrow \infty\).
		&lt;/li&gt;

		&lt;li&gt;&lt;p&gt;Consider a unit circle and a sector of angle \(\theta \in (0, \pi/2)\).&lt;/p&gt;

			&lt;center&gt;&lt;img src=&quot;/people/varun.kanade/website/pics/posts/trig.png&quot; width=&quot;60%&quot;&gt;&lt;/center&gt;

			&lt;p&gt;The area of the grey inner triangle is \(\frac{1}{2} \sin \theta \). The sector of the circle of angle \(\theta\) has area \(\theta/2\). The area of the outer right-angled triangle is \(\frac{1}{2} \tan \theta\). Since each of these contain the previous one, the claimed inequalities follow.&lt;/p&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;p&gt; We have

			\[ \frac{1}{\tan^2\theta} \lt \frac{1}{\theta^2} \lt \frac{1}{\sin^2 \theta} = \frac{\sin^2 \theta + \cos^2 \theta}{\sin^2 \theta} = 1 + \frac{1}{\tan^2\theta}. \]
			&lt;/p&gt;
		&lt;/li&gt;
		&lt;li&gt;
			We have 
			\[ \sum_{k=1}^n \frac{1}{k^2} = \frac{\pi^2}{(2n + 1)^2} \sum_{k=1}^n \frac{1}{\theta_k^2}\]
			and so 
			\begin{align*}
			\frac{\pi^2}{(2n + 1)^2} \sum_{k=1}^n \frac{1}{\tan^2 \theta_k} \lt \sum_{k=1}^n \frac{1}{k^2} &amp;\lt \frac{\pi^2}{(2n + 1)^2}\sum_{k=1}^n \left(\frac{1}{\tan^2\theta_k} + 1 \right) \\
			&amp;= \frac{\pi^2}{(2n + 1)^2} \sum_{k=1}^n \frac{1}{\tan^2\theta_k} + \frac{n \pi^2}{(2n + 1)^2}.
			\end{align*}
		&lt;/li&gt;
		&lt;li&gt; Since \( (r_k)_{1 \leq k \leq n} \) are the roots of the polynomial, we have 
			\[ \sum_{k=1}^n r_k = \frac{2n+1 \choose 3}{2n+1 \choose 1} = \frac{(2n+1)(2n)(2n-1)}{6(2n+1)} = \frac{2n(2n-1)}{6}.\] 
			So 
			\[ \frac{\pi^2}{(2n+1)^2} \sum_{k=1}^n r_k = \frac{2n(2n-1)\pi^2}{6 (2n + 1)^2} \rightarrow \frac{\pi^2}{6} \]
			as \( n \rightarrow \infty\). Since
			\[ \frac{n \pi^2}{(2n + 1)^2} \rightarrow 0, \]
			it follows that \(\sum_{k=1}^n \frac{1}{k^2} \) is boudned above and below by quantities which tend to \(\pi^2/6\) and the result follows.
		&lt;/li&gt;
	&lt;/ol&gt;

	&lt;p&gt;&lt;b&gt;Comments&lt;/b&gt;&lt;/p&gt;

	&lt;p&gt;What we have called \(Z(s) \) in this problem is of course the famous &lt;a href=&quot;https://en.wikipedia.org/wiki/Riemann_zeta_function&quot;&gt;Riemann zeta function&lt;/a&gt;, \( \zeta(s) \). The calculation of \( Z(2) \) is known as the &lt;a href=&quot;https://en.wikipedia.org/wiki/Basel_problem&quot;&gt;&lt;i&gt;Basel problem&lt;/i&gt;&lt;/a&gt;. Euler first gave a non-rigorous argument in 1735. This question is based on Cauchy&apos;s (rigorous!) proof from 1821.

	&lt;ol&gt;
		&lt;li&gt;We were expecting \(Z(s) \gt 1\) to be straightforward; it usually wasn&apos;t, and often required quite a lot of discussion.&lt;/li&gt;
		&lt;li&gt;Quite often people recognised the harmonic series. Some knew that \( H_n \sim \log n\); others didn&apos;t. We often spent the bulk of time deriving a proof of this.&lt;/li&gt;
		&lt;li&gt;We skipped Part 3 if the previous part had taken too long in order to give candidates a chance at something else. &lt;/li&gt;
		&lt;li&gt;We rarely got beyond the fourth part on this question.&lt;/li&gt;
	&lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Sun, 04 Dec 2022 20:21:01 +0000</pubDate>
        <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/12/04/interview-question3-discussion.html</link>
        <guid isPermaLink="true">http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/12/04/interview-question3-discussion.html</guid>
        
        <category>oxford</category>
        
        <category>cs</category>
        
        <category>maths</category>
        
        <category>interview</category>
        
        
        <category>post</category>
        
      </item>
    
      <item>
        <title>Discussion about Interview Question 2</title>
        <description>&lt;div&gt;
	&lt;p&gt;
	We used this as the first question in the CS interview at &lt;a href=&quot;https://www.lmh.ox.ac.uk/&quot;&gt;LMH&lt;/a&gt; in December 2019. The question below is from &lt;a href=&quot;/people/varun.kanade/website/post/2022/06/29/interview-question2.html&quot;&gt;this post&lt;/a&gt;.
	&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Question&lt;/b&gt;: 
	&lt;ol&gt;
		&lt;li&gt;Find the smallest natural number ending in \(6\), such that if the last \(6\) is removed and placed in the front, the new number is \(4\) times the original number.&lt;/li&gt;
		&lt;li&gt;Can you give a procedure to find the smallest number ending in digit \(d\), where \(d\) is between \(1\) and \(9\), such that if the last digit, \(d\), is removed and placed in front, you get a number that is \(k\) times as large? Is this possible for every value of \(d\) and \(k\)?
	&lt;/ol&gt;
	&lt;/p&gt;

	&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt; 	
	&lt;ol&gt;
		&lt;li&gt;
			&lt;p&gt;The answer is 153846.&lt;/p&gt;

			&lt;p&gt;Here&apos;s one way to arrive at it. We can start by doing long multiplication, where we multiply \(X\cdots X6\) by \(4\). We don&apos;t know how many digits there are or what they are, but we can at least multiply \(6\) by \(4\). We know that this yields the digit \(4\) and carry \(2\).&lt;/p&gt;
			&lt;center&gt;
				&lt;table&gt;
					&lt;tr&gt;
						&lt;td align=right&gt; \(X \cdots X^{(2)} 6\) &lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;td align=right style=&quot;border-bottom: 1px solid black;&quot;&gt; \(\times 4\)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;td align=right&gt; \(Y \cdots Y 4 \)&lt;/td&gt;
					&lt;/tr&gt;
				&lt;/table&gt;
			&lt;/center&gt;

			&lt;p&gt;As we know that removing the trailing \(6\) and putting it at front yields a number \(4\) times as big, the above operation tells us that the digit just before the \(6\) must have been \(4\). This allows us to continue the long multiplication, \(4 \times 4 + 2\) is \(18 \) which yields the digit \(8\) and carry \(1\).&lt;/p&gt;
			&lt;center&gt;
				&lt;table&gt;
					&lt;tr&gt;
						&lt;td align=right&gt; \(X \cdots X^{(1)} 4^{(2)} 6\) &lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;td align=right style=&quot;border-bottom: 1px solid black;&quot;&gt; \(\times 4\)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;td align=right&gt; \(Y \cdots 8 4 \)&lt;/td&gt;
					&lt;/tr&gt;
				&lt;/table&gt;
			&lt;/center&gt;

			&lt;p&gt;Continuing this way, and stopping as soon as we get the digit \(6\) and carry \(0\), we obtain,&lt;/p&gt;
			&lt;center&gt;
				&lt;table&gt;
					&lt;tr&gt;
						&lt;td align=right&gt; \(1^{(2)} 5^{(1)} 3^{(3)} 8^{(1)} 4^{(2)} 6\) &lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;td align=right style=&quot;border-bottom: 1px solid black;&quot;&gt; \(\times 4\)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;td align=right&gt; \(6 1 5 3 8 4 \)&lt;/td&gt;
					&lt;/tr&gt;
				&lt;/table&gt;
			&lt;/center&gt;

			&lt;p&gt;We could of course continue and find other such numbers, but the question asked us to find the smallest such number, so we will stop here.&lt;/p&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;p&gt;First, we observe that if \(d \lt k \), then it is not possible, at least not if we don&apos;t allow the leading digit to be \(0\). This is because even if a number starts with \(1\), after multiplying it by \(k\), if the number of digits in the new number has not increased, the first digit in the new number is at least \(k\). We do know that the number of digits after multiplying by \(k\) remains unchanged as we are told that the new number is simply obtained by moving the \(d\) from the end to the beginning. So if \(d \lt k\) this is not possible. We shall now show that whenever \(d \geq k\), we can always find a solution.&lt;/p&gt;

			&lt;p&gt;We will follow the same strategy as we used in the special case above. Let us consider what happens when we have to multiply some digit \(d_1\) by \(k\); let us also assume that we may already have a carry \(c_1\) (from the previous multiplication). We get the number \(d_1 k + c_1 \). If \(d_1 k + c_1 \geq 10\), we need to break this into a digit \(d_2\) and a carry \(c_2\). Let us make a few observations.&lt;/p&gt;
			&lt;ol type=&quot;a&quot;&gt;
				&lt;li&gt; \(d_1 k + c_1 \lt 10k \) provided \(c_1 \lt k\). This follows as \(d_1\) is a digit between \(0, \ldots, 9\), so \(d_1 k \leq 9k \), and also we have that \( c_1 \lt k\). &lt;/li&gt;
				&lt;li&gt; Hence, we can write \( d_1 k + c_1 = 10 \cdot c_2  + d_2 \), where \(d_2\) is a digit between \(0, \ldots, 9\), and we also have that \(c_2 \lt k\). (If \(c_2 \geq k\), then \(10 \cdot c_2 + d_2 \geq 10k\), but as \(10 \cdot c_2 + d_2 = d_1 k + c_1\), and  \(d_1 k + c_1 \lt 10k\), that can&apos;t happen.)&lt;/li&gt;
				&lt;li&gt; The most critical observation (which I didn&apos;t expect any candidate to make) is that under the condition that \(d_1, d_2\) are digits between \(0, \ldots, 9\) and that \(c_1 \lt k\) and \(c_2 \lt k\), this process is entirely reversible. That starting with \((d_2, c_2)\) where \(c_2 \lt k\), there is a unique pair \((d_1, c_1)\) with \(c_1 \lt k\) satisfying \( d_1 k + c_1 = 10 c_2 + d_2 \). In fact, \(d_1\) is the quotiend when \(10 c_2 + d_2 \) is divided by \(k\) and \(c_1\) is the remainder.&lt;/li&gt;
			&lt;/ol&gt;

			&lt;p&gt;Now let us repeat the algorithm that we had from the previous part. We start with the &lt;i&gt;digit&lt;/i&gt; \(d\) and &lt;i&gt;multiplier&lt;/i&gt; \(k\). We begin with \((d_0 = d, c_0 = 0)\) and perform long multiplication. Starting with \((d_i, c_i)\) we get a \((d_{i+1}, c_{i+1})\) as indicated by Observation (b) above. Since each \(d_i\) takes values in \(0, \ldots, 9\) and each \(c_i\) takes values in \(0, \ldots, k-1\), there are at most \(10k\) such pairs. Thus, the sequence has to eventually repeat. By the reversibility from Observation (c), we know that the first repetition must yield \((d, 0)\), so we have obtained the smallest number we were looking for.&lt;/p&gt;
	&lt;/ol&gt;

	&lt;p&gt;&lt;b&gt;Remark:&lt;/b&gt; While this was certainly not expected during interviews, we can quickly check that provided \(d \geq k \), the reversibility ensures that in order to get to \((d_0 = d, c_0 = 0 )\), we must have started from \(d_{-1} = q, c_{-1} = r)\), where \( 10 \cdot 0 + d = q \cdot k + r \). The fact that \(d \geq k\) ensures that \(q \geq 1\), so the leading digit of the number we are looking for is at least \(1\).&lt;/p&gt;

	&lt;p&gt;This also gives us a way of writing the number from left to right, rather than right to left. Let&apos;s see how this works out with the specific example above with \(d = 6 \) and \(k = 4\), the first digit must be given by looking for \(q, r\) satisfying \(10 \cdot 0 + 6 = 4 q + r\), so we get that the first digit must be \(1 \) and the corresponding carry is \(2\). Then, we are looking for \(q, r\) that satisfy, \(2 \cdot 10 + 1 = 4 q + r \), we get the next digit must be \(5 \) and carry is \(1\); then looking for \(1 \cdot 10 + 5 = 4 q + r\), gives digit \(3\) and carry \(3\), looking for \(3 \cdot 10 + 3 = 4q + r\) gives digit \(8\) and carry \(1\), looking for \(1 \cdot 10 + 8 = 4 q + r\) gives digit \(4 \) and carry \(2\), and finally looking for \( 2 \cdot 10 + 4 = 4 q + r \) gives digit \(6 \) and carry \(0\), when we can stop. The number is \(153846\). 
	&lt;/p&gt;


	&lt;h4&gt;Discussion&lt;/h4&gt;

	&lt;p&gt;As can be seen from the solution to the second part of the question, getting the correct answer was quite involved and led to lots of interesting discussions in the interview. This kind of interaction between tutor and student is an integral part of tutorials at Oxford, and this is why we design interview questions that can lead to such discussions, to see how you would perform in tutorials.&lt;/p&gt;

	&lt;p&gt;The main purpose of this question was to get candidates to think algorithmically and then reason mathematically about the algorithmic approach. As can be seen in the solution above, there are certain aspects of the argument that are quite subtle and we were not expecting candidates to present such a detailed argument, certainly not without help from the interviewers. What we were hoping is that candidates would see that they can at least &lt;i&gt;start&lt;/i&gt; doing long multiplication and that that reveals the digits of the number one by one starting from the right. We were also hoping that, perhaps with a bit of help in some cases, candidates would see that given a digit and carry, the next digit and carry is uniquely defined, and since the number of digit-carry pairs can be at most \(100\), at some point of time the process must repeat. Stopping at the first repetition gives the desired smallest number, though as you can see the argument of correctness is a bit subtle.&lt;/p&gt;

	&lt;p&gt;What was more interesting is that some candidates started approaching the problem purely mathematically. Let&apos;s see this approach for the specific example first. Let \(l\) be the number of digits in the target number. We can write the unknown number as \( 10 x + 6 \), as we know that the last digit is \(6\). Then we have the following equality:&lt;/p&gt;

	\[ 4 (10 x + 6 ) = 6 \cdot 10^l + x.  \]

	&lt;p&gt;This is a single equation in two unknowns \(x, l\), both of which have to be positive integers. We do also have the additional information that we are looking for the smallest possible \(l\) that satisfies the equation for some \(x \), since we are looking for the smallest such number. We can rearrange the above equation to get&lt;/p&gt;

	\begin{align*}
		4 (10 x + 6 ) &amp;= 6 \cdot 10^l + x  \\
		39 x + 24 &amp;= 6 \cdot 10^l \\
		13 x + 8 &amp;= 2 \cdot 10^l \\
		13 x &amp;= 2 (10^l - 4).
	\end{align*}

	&lt;p&gt;At this point, we may try to find the smallest value of \(l\) that satisfies the above equation. In order to satisfy the equation we need that \(13 | 10^l - 4\), or alternatively, we want \( 10^l \equiv 4~(\mathrm{mod}~13)\). You could check the following relatively easily, especially if you&apos;ve seen some &lt;a href=&quot;https://en.wikipedia.org/wiki/Modular_arithmetic&quot;&gt;modular arithmetic&lt;/a&gt;.&lt;/p&gt;
	\begin{align*}
	&amp;10^1 \equiv 10 ~(\mathrm{mod}~13) &amp;10^2 \equiv 9 ~(\mathrm{mod}~13) \\
	&amp;10^3 \equiv 12 ~(\mathrm{mod}~13) &amp;10^4 \equiv 3 ~(\mathrm{mod}~13) \\
	&amp;10^5 \equiv 4 ~(\mathrm{mod}~13) &amp;10^6 \equiv 1 ~(\mathrm{mod}~13)
	\end{align*}

	&lt;p&gt;This gives us \(l = 5\) as a solution, as \(10^5 - 4\) is divisible by 13. We can then solve for \(x\) as:&lt;/p&gt;
	\begin{align*}
		13 x &amp;= 2 (10^5 - 4) \\
		x &amp;= 2 \cdot 99996 / 13 \\ 
		x &amp;= 2 \cdot 7692 = 15384.
	\end{align*}

	&lt;p&gt;This gives us the solution \(153846\) as desired. This was a solution that I didn&apos;t have in mind when we started interviewing, so it was interesting to see some of these solutions in interviews! One could try this approach in general, but here&apos;s an observation: we had \( 10^6 \equiv 1 ~(\mathrm{mod}~13)\), so if we hadn&apos;t found a solution with \(l = 1, 2, 3, 4, 5, 6\), we would not have found a solution at all, as \(l = 6 + i\) would behave exactly the same as \(l = i\). The general problem gives rise to the following equation:&lt;/p&gt;

	\begin{align}
	k \cdot (10x + d) &amp;= 10^l d + x, 
	\end{align}
	&lt;p&gt;and so,&lt;/p&gt;
	\begin{align}
	(10k - 1) x &amp;= d (10^l - k).
	\end{align}

	&lt;p&gt;Now we know that the algorithmic solution implies that this equation should always have a solution for \(x, l\), whenever \(d \geq k\), but can one argue this from this equation alone? I haven&apos;t quite figured out how do to that, so if anyone has an argument that can directly show that this equation always has a solution, I&apos;d be very keen to receive it by email or in comments below.&lt;/p&gt;
&lt;/div&gt;
</description>
        <pubDate>Sun, 04 Dec 2022 18:49:01 +0000</pubDate>
        <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/12/04/interview-question2-discussion.html</link>
        <guid isPermaLink="true">http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/12/04/interview-question2-discussion.html</guid>
        
        <category>oxford</category>
        
        <category>cs</category>
        
        <category>maths</category>
        
        <category>interview</category>
        
        
        <category>post</category>
        
      </item>
    
      <item>
        <title>Interview Question 4</title>
        <description>&lt;div&gt;
	&lt;ol&gt;
		&lt;li&gt;Consider the following ten-digit number:&lt;br&gt;
			&lt;center&gt;
				\( 7~1~0~6~4~1~9~9~0~2\).
			&lt;/center&gt;
			You should remove three of the digits so as to get the largest possible seven digit number. As a first step, you may want to try to delete two digits from the following five digit number to get the largest possible three digit number:&lt;br&gt;
			&lt;center&gt;
				\(7~1~9~3~4\).
			&lt;/center&gt;
		&lt;/li&gt;
		&lt;li&gt;Now consider the more general question when you are given an \(n\) digit number and asked to delete \(k &lt; n\) out of the \(n\) digits, so as to leave the largest possible \(n - k\) digit number. Explain your general strategy. Evaluate the number of steps requried to perform your strategy and try to minimise this number as much as you can.
		&lt;/li&gt;
	&lt;/ol&gt;

	This question was used in CS interviews at &lt;a href=&quot;https://www.lmh.ox.ac.uk/&quot;&gt;Lady Margaret Hall&lt;/a&gt; in December 2018. 
&lt;/div&gt;
</description>
        <pubDate>Fri, 16 Sep 2022 15:00:00 +0100</pubDate>
        <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/09/16/interview-question4.html</link>
        <guid isPermaLink="true">http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/09/16/interview-question4.html</guid>
        
        <category>oxford</category>
        
        <category>cs</category>
        
        <category>maths</category>
        
        <category>interview</category>
        
        
        <category>post</category>
        
      </item>
    
      <item>
        <title>Interview Question 3</title>
        <description>&lt;div&gt;
	This question is about the function \(Z\) defined by \( \displaystyle Z(s) = \sum_{k = 1}^\infty \frac{1}{k^s}, \) for \( s &gt; 1 \).&lt;br&gt;&lt;br&gt;

	&lt;ol&gt;
		&lt;li&gt;Can you find a lower bound on this function which is valid for all \( s &gt; 1 \)?&lt;/li&gt;
		&lt;li&gt;Why have we excluded \( s = 1\) from the domain?&lt;/li&gt;
	&lt;/ol&gt;
	From now on, we will concentrate on \( Z(2) \).&lt;br&gt;&lt;br&gt;
	&lt;ol start=&quot;3&quot;&gt;
		&lt;li&gt;Can you find an upper bound on \(Z(2) \)?&lt;/li&gt;
	&lt;/ol&gt;

	In fact, \( \displaystyle Z(2) = \frac{\pi^2}{6} \), i.e., \( \displaystyle \sum_{k=1}^n \frac{1}{k^2} \rightarrow \frac{\pi^2}{6} \) as \( n \rightarrow \infty \).&lt;br&gt;&lt;br&gt;
	&lt;ol start=&quot;4&quot;&gt;
		&lt;li&gt;One proof of this fact relies on the inequalities
			&lt;center&gt;
				\( \sin \theta &lt; \theta &lt; \tan \theta,~~~~\)for \(\theta \in (0, \pi/2)\).
			&lt;/center&gt;
			Can you show why this is true geometrically?
		&lt;/li&gt;
		&lt;li&gt;Can you use this to get upper and lower bounds on \(1/\theta^2\) in terms only of \(\tan \theta\)?
		&lt;/li&gt;
		&lt;li&gt;
			Now let \( \theta_k = \frac{k \pi}{2 n + 1} \) for \(1 \leq k \leq n \). Find upper and lower bounds on
			\[ \sum_{k=1}^n \frac{1}{k^2}. \]
		&lt;/li&gt;
		&lt;li&gt;It turns out that the numbers 
			\[ r_k = \frac{1}{\tan^2 \left( \frac{\pi k}{2n + 1 } \right) }, ~~ 1 \leq k \leq n, \]
			are roots of the polynomial
			\[ p_n(x) = { 2n + 1 \choose 1} x^n - {2n + 1 \choose 3} x^{n-1} + \cdots +  (-1)^n {2n + 1 \choose 2n + 1}. \]
			Can you use this to show that
			&lt;center&gt;
				\( \displaystyle \sum_{k=1}^n \frac{1}{k^2} \rightarrow \frac{\pi^2}{6} \) as \( n \rightarrow \infty \)?
			&lt;/center&gt;
	&lt;/ol&gt;

	This question was used in Maths &amp;amp; CS interviews at &lt;a href=&quot;https://www.lmh.ox.ac.uk/&quot;&gt;Lady Margaret Hall&lt;/a&gt; in December 2020. The question is due to &lt;a href=&quot;https://www.stats.ox.ac.uk/~goldschm/&quot;&gt;Christina Goldschmidt&lt;/a&gt;.
&lt;/div&gt;
</description>
        <pubDate>Fri, 16 Sep 2022 09:00:00 +0100</pubDate>
        <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/09/16/interview-question3.html</link>
        <guid isPermaLink="true">http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/09/16/interview-question3.html</guid>
        
        <category>oxford</category>
        
        <category>cs</category>
        
        <category>maths</category>
        
        <category>interview</category>
        
        
        <category>post</category>
        
      </item>
    
      <item>
        <title>Discussion about Interview Question 1</title>
        <description>&lt;div&gt;
	&lt;p&gt;
	As this was the second question that we used in the CS interview at &lt;a href=&quot;https://www.lmh.ox.ac.uk/&quot;&gt;LMH&lt;/a&gt; in December 2018, it was chosen to be a shorter question. Nevertheless, as the discussion below suggests, there was plenty of opportunity to have an interesting conversation about it. The question below is from &lt;a href=&quot;/people/varun.kanade/website/post/2022/06/29/interview-question1.html&quot;&gt;this post&lt;/a&gt;.
	&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Question&lt;/b&gt;: For a non-negative real number \(x\), the floor of \(x\), denoted by \( \lfloor x \rfloor\) is the largest integer that is less than or equal to \(x\). For example, \(\lfloor 3 \rfloor = 3 \) and \( \lfloor 6.999 \rfloor = 6 \). 
	&lt;ol&gt;
		&lt;li&gt;Let \(n\) be a positive natural number that is a perfect square. You are asked to pick a set of \( \left\lfloor \frac{n}{2} \right\rfloor \) natural numbers from \( 1,2, \ldots,n -1 \), such that none of the chosen numbers is a perfect square, and no two &lt;i&gt;distinct&lt;/i&gt; chosen elements add up to \(n \). For what values of \(n\) is this possible?&lt;/li&gt;
		&lt;li&gt;Let \(n\) be a positive natural number that is a perfect cube. You are asked to pick a set of \( \left\lfloor \frac{n}{2} \right\rfloor \) natural numbers from  \( 1,2, \ldots,n -1 \), such that none of the chosen numbers is a perfect cube, and no two &lt;i&gt;distinct&lt;/i&gt; chosen elements add up to \(n\). For what values of \(n\) is this possible?&lt;/li&gt;
	&lt;/ol&gt;
	&lt;/p&gt;

	&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt; We pair the numbers from \(1, 2, \ldots, n - 1, \) as, 
	\[ (1, n - 1), (2, n - 2) , \ldots, \left(\left\lfloor \frac{n}{2} \right\rfloor, \left\lceil \frac{n}{2} \right\rceil \right). \]
	
	Observe that depending on whether \(n\) is odd or even, the last pair is either \( ((n - 1)/2, (n + 1)/2) \), or \( ( n/2, n/2) \). 

	&lt;br&gt;&lt;br&gt;We notice that there are exactly \( \left\lfloor \frac{n}{2} \right\rfloor \) pairs and we can&apos;t pick both numbers from a pair to be in our target set \(S\) as they would add up to \(n\). 

	&lt;br&gt;&lt;br&gt;Now for the first part, it would pose no problem unless both numbers in a pair were perfect squares, as in that case we would be prevented from putting either of those in \(S\). Can this happen? Recall that \(n\) itself is a perfect square so let us write \(n = c^2 \). Suppose one of the pairs was \( (a^2, b^2) \), then we have 
	\[ a^2 + b^2 = c^2. \]
	This happens when \((a, b, c) \) is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Pythagorean_triple&quot;&gt;Pythagorean triple&lt;/a&gt;. So, we can conclude that (for the first part) the task of picking such a set \(S \) is possible for all \(n\) that are perfect squares, provided \( \sqrt{n} \) is not the largest number of a Pythagorean triple.

	&lt;br&gt;&lt;br&gt;The second part is very similar. Let us write \(n = c^3 \). The problem arises if there is a pair of the form \( (a^3, b^3) \), and it holds that,
	\[ a^3 + b^3 = c^3. \]
	&lt;a href=&quot;https://en.wikipedia.org/wiki/Fermat%27s_Last_Theorem&quot;&gt;Fermat&apos;s Last Theorem&lt;/a&gt; states that no such numbers \(a, b, c \) exist. So in fact, it is possible to do the task for all \(n \) that are perfect cubes.

	&lt;h4&gt;Discussion&lt;/h4&gt;

	&lt;p&gt;Although the solution is short and elegant, you can see that the problem
	requires a mix of combinatorics and number theory. This is quite typical of
	questions that you can expect in interviews or on the MAT. We want to see how
	you make connections between different areas of mathematics that you may
	have learnt, without being explicitly prompted to do so.&lt;/p&gt;

	&lt;p&gt;At this point I should say very clearly that we don&apos;t actually care
	about whether you know what Pythagorean triples are, or if you have heard of
	Fermat&apos;s Last Theorem. It is likely that most students we are interviewing
	know the former and have at least heard of the latter, but that is not the
	point of the question. What we are mainly looking for is your ability to
	find ways to attack an unseen problem and make logical arguments.&lt;/p&gt;

	&lt;p&gt;In a typical interview, it would be quite common for candidates to begin
	by considering small values of \(n \). The idea of trying out small cases
	before trying to answer any question in generality is an important one in
	mathematics, and if it seems to me that you are not already acquainted with
	it, I would, very soon in the interview, make that suggestion.&lt;/p&gt;

	&lt;p&gt;When \( n = 1\), there is nothing to do. The next number to try is \( n = 4 \); we need to pick \(2 \) elements. We might begin by crossing out numbers that we cannot pick as they are perfect squares, and circle the ones that we can pick. This immediately yields the solution \(S = \{2, 3 \} \).&lt;/p&gt;

	\[ \require{enclose} \enclose{updiagonalstrike}{1}, \enclose{circle}{2}, \enclose{circle}{3} \]

	&lt;p&gt;For \( n = 9 \), we can start the same way, we write all the numbers, \(1, 2, \ldots, 8 \), and cross out the perfect squares. 
	\[ \enclose{updiagonalstrike}{1}, ~ 2, ~ 3,\enclose{updiagonalstrike}{4}, ~ 5, ~ 6, ~ 7, ~ 8 \]

	We might start picking the numbers left to right, circling them and striking out any number ruled out after picking one, e.g. picking \(2 \) rules out \(7\), and so on. We are left with, 
	\[ \enclose{updiagonalstrike}{1}, \enclose{circle}{2}, \enclose{circle}{3}, \enclose{updiagonalstrike}{4}, \enclose{circle}{5}, \enclose{horizontalstrike}{6}, \enclose{horizontalstrike}{7},\enclose{circle}{8}. \]

	So we have the \(4 \) element set \(S = \{2, 3, 5, 8 \} \), which is exactly of the required size. This suggest an &lt;b&gt;&lt;i&gt;algorithm&lt;/i&gt;&lt;/b&gt;: we can first strike out all the perfect squares from \(1, 2, \ldots, n - 1\) (using a diagonal strike, e.g. \( \enclose{updiagonalstrike}{1} \)), then start picking from left to write and striking out (horizontally, so for \(n = 9 \), after picking \(2 \), we can rule out \( 7\) as \( \enclose{horizontalstrike}{7} \)) any number that is ruled out after we have made some choices. This worked in the case of \( n = 9 \). We can see below that it also works for \( n = 16 \). 

	\[ \require{enclose} \enclose{updiagonalstrike}{1}, \enclose{circle}{2}, \enclose{circle}{3}, \enclose{updiagonalstrike}{4}, \enclose{circle}{5}, \enclose{circle}{6}, \enclose{circle}{7}, \enclose{circle}{8}, \enclose{updiagonalstrike}{9}, \enclose{horizontalstrike}{10}, \enclose{horizontalstrike}{11}, \enclose{circle}{12}, \enclose{horizontalstrike}{13}, \enclose{horizontalstrike}{14}, \enclose{circle}{15} \]

	&lt;p&gt;&lt;b&gt;Detour&lt;/b&gt;: At least in good interviews, it was quite common to get to
	this stage, but then when probed to think whether the algorithm would always
	work, students would start using ideas like &lt;i&gt;always pick numbers less than
	\( n/2 \) first&lt;/i&gt; so that no two of them would add up to \(n \). (Indeed,
alternatively one could pick numbers that are great than \( n/2 \).) From the
examples above, it is clear that always picking numbers on one side of \( n /2
\) doesn&apos;t work in general, because after crossing out perfect squares, there
aren&apos;t enough of them left. The algorithm above, which goes left to right
essentially picks as many numbers less than or equal to \( n /2 \) as it can,
and then tries to make up for the missing ones by picking numbers that are greater than
\( n/2 \). When probed whether this is always possible, some students jumped to
the clean solution given above that involves pairing numbers that add up to \(n
\), and at that point, realised the connection between Pythagorean triples and the
question. Others, including some who got offers at Oxford, may have needed to
work out the case of \(n = 25 \) in full detail. Luckily, while somewhat
tedious, it is still just about possible to write all the numbers from \( 1\)
to \(24 \) and then work out the details. 

	&lt;p&gt;&lt;b&gt;Back to the Discussion&lt;/b&gt;: Let us see what happens when \( n = 25 \). We can run the procedure described above to get, 
	\[ 
		\enclose{updiagonalstrike}{1}, \enclose{circle}{2}, \enclose{circle}{3}, 
		\enclose{updiagonalstrike}{4}, \enclose{circle}{5}, \enclose{circle}{6},
		\enclose{circle}{7}, \enclose{circle}{8}, \enclose{updiagonalstrike}{9},
		\enclose{circle}{10}, \enclose{circle}{11}, \enclose{circle}{12},
		\enclose{horizontalstrike}{13}, \enclose{horizontalstrike}{14},
		\enclose{horizontalstrike}{15}, \enclose{updiagonalstrike}{16},
		\enclose{horizontalstrike}{17}, \enclose{horizontalstrike}{18},
		\enclose{horizontalstrike}{19}, \enclose{horizontalstrike}{20},
		\enclose{circle}{21}, \enclose{horizontalstrike}{22}, 
		\enclose{horizontalstrike}{23}, \enclose{circle}{24}. 
	\]

	If we count them up, we see that we&apos;ve only ended up with \( 11 \) numbers
	circled rather than \(12 \) as we might have hoped for. Among the numbers,
	\(1 \) through \(12 \), \(1, 4 \) and \(9 \) were crossed out as they were
	squares. The were paired with \(24, 21 \) and \(16 \) respectively. Picking
	\(24 \) and \(21 \) to go in our set doesn&apos;t pose a problem, as they are not
	perfect squares. But, we can&apos;t pick \(16 \) as it is a perfect square. The
	fact that \( 9 + 16 = 25 \), or \(3^2 + 4^2 = 5^2 \), poses a problem as we
	have two square numbers that add up to \(25, \) which itself is a perfect
	square. 

	&lt;p&gt;For students who get to this point, usually it would be clear what the
	answer is, possibly with some help from the interviewers (which is perfectly
	fine!). For the second part, once the main argument has been understood, it
	is only a matter of knowing whether a solution to \( a^3 + b^3 = c^3 \)
	exists for positive integers \(a, b \) and \(c \). Fermat&apos;s Last Theorem
	rules out this possibility.

	&lt;p&gt;If there were time time left, I would explore further by asking students to
	count the number of ways in which picking such a set could be achieved. In
	general, once a solution is arrived at it is quite common for
	interviewers to start discussing related questions provided there was time
	remaining. 

	&lt;p&gt;&lt;b&gt;Reflections&lt;/b&gt;: The aim of this question is &lt;b&gt;&lt;i&gt;not&lt;/i&gt;&lt;/b&gt; to test
	whether students are familiar with Pyathagorean triples or Fermat&apos;s Last
	Theorem. What I was looking for is to see how students make a connection
	between two potentially interacting constraints, that the numbers picked
	should not be squares and no two of them should add up to \( n \). In good
	interviews, this naturally led to a quick chat about Pythagorean triples (which
	you should read about if you are not familiar, because they are cool) and a
	very quick word about Fermat&apos;s Last Theorem. The interaction between
	combinatorics and number theory that appears in this question is something
	that will be typical of questions you might get in interviews (or indeed on
	the MAT), as we are interested to see how you make connections between
	different areas of mathematics.
&lt;/div&gt;
</description>
        <pubDate>Thu, 15 Sep 2022 06:11:00 +0100</pubDate>
        <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/09/15/interview-question1-discussion.html</link>
        <guid isPermaLink="true">http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/09/15/interview-question1-discussion.html</guid>
        
        <category>oxford</category>
        
        <category>cs</category>
        
        <category>maths</category>
        
        <category>interview</category>
        
        
        <category>post</category>
        
      </item>
    
      <item>
        <title>Interview Question 2</title>
        <description>&lt;div&gt;
	&lt;ol&gt;
		&lt;li&gt;Find the smallest natural number ending in \(6\), such that if the last \(6\) is removed and placed in the front, the new number is \(4\) times the original number.&lt;/li&gt;
		&lt;li&gt;Can you give a procedure to find the smallest number ending in digit \(d\), where \(d\) is between \(1\) and \(9\), such that if the last digit, \(d\), is removed and placed in front, you get a number that is \(k\) times as large? Is this possible for every value of \(d\) and \(k\)?
	&lt;/ol&gt;

	This question was used in CS interviews at &lt;a href=&quot;https://www.lmh.ox.ac.uk/&quot;&gt;Lady Margaret Hall&lt;/a&gt; in December 2019. 

	&lt;br&gt;&lt;br&gt;&lt;b&gt;Update&lt;/b&gt;: This post was updated to use MathJax on July 25, 2022.
&lt;/div&gt;
</description>
        <pubDate>Wed, 29 Jun 2022 14:00:00 +0100</pubDate>
        <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/06/29/interview-question2.html</link>
        <guid isPermaLink="true">http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/06/29/interview-question2.html</guid>
        
        <category>oxford</category>
        
        <category>cs</category>
        
        <category>maths</category>
        
        <category>interview</category>
        
        
        <category>post</category>
        
      </item>
    
      <item>
        <title>Interview Question 1</title>
        <description>&lt;div&gt;
	For a non-negative real number \(x\), the floor of \(x\), denoted by \( \lfloor x \rfloor\) is the largest integer that is less than or equal to \(x\). For example, \(\lfloor 3 \rfloor = 3 \) and \( \lfloor 6.999 \rfloor = 6 \). 
	&lt;ol&gt;
		&lt;li&gt;Let \(n\) be a positive natural number that is a perfect square. You are asked to pick a set of \( \lfloor \frac{n}{2} \rfloor \) natural numbers from \( 1,2, \ldots,n - 1 \), such that none of the chosen numbers is a perfect square, and no two &lt;i&gt;distinct&lt;/i&gt; chosen elements add up to \(n \). For what values of \(n\) is this possible?&lt;/li&gt;
		&lt;li&gt;Let \(n\) be a positive natural number that is a perfect cube. You are asked to pick a set of \( \lfloor \frac{n}{2} \rfloor \) natural numbers from  \( 1,2, \ldots,n -1 \), such that none of the chosen numbers is a perfect cube, and no two &lt;i&gt;distinct&lt;/i&gt; chosen elements add up to \(n\). For what values of \(n\) is this possible?&lt;/li&gt;
	&lt;/ol&gt;

	This question was used in CS interviews at &lt;a href=&quot;https://www.lmh.ox.ac.uk/&quot;&gt;Lady Margaret Hall&lt;/a&gt; in December 2018. 

	&lt;br&gt;&lt;br&gt;&lt;b&gt;Update&lt;/b&gt;: This post was updated to use MathJax on July 10, 2022.
&lt;/div&gt;
</description>
        <pubDate>Wed, 29 Jun 2022 10:00:00 +0100</pubDate>
        <link>http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/06/29/interview-question1.html</link>
        <guid isPermaLink="true">http://www.cs.ox.ac.uk/people/varun.kanade/website/post/2022/06/29/interview-question1.html</guid>
        
        <category>oxford</category>
        
        <category>cs</category>
        
        <category>maths</category>
        
        <category>interview</category>
        
        
        <category>post</category>
        
      </item>
    
  </channel>
</rss>
