Segment Tree: Build and Query | Live Coding..

Поділитися
Вставка
  • Опубліковано 4 лип 2024
  • Check our Website:
    In case you are thinking to buy courses, please check below:
    Link to get 20% additional Discount at Coding Ninjas: bit.ly/3wE5aHx
    Code "takeuforward" for 15% off at GFG: practice.geeksforgeeks.org/co...
    Code "takeuforward" for 20% off on sys-design: get.interviewready.io?_aff=takeuforward
    Crypto, I use the Wazirx app: wazirx.com/invite/xexnpc4u
    Take 750 rs free Amazon Stock from me: indmoney.onelink.me/RmHC/idje...
    Earn 100 rs by making a Grow Account for investing: app.groww.in/v3cO/8hu879t0
    Linkedin/Instagram/Telegram: linktr.ee/takeUforward
    ---------------------------------------------------------------------------------------------------------------------------------------------------- In this video, the Segment Tree Data Structure has been discussed.
    Please donate to save someone's life: www.ketto.org/fundraiser/i-ne...
    Proof: www.quora.com/Why-does-4-*-N-...
    Striver's Linkedin Profile: / rajarvp
    Instagram(I reply mostly here): / striver_79
    Connect with us: t.me/Competitive_Programming_tuf (Use Link in Mobile only)
    #FundRaiser #SegmentTree #Tutorial

КОМЕНТАРІ • 107

  • @deepakchawla1105
    @deepakchawla1105 4 роки тому +104

    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 .

  • @akshatpriyansh1818
    @akshatpriyansh1818 2 роки тому +1

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

  • @abhisekmohanty7386
    @abhisekmohanty7386 4 роки тому +5

    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.

  • @devanshmesson2777
    @devanshmesson2777 2 роки тому +3

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

  • @ankitsingh-rb8pc
    @ankitsingh-rb8pc 3 роки тому +8

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

  • @harinijaan3779
    @harinijaan3779 2 роки тому

    You are the best. Clearly explained

  • @prashantshukla6870
    @prashantshukla6870 Рік тому +1

    The way you explain was absolutely great.

  • @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 .

  • @itz_me_imraan02
    @itz_me_imraan02 3 роки тому +10

    One who explains tough concepts easily... 🔥

  • @rakesh8829
    @rakesh8829 3 роки тому +2

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

  • @chandrashekarv.t7981
    @chandrashekarv.t7981 3 роки тому +4

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

  • @lifeofasoftwareengg...930
    @lifeofasoftwareengg...930 2 роки тому

    Fantastic explanation!!

  • @GauravKumar-by1yt
    @GauravKumar-by1yt 4 роки тому

    Love your video...nice gesture

  • @simardeepsinghmudhar7065
    @simardeepsinghmudhar7065 2 місяці тому +1

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

  • @rohansharma4065
    @rohansharma4065 3 роки тому +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

  • @ShubhamSHARMA-oi4xf
    @ShubhamSHARMA-oi4xf 4 роки тому +9

    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.

  • @yashgoyal6079
    @yashgoyal6079 2 роки тому

    Wonderful Explanation 👌

  • @lofibeats2344
    @lofibeats2344 Рік тому +1

    Please continue uploading about advanced DSA

  • @shensean1784
    @shensean1784 Рік тому

    Thank u. Nice explanation and good code demo.

  • @divyanshdixit4944
    @divyanshdixit4944 4 роки тому

    Nice video. Please upload lazy propagation too.

  • @aligohar1708
    @aligohar1708 Рік тому

    So on point, loved it

  • @ramtiwari4727
    @ramtiwari4727 3 роки тому

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

  • @raj_kundalia
    @raj_kundalia Рік тому

    Amazing explanation!

  • @chaitanyakumar9229
    @chaitanyakumar9229 3 роки тому

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

  • @shriyasripuram529
    @shriyasripuram529 4 роки тому +2

    Now, this is best content!
    Thank you sir.

  • @sachingoyal7443
    @sachingoyal7443 3 роки тому

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

  • @dheeraj3281
    @dheeraj3281 3 роки тому

    Crystal clear explanation! Thanks bro!

  • @ztrixx3280
    @ztrixx3280 4 роки тому +2

    Crystal clear explanation..✔️💯

  • @codingwithsam4992
    @codingwithsam4992 Рік тому

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

  • @DharanAditya
    @DharanAditya 4 роки тому +1

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

  • @sagardhandhalya2067
    @sagardhandhalya2067 3 роки тому

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

  • @rohitrout6450
    @rohitrout6450 2 роки тому

    what about update_query_on_a_given_range?

  • @sainathsingineedi2922
    @sainathsingineedi2922 4 роки тому +8

    Really nice gesture from you❤️

  • @AceHardy
    @AceHardy 4 роки тому

    👑

  • @m.s.nabhiram1532
    @m.s.nabhiram1532 4 роки тому

    Thanks

  • @vaibhavsethia70
    @vaibhavsethia70 3 роки тому

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

  • @nightmare_9
    @nightmare_9 3 роки тому +1

    Amazing man !! Just an amazing explanation

  • @prernapundir8020
    @prernapundir8020 4 роки тому +1

    Really appreciable...thanks a lot sir.

  • @soumyadeepdutta6759
    @soumyadeepdutta6759 Рік тому +1

    where do I get this code?

  • @sysfailureexe6038
    @sysfailureexe6038 3 дні тому

    Thank youu !!

  • @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??

  • @sumitmahato1341
    @sumitmahato1341 4 роки тому

    Please made some video on javascript.

  • @vishalsingh1295
    @vishalsingh1295 3 роки тому

    Thanks for saving time

  • @subhadeepdas8701
    @subhadeepdas8701 2 роки тому

    Very nice explanation

  • @suhaanbhandary4009
    @suhaanbhandary4009 Рік тому

    Understood!!

  • @siddhantdash4955
    @siddhantdash4955 2 роки тому

    great one..

  • @burhanuddinsadikot4300
    @burhanuddinsadikot4300 3 роки тому

    Dude you are just awesome👍🏻, thanks

  • @mukulasija4501
    @mukulasija4501 Рік тому

    Thankyou..

  • @shivabansfore7510
    @shivabansfore7510 4 роки тому

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

  • @kunalgulati3358
    @kunalgulati3358 2 роки тому

    great video

  • @gunratnamore4250
    @gunratnamore4250 Рік тому

    Perfect :)

  • @_wolvox
    @_wolvox 4 роки тому

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

  • @priyanshusrivastava2145
    @priyanshusrivastava2145 Рік тому

    Striver is Legend For a Reason

  • @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?

  • @utsavsingh899
    @utsavsingh899 4 роки тому +2

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

  • @yashdeore473
    @yashdeore473 3 роки тому +1

    LIT

  • @tarunsinha8964
    @tarunsinha8964 3 роки тому

    The best explanation!

  • @sadhunarun7430
    @sadhunarun7430 3 роки тому

    very interesting topic well explained bro :D

  • @technologybaba192
    @technologybaba192 14 днів тому

    Understood

  • @koocheukkeijacky9704
    @koocheukkeijacky9704 3 роки тому

    Thank you sooo much sir!!

  • @showsshorts4696
    @showsshorts4696 Рік тому +1

    great sir

  • @p38_amankuldeep75
    @p38_amankuldeep75 Рік тому

    understood❤❤❤

  • @suryaprakashkalyanam3186
    @suryaprakashkalyanam3186 4 місяці тому

    ❤❤❤

  • @AnkitKumar-mb4vl
    @AnkitKumar-mb4vl 4 роки тому

    Very nicely explained👍

  • @rishabhkumar8115
    @rishabhkumar8115 2 роки тому

    great video sir ji

  • @Joel-px2yy
    @Joel-px2yy 4 місяці тому

    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);
    }
    }

  • @vaalarivan_p
    @vaalarivan_p Рік тому

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

  • @shadabfaizal
    @shadabfaizal 3 роки тому

    bhai maza aa gya video dekh kr

  • @pulkitjain5159
    @pulkitjain5159 Рік тому

    bahi maja agya , kya explain kiya hai

  • @mainakmondal5228
    @mainakmondal5228 Рік тому

    US

  • @vedantvalsangkar2091
    @vedantvalsangkar2091 3 роки тому

    Simply awesome

  • @tecHSonic
    @tecHSonic 4 роки тому

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

  • @MANASDEWARIMVCS
    @MANASDEWARIMVCS Рік тому

    osm

  • @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

  • @dayanandraut5660
    @dayanandraut5660 2 роки тому

    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 Рік тому

      @@GuitarCoversByRavi it should be 2n-1

  • @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 Місяць тому

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

  • @pratikkundnani
    @pratikkundnani 4 роки тому +1

    Do product based companies ask segment tree questions?

  • @adityapandey2514
    @adityapandey2514 3 роки тому

    just awesome 3000

  • @skt7088
    @skt7088 3 роки тому

    Please also make a video on sparse table data structure

  • @jethalalnhk2409
    @jethalalnhk2409 4 роки тому

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

  • @pratikthakur9016
    @pratikthakur9016 4 роки тому +1

    Hi frist

  • @harshsrivastava5124
    @harshsrivastava5124 3 роки тому

    aye su che

  • @sjgghosh7677
    @sjgghosh7677 3 роки тому +3

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

  • @safalyaghoshroy2405
    @safalyaghoshroy2405 4 роки тому

    First comment!!!