Enable contrast version

Tutor profile: Nir S.

Inactive
Nir S.
Computer Science and Mathematics expert
Tutor Satisfaction Guarantee

Questions

Subject: Python Programming

TutorMe
Question:

Write a python function that accepts a list of 2 or more numbers as a parameter, and returns the second largest number. Use a for loop.

Inactive
Nir S.
Answer:

def second_largest_number(lst): largest = None second_largest = None for num in lst: if largest == None or num > largest: #we found a new largest number second_largest = largest #the old largest number is now second largest largest = num elif second_largest == None or num > second_largest #new second largest number second_largest = num return second_largest

Subject: Computer Science (General)

TutorMe
Question:

Describe an efficient algorithm to solve the following problem, and analyze it's time complexity: Given a sorted array A of n integers, determine whether some number appears more than n/2 times in A.

Inactive
Nir S.
Answer:

First, we observe that since the array is sorted, if some value x appears in it more than n/2 times, it must appear in the middle of the array. That is, A[floor(n/2)] == x. Now we describe the algorithm: Using binary search, we find the indexes of the first and last appearance of the value A[floor(n/2)] in the array. The number of times the value A[floor(n/2)] appears in the array must be exactly: l last_index - first_index+1. We check if that amount is greater than n/2. The algorithm runs in O(log(n)) time, since other than 2 binary searches, everything else runs in constant time.

Subject: Calculus

TutorMe
Question:

Find the derivative of the function f(x)=cos(x^3+4x)

Inactive
Nir S.
Answer:

Using the chain rule: f(x) = cos(g(x)) where g(x) = x^3+4x First we derive g(x) using the formula for the derivative of a polynomial: g'(x) = 3*x^2+4 Now, using the chain rule, and the fact that the derivative of cos(x) is -sin(x): f'(x) = g'(x)*(-sin(g(x)) = -(3*x^2+4)*sin(x^3+4x)

Contact tutor

Send a message explaining your
needs and Nir will reply soon.
Contact Nir

Request lesson

Ready now? Request a lesson.
Start Lesson

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 Lesson" 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.