Divide & Conquer (Think Like a Programmer)

preview_player
Показать описание

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:

Connect with me:
Рекомендации по теме
Комментарии
Автор

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.

lupita
Автор

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!

johnnyesperanto
Автор

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?

isaacchuah
Автор

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

t
Автор

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 ?

gustavomoncada
Автор

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

DarthAmitesh
Автор

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

pfannkuchen
Автор

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

}

FarahATUBE
Автор

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!

d_agudo
Автор

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

nishithakur
Автор

its normal to be more depressed after watching this playlist?

caiquemoa
Автор

if(arraySize == 0)
{
return array[0]
}

Ah yes... I also did this when I started programming... Actually - I didn't.

Mortuus
Автор

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

EdukazeChannel