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.
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!
@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.
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?
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); }
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 ?
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!
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.
@@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
@@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.
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 ?...
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.
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!
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.
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!
@Bobby Dylan instablaster =)
@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.
@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
Thanks. I learned a lot from your videos. Your learning style is amazing!!
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?
Lifesaver! Thanks for this.
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);
}
Thank you... just learned pretty much trough your videos
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 ?
thank you. i love ur way of teaching
Thank you
Isnt Binary exponentiation the best method for calculating exponents of a number.
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!
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.
@@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
we can think easily on recursion by assuming that our first recursion call is going to give the answer ...
if(arraySize == 0)
{
return array[0]
}
Ah yes... I also did this when I started programming... Actually - I didn't.
its normal to be more depressed after watching this playlist?
I certainly hope my videos do not induce depression.
@@vantonspraul your videos are not the peoblem i'm just to dumb to understand then
@@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.
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 ?...