Divide & Conquer (Think Like a Programmer)

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

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

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

    Unrelated to divide and conquer but a more efficient way to solve the exponential problem is to check binary bits of n, eg. n = 11 = 8 + 2 + 1, so we need x, x^2, x^8, you can update x = x * x at every iteration of looking at the smallest bit of n, and multiply the answer by the current base, then n = n >> 1.

  • @johnnyesperanto3859
    @johnnyesperanto3859 6 лет назад +4

    Thank you for making these videos. I picked up your book a few weeks back and the videos go very well together. I hope you keep making great material!

    • @vantonspraul
      @vantonspraul  6 лет назад +2

      Thank you! I'm glad you are enjoying them. I've been pretty busy of late, but I'm hoping to get some new stuff up soon.

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

      I guess Im randomly asking but does any of you know of a way to get back into an instagram account??
      I was stupid lost my account password. I appreciate any tricks you can offer me!

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

      @Bobby Dylan instablaster =)

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

      @Saul Layton i really appreciate your reply. I got to the site through google and I'm waiting for the hacking stuff now.
      I see it takes quite some time so I will reply here later when my account password hopefully is recovered.

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

      @Saul Layton It did the trick and I finally got access to my account again. I'm so happy:D
      Thank you so much you really help me out :D

  • @t1054384
    @t1054384 6 лет назад +2

    Thanks. I learned a lot from your videos. Your learning style is amazing!!

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

    Helpful video. One thing though: I didn't quite get what you meant at 3:44 when you said we should store the "left" and "right" as local variables. Specifically, why would not doing this end up in us calling the recursive function twice?

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

    Lifesaver! Thanks for this.

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

    Here's my attempt at the power function iteratively:
    static int power(int number, int exponent) {
    int answer=1;
    int iterations = exponent;
    while(iterations > 0) {
    answer = answer * number;
    iterations--;
    }
    return answer;
    }
    public static void main(String[] arg) {
    int result = power(2, 0);
    System.out.println(result);
    int result = power(2, 5);
    System.out.println(result);
    }

  • @pfannkuchen12345
    @pfannkuchen12345 5 лет назад

    Thank you... just learned pretty much trough your videos

  • @gustavomoncada5321
    @gustavomoncada5321 5 лет назад +1

    Could we make a helper function that would check if the starting power is odd? If odd then return (call to recursive function) * base? else return just the call to the recursive function by itself ?

  • @hugoirwanto9905
    @hugoirwanto9905 5 лет назад

    thank you. i love ur way of teaching

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

    Thank you

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

    Isnt Binary exponentiation the best method for calculating exponents of a number.

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

    Hi Anton! First i would like to say thxs for sharing these amazing videos!!t hey`ve helped me a lot!!.Is your book translated into spanish?! would be awesome!

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

      You're welcome! Unfortunately, no, Think Like a Programmer has never been translated into Spanish. I'd like to see that happen, but the way translation deals work is, a publisher gets the rights to translate a book and market it in a particular area (for example, a Japanese publisher gets the rights to sell a Japanese language edition in Japan). I think a Spanish edition would be great if it could reach Spanish-speaking programmers wherever they are, but I don't know if there's a way to make that happen.

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

      @@vantonspraul ok then! I'll buy the book in English, i just didn't want to miss anything ;-)... The chapter about recursion is very good!!! I can't wait to put it in practice! Thks again Anton

  • @nishithakur424
    @nishithakur424 6 лет назад +8

    we can think easily on recursion by assuming that our first recursion call is going to give the answer ...

  • @47Mortuus
    @47Mortuus 4 года назад

    if(arraySize == 0)
    {
    return array[0]
    }
    Ah yes... I also did this when I started programming... Actually - I didn't.

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

    its normal to be more depressed after watching this playlist?

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

      I certainly hope my videos do not induce depression.

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

      @@vantonspraul your videos are not the peoblem i'm just to dumb to understand then

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

      @@caiquemoa Oh, come on. If any of the concepts seem too advanced, just find a simpler place to start. If there's anything in particular that you have questions on, let me know.

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

    this is inspiring video for me to create interesting content for programming topics. I was trying for this, but not given good result enough on my channel. Maybe someone can give feedback to my videos ?...