Divide & Conquer (Think Like a Programmer)

Sdílet
Vložit
  • čas přidán 3. 08. 2016
  • This video explores the "divide and conquer" technique of problem solving--mainly a recursive technique, so if you haven't watched it yet, I would start with my earlier video on recursion ( • Recursion (Think Like ... ). Also if you go to my publisher's site (link below), you can download the chapter in the Think Like a Programmer book for free.
    Your comments and suggestions for future videos are welcome.
    "Think Like a Programmer" is a book I've written to help programmers with problem solving. If you've found that you are able to read programs and understand programming language syntax but aren't always confident writing programs from scratch, my book may be able to help.
    For more information on the book head to one of these:
    Amazon page for the book: amzn.to/1MZlmlY
    My site: www.vantonspraul.com/TLAP
    My publisher's site: nostarch.com/thinklikeaprogrammer
    Connect with me:
    My site: vantonspraul.com
    Twitter: / vantonspraul
    Facebook: / thinklikeaprog
  • Věda a technologie

Komentáře • 27

  • @t1054384
    @t1054384 Před 6 lety +2

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

  • @lupita3689
    @lupita3689 Před 4 lety +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.

  • @pfannkuchen12345
    @pfannkuchen12345 Před 5 lety

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

  • @hugoirwanto9905
    @hugoirwanto9905 Před 4 lety

    thank you. i love ur way of teaching

  • @johnnyesperanto3859
    @johnnyesperanto3859 Před 6 lety +3

    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  Před 6 lety +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 Před 2 lety

      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 Před 2 lety

      @Bobby Dylan instablaster =)

    • @bobbydylan6792
      @bobbydylan6792 Před 2 lety

      @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 Před 2 lety

      @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

  • @gustavomoncada5321
    @gustavomoncada5321 Před 5 lety +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 ?

  • @masanaxx
    @masanaxx Před rokem

    Lifesaver! Thanks for this.

  • @isaacchuah7543
    @isaacchuah7543 Před 3 lety +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?

  • @amiteshmagar7915
    @amiteshmagar7915 Před 3 lety

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

  • @RoyerAdames
    @RoyerAdames Před 3 lety

    Thank you

  • @Farah7ATUBE
    @Farah7ATUBE Před 4 lety

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

  • @d_agudo
    @d_agudo Před 4 lety

    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  Před 4 lety +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 Před 4 lety

      @@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 Před 6 lety +8

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

  • @caiquemoa
    @caiquemoa Před rokem

    its normal to be more depressed after watching this playlist?

    • @vantonspraul
      @vantonspraul  Před rokem

      I certainly hope my videos do not induce depression.

    • @caiquemoa
      @caiquemoa Před rokem

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

    • @vantonspraul
      @vantonspraul  Před rokem +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.

  • @47Mortuus
    @47Mortuus Před 4 lety

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

  • @EdukazeChannel
    @EdukazeChannel Před 4 lety

    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 ?...