Why You Must Learn Prefix Sum Algorithm? | Need of prefix-sum Algorithm | EP1

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024

ความคิดเห็น • 84

  • @JavaAidTutorials
    @JavaAidTutorials  5 ปีที่แล้ว +9

    Hello Coding Lover,
    If you have any doubts , please let me know in comments.

  • @mayurkadam
    @mayurkadam 5 ปีที่แล้ว +10

    Nice one most of the time i used traditional one 😅
    Whenever you upload that video just notify me

    • @JavaAidTutorials
      @JavaAidTutorials  5 ปีที่แล้ว

      Thanks Mayur.
      Make sure you have subscribed and press the bell icon to get the notification instantly.

    • @mayurkadam
      @mayurkadam 5 ปีที่แล้ว +1

      @@JavaAidTutorials all set 👍

    • @JavaAidTutorials
      @JavaAidTutorials  5 ปีที่แล้ว

      @@mayurkadam cool (Y)

  • @Anonymous-pj2mv
    @Anonymous-pj2mv 3 ปีที่แล้ว +2

    Easy explanation
    Great job .

  • @rohitpal36
    @rohitpal36 4 ปีที่แล้ว +3

    just prefect .. keep it on man

  • @rohitkumarvarma4952
    @rohitkumarvarma4952 3 ปีที่แล้ว +1

    Really a great video sir!! thanks a lot!

  • @tomasnascimento1762
    @tomasnascimento1762 2 ปีที่แล้ว

    great introduction to the topic

  • @kunalsolanki100
    @kunalsolanki100 6 วันที่ผ่านมา

    sir please make full dsa course

  • @rajeshg8718
    @rajeshg8718 2 ปีที่แล้ว

    awesome explanation

  • @tetrahedralone
    @tetrahedralone 4 ปีที่แล้ว +1

    You have stated the reason why prefix sum is better than the naive approach, but not provided the reason why the algorithm must be learned. I know of 2 applications, line of sight analysis and creating cumulative images for image processing. What other applications make this relevant as more than just a test exercise?

    • @JavaAidTutorials
      @JavaAidTutorials  4 ปีที่แล้ว +2

      Find this list on little bit of googling, I hope it help :)
      The uses of the all-prefix-sums operation are extensive. Here is a list of some of them:
      1. To lexically compare strings of characters. For example, to determine that "strategy" should appear before "stratification" in
      a dictionary (see Problem 2).
      1.1 Introduction 37
      2. To add multi precision numbers. These are numbers that cannot
      be represented in a single machine word (see Problem 3).
      3. To evaluate polynomials (see Problem 6).
      4. To solve recurrences. For example, to solve the recurrences
      xi = aixi−1 + bixi−2 and xi = ai + bi/xi−1 (see Section 1.4).
      5. To implement radix sort (see Section 1.3).
      6. To implement quicksort (see Section 1).
      7. To solve tridiagonal linear systems (see Problem 12).
      8. To delete marked elements from an array (see Section 1.3).
      9. To dynamically allocate processors (see Section 1.6).
      10. To perform lexical analysis. For example, to parse a program into
      tokens.
      11. To search for regular expressions. For example, to implement the
      UNIX grep program.
      12. To implement some tree operations. For example, to find the depth
      of every vertex in a tree (see Chapter 3).
      13. To label components in two dimensional images
      complete PDF can be find here-
      www.cs.cmu.edu/~guyb/papers/Ble93.pdf

    • @sherazdotnet
      @sherazdotnet ปีที่แล้ว +2

      If you are given a binary tree and a target value and you are asked to find the nodes that sum up to the target value. The brute force solution to this is O(N^2) because you are going to visit each node and on each node you are going to check of any of the previous nodes + visiting node is equal to the given target. So traversing tree = O(N) and finding if any previous node sum + current node = target is also O(N). But using Prefix sum this time complexity can be reduced to O(N).

  • @yasserhisham8778
    @yasserhisham8778 2 ปีที่แล้ว

    Thanks for the lesson. I think to be more precise the Prefix Sum Algorithm takes O(m+n) not just O(n).

  • @shobhitkumar9452
    @shobhitkumar9452 4 ปีที่แล้ว +1

    hello sir.. can you please make a video on the problem append and delete from hackerrank.

  • @Akash-rv3yr
    @Akash-rv3yr 5 ปีที่แล้ว +5

    2:59 why there is a outer loop since all queries have different input so to calculate sum for each query we have to run the for loop for each query all the for loop will be execute for n times in worst case for m queries so the complexity will be m*O(n) why it is O(m*n) ?
    Please clarify my doubts.

    • @JavaAidTutorials
      @JavaAidTutorials  5 ปีที่แล้ว +1

      Hi Akash,
      I can see you have two separate queries so let me take it one by one.
      1) some time you will get bunch of queries which you need to perform of n size input array. if you do one by one (which is fairly possible) but for each and individual query you need to process the array every time or at max O(n) time for n size array.
      but there is way to save the execution time by pre-processing the array only once (irrespective of query size).
      for example checkout this problem with multiple queries--> www.hackerrank.com/challenges/crush/problem
      2) If we treat n as function complexity is O(n). similarly here m is a query size, if you treat it like a function then it will be O(m*n) or if you treat it as a scaler quantity then it will be m*O(n). but over all result will be same. because for each query you may end up process at max O(n).

    • @Akash-rv3yr
      @Akash-rv3yr 5 ปีที่แล้ว

      Thank you so much!!

    • @JavaAidTutorials
      @JavaAidTutorials  5 ปีที่แล้ว

      Most welcome..:😊

    • @JavaAidTutorials
      @JavaAidTutorials  5 ปีที่แล้ว

      Most welcome..:😊

    • @JavaAidTutorials
      @JavaAidTutorials  5 ปีที่แล้ว

      Most welcome..:😊

  • @MojarFunTV
    @MojarFunTV 4 ปีที่แล้ว

    Thank you for video 😋Fully watched till the end LIKE 👍hmm interesting video 👌♥️ enjoyed it please connect mee friends👌

    • @JavaAidTutorials
      @JavaAidTutorials  4 ปีที่แล้ว

      Thank you :)
      you can connect me on various social media, just have a look on video description

  • @top10thingwhichyoushouldkn37
    @top10thingwhichyoushouldkn37 4 ปีที่แล้ว

    any motivation i am doing array from last 5 days and i am so bore from this

  • @mohammadimran8568
    @mohammadimran8568 5 ปีที่แล้ว

    neeed code attachment plz

    • @JavaAidTutorials
      @JavaAidTutorials  5 ปีที่แล้ว

      Are you talking about the slides? or something else