Segment Tree: Build and Query | Live Coding..

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 109

  • @deepakchawla1105
    @deepakchawla1105 4 года назад +119

    This is so great that our coders community is helping to save someone's life . A great fan of yours sir . This is highly appreciated .

  • @abhisekmohanty7386
    @abhisekmohanty7386 4 года назад +10

    Striver you really won my heart bro.....The cause is really worth donating. And I surely would. Having said that would you please try to make videos on SPOJ problems like GSS1, GSS2, GSS3, GSS4 and some other good problems on segments trees, like I many times find problem figuring out the merging conditions and even the updates when we are dealing with tougher problems, Striver would be really happy if u try making them.
    I really appreciate this gesture of yours buddy.

  • @ankitsingh-rb8pc
    @ankitsingh-rb8pc 3 года назад +10

    best segment tree lecture i can find. i was trying to learn it from last year

  • @rohansharma4065
    @rohansharma4065 4 года назад +2

    Update Code based on the above video code-
    void add(vi&arr, int val,int tidx, int idx, int low, int high){
    if(high == low && high == tidx){
    seg[idx] += val; return;
    }
    seg[idx]+= val;
    int mid = (low+high)/2;
    if(tidx>=low && tidx=mid+1 && tidx

  • @simardeepsinghmudhar7065
    @simardeepsinghmudhar7065 6 месяцев назад +1

    What a great coder, i hope he gets into a good mnc such as google, keep it up 👍

  • @chandrashekarv.t7981
    @chandrashekarv.t7981 3 года назад +6

    No words to say .......He is the Absolute Best !

  • @devanshmesson2777
    @devanshmesson2777 3 года назад +3

    Such a nice explanation on Segment Trees, You just removed my fear of Segment Trees!
    Thank you so much Striver!

  • @StellarWeb008
    @StellarWeb008 Месяц назад

    I love the voice of this man. It sparks confidence.

  • @deepakchawla1105
    @deepakchawla1105 4 года назад +7

    Sir , It would be so great if you make a video on "How to stay motivated in CP and how to handle frustation" , i hope a lot of people need it .

  • @ShubhamSHARMA-oi4xf
    @ShubhamSHARMA-oi4xf 4 года назад +10

    Really nice from you Striver . It would help him a lot . Continue your good work brother . The way you come forward to help others is really appreciable.

  • @Joel-px2yy
    @Joel-px2yy 8 месяцев назад

    Java code:
    class SegmentTree {
    static int arr[];
    static int seg[];
    static void build(int ind, int low, int high) {
    if (low == high) {
    seg[ind] = arr[low];
    return;
    }
    int mid = low + ((high - low) / 2);
    build(2 * ind + 1, low, mid);
    build(2 * ind + 2, mid + 1, high);
    seg[ind] = Math.max(seg[2 * ind + 1], seg[2 * ind + 2]);
    }
    static int findMax(int idx, int low, int high, int l, int r) {
    if (low >= l && high r)
    return Integer.MIN_VALUE;
    int mid = low + ((high - low) / 2);
    int left = findMax(2 * idx + 1, low, mid, l, r);
    int right = findMax(2 * idx + 2, mid + 1, high, l, r);
    return Math.max(left, right);
    }
    public static void main(String[] args) {
    arr = new int[] { 8, 2, 5, 1, 4, 5, 3, 9, 6, 10 };
    int n = arr.length;
    seg = new int[n * 4];
    build(0, 0, n - 1);
    // System.out.println(Arrays.toString(seg));
    int q1 = findMax(0, 0, n - 1, 1, 4);
    int q2 = findMax(0, 0, n - 1, 3, 8);
    int q3 = findMax(0, 0, n - 1, 4, n - 1);
    System.out.println(q1 + " " + q2 + " " + q3);
    }
    }

  • @prashantshukla6870
    @prashantshukla6870 2 года назад +1

    The way you explain was absolutely great.

    • @_PixelPioneer_
      @_PixelPioneer_ 5 месяцев назад

      kehna kya chahte ho hindi me bolo

  • @itz_me_imraan02
    @itz_me_imraan02 3 года назад +10

    One who explains tough concepts easily... 🔥

  • @lofibeats2344
    @lofibeats2344 2 года назад +1

    Please continue uploading about advanced DSA

  • @akshatpriyansh1818
    @akshatpriyansh1818 2 года назад +1

    Super clear explanation. Loved the structure and the flow, keep it up.

  • @aishwaryasingh246
    @aishwaryasingh246 Месяц назад

    Beautiful explanation. Thank you so much.

  • @codingwithsam4992
    @codingwithsam4992 Год назад

    how is segment tree different or useful from sparse table?
    I want to edit any value in logn time.

  • @rakesh8829
    @rakesh8829 4 года назад +2

    I personally felt this is the best video by striver.
    Thank u Striver :)

  • @harinijaan3779
    @harinijaan3779 2 года назад

    You are the best. Clearly explained

  • @rohitrout6450
    @rohitrout6450 2 года назад +1

    what about update_query_on_a_given_range?

  • @sagardhandhalya2067
    @sagardhandhalya2067 4 года назад

    Segment Tree use to scare me but not anymore , thank you. this video deserves more like.

  • @divyanshdixit4944
    @divyanshdixit4944 4 года назад

    Nice video. Please upload lazy propagation too.

  • @utsavsingh899
    @utsavsingh899 4 года назад +2

    What are you using to "write" on the screen?

  • @soumyadeepdutta6759
    @soumyadeepdutta6759 Год назад +1

    where do I get this code?

  • @sainathsingineedi2922
    @sainathsingineedi2922 4 года назад +8

    Really nice gesture from you❤️

  • @sysfailureexe6038
    @sysfailureexe6038 3 месяца назад +1

    Thank youu !!

  • @ramtiwari4727
    @ramtiwari4727 3 года назад

    keep it up......great video on segment tree...

  • @shriyasripuram529
    @shriyasripuram529 4 года назад +2

    Now, this is best content!
    Thank you sir.

  • @GauravKumar-by1yt
    @GauravKumar-by1yt 4 года назад

    Love your video...nice gesture

  • @jethalalnhk2409
    @jethalalnhk2409 4 года назад

    you haven't write function for update operation

  • @Code_Note
    @Code_Note 4 года назад

    bro can u please tell is it possible to return the index of the maximum element within a given range??

  • @raj_kundalia
    @raj_kundalia Год назад

    Amazing explanation!

  • @lifeofasoftwareengg...930
    @lifeofasoftwareengg...930 2 года назад

    Fantastic explanation!!

  • @chaitanyakumar9229
    @chaitanyakumar9229 3 года назад

    This is the best and the simplest explanation i saw !!

  • @Ajay-ju2ig
    @Ajay-ju2ig 4 года назад

    We use array for storing value in segment tree .It is possible some index in middle of the array is empty?

  • @DharanAditya
    @DharanAditya 4 года назад +1

    Good initiative bro. I dontated my Part. Keep inspiring Us.

  • @aligohar1708
    @aligohar1708 2 года назад

    So on point, loved it

  • @shivabansfore7510
    @shivabansfore7510 4 года назад

    Daa after this plz make video on lazy propogation there is no proper video on youtube..

  • @_wolvox
    @_wolvox 4 года назад

    Can you please make a video on range update query also!

  • @sumitmahato1341
    @sumitmahato1341 4 года назад

    Please made some video on javascript.

  • @vishalsingh1295
    @vishalsingh1295 4 года назад

    Thanks for saving time

  • @vaibhavsethia70
    @vaibhavsethia70 3 года назад

    Clean explanation!! Understood in 1 go. Thanks..

  • @yashgoyal6079
    @yashgoyal6079 2 года назад

    Wonderful Explanation 👌

  • @ztrixx3280
    @ztrixx3280 4 года назад +2

    Crystal clear explanation..✔️💯

  • @priyanshusrivastava2145
    @priyanshusrivastava2145 Год назад

    Striver is Legend For a Reason

  • @sachingoyal7443
    @sachingoyal7443 3 года назад

    Excellent.. One of the best and precise explanation. Thank you 😊😊

  • @subhadeepdas8701
    @subhadeepdas8701 2 года назад

    Very nice explanation

  • @dheeraj3281
    @dheeraj3281 3 года назад

    Crystal clear explanation! Thanks bro!

  • @m.s.nabhiram1532
    @m.s.nabhiram1532 4 года назад

    Thanks

  • @showsshorts4696
    @showsshorts4696 Год назад +1

    great sir

  • @mukulasija4501
    @mukulasija4501 Год назад

    Thankyou..

  • @dayanandraut5660
    @dayanandraut5660 3 года назад

    Bro, you missed the part on how to calculate the number of nodes in segment tree given the Array. That's one of the most important parts to understand when it comes to segment tree.

    • @GuitarCoversByRavi
      @GuitarCoversByRavi 2 года назад +1

      Isn't it the same as space taken in seg[ ] array, i. e. 4*n

    • @noobplays6673
      @noobplays6673 2 года назад

      @@GuitarCoversByRavi it should be 2n-1

  • @siddhantdash4955
    @siddhantdash4955 2 года назад

    great one..

  • @technologybaba192
    @technologybaba192 4 месяца назад

    Understood

  • @suhaanbhandary4009
    @suhaanbhandary4009 Год назад

    Understood!!

  • @prernapundir8020
    @prernapundir8020 4 года назад +1

    Really appreciable...thanks a lot sir.

  • @nightmare_9
    @nightmare_9 3 года назад +1

    Amazing man !! Just an amazing explanation

  • @kunalgulati3358
    @kunalgulati3358 3 года назад

    great video

  • @mohitgarg7070
    @mohitgarg7070 4 года назад +2

    *Hey striver, we'll participate for sure but i have a request that whatever amount their college mates get, please tell them to donate all of that money directly to Tarun not through that ketto app because that fundraiser organisation charges 10% of whatever they make through that platform.*
    *Bold*

    • @ShubhamSHARMA-oi4xf
      @ShubhamSHARMA-oi4xf 4 года назад +3

      Okay we will look into it thanks for your suggestion/concern.

    • @munvut877
      @munvut877 5 месяцев назад

      @@ShubhamSHARMA-oi4xf what happened to that boy is he okay now?

  • @pulkitjain5159
    @pulkitjain5159 Год назад

    bahi maja agya , kya explain kiya hai

  • @vaalarivan_p
    @vaalarivan_p Год назад

    0:00 - 7:05
    9:17 - 12:04

  • @shadabfaizal
    @shadabfaizal 3 года назад

    bhai maza aa gya video dekh kr

  • @yashdeore473
    @yashdeore473 3 года назад +1

    LIT

  • @rishabhkumar8115
    @rishabhkumar8115 3 года назад

    great video sir ji

  • @tecHSonic
    @tecHSonic 4 года назад

    Which software or pen table do you use for making videos?

  • @TarunSinha13
    @TarunSinha13 3 года назад

    The best explanation!

  • @AceHardy
    @AceHardy 4 года назад

    👑

  • @AnkitKumar-mb4vl
    @AnkitKumar-mb4vl 4 года назад

    Very nicely explained👍

  • @shensean1784
    @shensean1784 2 года назад

    Thank u. Nice explanation and good code demo.

  • @p38_amankuldeep75
    @p38_amankuldeep75 Год назад

    understood❤❤❤

  • @gunratnamore4250
    @gunratnamore4250 2 года назад

    Perfect :)

  • @burhanuddinsadikot4300
    @burhanuddinsadikot4300 3 года назад

    Dude you are just awesome👍🏻, thanks

  • @shashwatsingh1892
    @shashwatsingh1892 4 года назад

    Hey striver tell them not to keep any prize money for the contest and keep tell them to donate entry fees for the same

  • @suryaprakashkalyanam3186
    @suryaprakashkalyanam3186 8 месяцев назад

    ❤❤❤

  • @pratikthakur9016
    @pratikthakur9016 4 года назад +1

    Hi frist

  • @koocheukkeijacky9704
    @koocheukkeijacky9704 4 года назад

    Thank you sooo much sir!!

  • @mainakmondal5228
    @mainakmondal5228 2 года назад

    US

  • @sadhunarun7430
    @sadhunarun7430 4 года назад

    very interesting topic well explained bro :D

  • @vedantvalsangkar2091
    @vedantvalsangkar2091 3 года назад

    Simply awesome

  • @MANASDEWARIMVCS
    @MANASDEWARIMVCS Год назад

    osm

  • @pratikkundnani
    @pratikkundnani 4 года назад +1

    Do product based companies ask segment tree questions?

  • @skt7088
    @skt7088 3 года назад

    Please also make a video on sparse table data structure

  • @adityapandey2514
    @adityapandey2514 3 года назад

    just awesome 3000

  • @harshsrivastava5124
    @harshsrivastava5124 4 года назад

    aye su che

  • @sjgghosh7677
    @sjgghosh7677 3 года назад +3

    wasn't this supposed to be one of the toughest concepts :(

  • @jethalalnhk2409
    @jethalalnhk2409 4 года назад

    i thought its a very hard topic but its easy but times consuming during contest

  • @safalyaghoshroy2405
    @safalyaghoshroy2405 4 года назад

    First comment!!!