TutorMe homepage
Subjects
PRICING
COURSES
Start Free Trial
Ankush A.
Studying Data Science at Illinois Tech, Chicago
Tutor Satisfaction Guarantee
SQL Programming
TutorMe
Question:

Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically. The STATION table is described as follows - FIELD TYPE ID NUMBER CITY VARCHAR2(21) STATE VARCHAR2(21) LAT_N NUMBER LONG_W NUMBER

Ankush A.

This can be solved by running 2 different queries and combining the results together using UNION. The first query fetches the city and length of its name and sorts in ascending order and limit the result to 1, fetches only the shortest city name and its length. Likewise, the second query only fetches 1 longest city name and its length as the result from the second query is sorted in descending order. Solution - (select city, length(city) from station order by 2, 1 limit 1) union (select city, length(city) from station order by 2 desc, 1 limit 1)

Python Programming
TutorMe
Question:

Given a string, find out if its characters can be rearranged to form a palindrome.

Ankush A.

To answer this question, let us look at how a palindrome can be understood. A palindrome is a sequence of characters which when reversed are the same as the original string. For example, "racecar", when reversed (read from right to left), the sequence of the characters is still the same as "racecar". Thus it can be seen as, the string (sequence of words) is broken in half, and the other half is just the mirror image of the first half. Thus, in the given string, at max, one character can occur an odd number of times, all the remaining characters have to occur even number of times. For example, in "racecar", "r" occurs twice, "a" occurs twice, "c" occurs twice and only "e" occurs once (odd) and thus a palindrome. the python code for the above is as follows - def palindromeRearranging(inputString): charDict = {} oneSingleChar = False flag = True for i in range(len(inputString)): if inputString[i] in charDict.keys(): charDict[inputString[i]] += 1 else: charDict[inputString[i]] = 1 for nbrOfChar in charDict.values(): if nbrOfChar % 2 == 1 and not oneSingleChar: oneSingleChar = True elif nbrOfChar % 2 == 1 and oneSingleChar: flag = False break else: flag = True return flag

Algebra
TutorMe
Question:

If $$\alpha$$ and $$\beta$$ are the roots of $$x^2+px-q=0$$ and$$\gamma$$ and $$\delta$$ are the roots of $$x^2+px+r=0$$ show that $$(\alpha-\gamma)(\alpha-\delta)=(\beta-\gamma)(\beta-\delta)=q+r$$

Ankush A.

Given that $$\alpha$$ and $$\beta$$ are the roots of $$x^2+px-q=0$$ and$$\gamma$$ and $$\delta$$ are the roots of $$x^2+px+r=0$$. Therefore, -q = $$\alpha\beta$$, implies q = $$-\alpha\beta$$. and p = $$(\alpha + \beta)$$ Similarly, r = $$\gamma\delta$$ and p = $$(\gamma + \delta)$$ now, consider proving the first part - $$(\alpha-\gamma)(\alpha-\delta)=q+r$$ L.H.S. = $$\alpha^{2} - \alpha\delta -\alpha\gamma + \gamma\delta$$ L.H.S. = $$\alpha^{2} - \alpha*(\delta + \gamma) + r$$ ( since, r = $$\gamma\delta$$ ) L.H.S. = $$\alpha^{2} - \alpha*(p) + r$$ ( since, p = $$(\gamma + \delta)$$ ) L.H.S. = $$\alpha^{2} - \alpha*(\alpha + \beta) + r$$ ( since, p = $$(\alpha + \beta)$$ ) L.H.S. = $$\alpha^{2} - \alpha^{2} - \alpha\beta + r$$ L.H.S. = $$-\alpha\beta + r$$ L.H.S. = q + r (since q = $$-\alpha\beta$$) Hence proved --> $$(\alpha-\gamma)(\alpha-\delta)=q+r$$ Similarly, consider the second part - $$(\beta-\gamma)(\beta-\delta)=q+r$$ L.H.S. = $$\beta^{2} - \beta\delta -\beta\gamma + \gamma\delta$$ L.H.S. = $$\beta^{2} - \beta*(\delta + \gamma) + r$$ ( since, r = $$\gamma\delta$$ ) L.H.S. = $$\beta^{2} - \beta*(p) + r$$ ( since, p = $$(\gamma + \delta)$$ ) L.H.S. = $$\beta^{2} - \beta*(\alpha + \beta) + r$$ ( since, p = $$(\alpha + \beta)$$ ) L.H.S. = $$\beta^{2} - \beta\alpha- \beta^{2} + r$$ L.H.S. = $$-\beta\alpha+ r$$ L.H.S. = q + r (since q = $$-\alpha\beta$$)

Send a message explaining your
needs and Ankush will reply soon.
Contact Ankush
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.