Enable contrast version

Tutor profile: Harshil N.

Inactive
Harshil N.
Software Engineer with about two years experience
Tutor Satisfaction Guarantee

Questions

Subject: Pre-Calculus

TutorMe
Question:

How many ways to choose any r numbers from a set of n numbers? How do we derive it if we don't know the popular formula?

Inactive
Harshil N.
Answer:

Consider the numbers from 1....n. Now consider r blanks. Lets start filling the r blanks from the n numbers. The first blank can be filled using any of the n numbers. The second with n-1 as the first blank is already filled and there are n-1 numbers remaining. The third with n-2 and so on. The last blank can be filled with n-(r-1) numbers. So the total ways could be counted as n*(n-1)*(n-2)....(n-r+1) = n!/(r)! . But we have not considered duplicates. For each combination of those blanks we have also counted their permutations as separate combinations. For instance (1,2,3) and (3,2,1) and (2,1,3) are all counted as separate combinations. So we divide each combination we have got by (n-r)!. As we can permute any combination by (n-r)! ways. So we can then divide the total by (n-r)!. Hence n!/(r!(n-r)!).

Subject: Java Programming

TutorMe
Question:

Whats a singleton object? And why do we need one?

Inactive
Harshil N.
Answer:

A singleton object is one which on invoking the constructor of the corresponding class returns the same object on each invocation. To elaborate that, it means the class (lets name it C1 ) which we want as singleton, we return the same object of C1 across all the other classes which are dependent on C1. We would need one because of various reasons. One of them could be space considerations. Any application which uses plenty of classes and each class depends on other classes, we might end up constructing plenty of objects in the memory. Increasing the frequency of garbage collector operating and slow down the application. Also when we make singletons, we make them thread safe. This is to avoid any state changes to the object which is being used by a thread (t1) by another thread(t2).

Subject: Computer Science (General)

TutorMe
Question:

What data structure would you use to organise incoming requests to a web server with each request having a priority being assigned to it?

Inactive
Harshil N.
Answer:

The answer is a priority queue. We use a priority queue using heap implementation where the top most element of the heap is the request which has the highest priority at a given time T. As each request arrives on the server we store it to the heap, the property of the heap being that each element has two nodes both of which have a priority less than the priority of itself. When we insert to the heap, we need to maintain the original property of the heap, which takes log n time (where n is the size of the heap). And when we want to serve a request we just access the top most element which is constant time operation i.e O(1).

Contact tutor

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

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.