TutorMe homepage
Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Revanth G.
Computer Science/Math Undergraduate at Carnegie Mellon University
Tutor Satisfaction Guarantee
Python Programming
TutorMe
Question:

Given an array with x amount of numbers and a target value y, write the most efficient algorithm that prints all possible unique pairs of numbers within the array that sum to y. The numbers are in the set of integers.

Revanth G.
Answer:

To reduce the run time complexity in python, we can use a set. Create two sets by the name of new and temp. The new set will remove any duplicates and at worst keep the original array if no duplicates are present. Next, create a temp set that is also the same as the new set which you can use later to modify. Converting a list to a set is O(n). Next I iterate through every element in new set and I compute value which is equal to target - element. If this value is in the new set, I will print out the pair (value, element) and remove this element from temp which is O (1). Overall I am iterating through every element in new set n times which is O(n). The complexity of this algorithm is O(n) + O(n) = O (2n) = O(n). The code I wrote below is this algorithm. def possiblepairs(target, array): new = set(array) temp = set(array) for elem in new: value = target - elem if(value in temp): print(elem,value) temp.remove(elem)

Number Theory
TutorMe
Question:

Arithmetic sequences $$(a_x)$$ and $$(b_x)$$ have integer terms with $$a_1 = b_1 = 1 < a_2 \leq b_2$$ and $$a_x b_x = 2010$$ for some $$x$$. What is the largest possible value of $$x$$?

Revanth G.
Answer:

Let $$d_1$$ be the common difference of the arithmetic sequence $$a_x$$. The first term is $$a_1 = 1$$, so $$a_x = 1 + (x - 1) d_1$$ for all $$n$$ $$\geq$$ $$1$$. Since $$a_2 > 1$$, the common difference $$d_1$$ is positive. Similarly, let $$d_2$$ be the common difference of the arithmetic sequence \((b_x)\). The first term is $$b_1 = 1$$, so $$b_x = 1 + (n - 1) d_2$$ for all $$n$$ $$\geq$$ $$1$$. Since $$b_2 > 1$$, the common difference $$d_2$$ is also positive. We observe that $$x - 1$$ divides both $$a_x - 1$$ and $$b_x - 1$$ for all $$x$$. Also, since $$a_24$$ $$\leq$$ $$b_2$$, $$a_x$$ $$\leq$$ $$b_x$$ for all $$x$$. If $$a_x b_x = 2010$$, then $$(a_x, b_x)$$ must be one of the pairs $$(2,1005), (3,670), (5,402), (6,335), (10,201), (15,134)$$, or $$(30,67)$$. For each such pair, we compute the largest number dividing both $$a_x - 1$$ and $$b_x - 1$$: \begin{array}{c|c|c} a_x & b_x & \gcd(a_x - 1, b_x - 1) \\ \hline 2 & 1005 & 1 \\ 3 & 670 & 1 \\ 5 & 402 & 1 \\ 6 & 335 & 1 \\ 10 & 201 & 1 \\ 15 & 134 & 7 \\ 30 & 67 & 1 \end{array} We see that the largest possible value of $$x - 1$$ is 7 (for $$a_x = 15$$ and $$b_x = 134$$), so the largest possible value of $$x$$ is $$\boxed{8}$$. The corresponding arithmetic sequences are $$a_x = 2x - 1$$ and $$b_x = 19x - 18$$.

Physics
TutorMe
Question:

A battery is connected to the endpoints A and B of a homogeneous wire. Using an ammeter one finds that a current I = 1.5 amps flows through the conductor. Then, the wire is bent in the form of a circle and the same battery is connected to points A and B. A point C is now exactly between points A and B. What is the current in Amps flowing through point C in this case? You may neglect the internal resistance of the battery.

Revanth G.
Answer:

Assume the wire's resistance is 2 ohms. Then the voltage of AB is 3 volts by ohm's law which is V = IR. When the same wire is bent into a circle, the distance of AB is half of the length it used to be therefore the resistance also halfs. Now each branch is 1 ohm and the voltage drop across each branch is still 3 volts by using the voltage divider formula. Substituting these values in the ohms law equation, we solve for I = current. 3= Current * 1. Now its simple to deduce that current flowing across point C is 3 amps.

Send a message explaining your
needs and Revanth will reply soon.
Contact Revanth
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.