How to perform a query in mongoose?

Can we perform a large number of Point Update Query in less than Amortized (logn) time?

  • If we have to perform range update query many times, Can we reduce the overall time? Edit - Can this be solved by applying DP or Hashing with BIT?

  • Answer:

    Yes, it is possible in a special case. If all updates occur before queries, then updating the closed interval [a,b][a,b] [a,b] with value x, can be done by marking the positions b and a-1 with +x and -x respectively. After all updates complete, we can traverse through the array from last to first, to complete the updation. This method is linear in worst case which is worse than the worst case logarithmic time in other data structures like segment trees or binary indexed trees. But in the special case where a large number of continuous updates occur together, this has an amortized constant time. It is however not possible to obtain an average case performance of sub logarithmic time.

Rajkiran Rajkumar at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.