Euclid Algorithm Coding - Java Algorithms Tutorial
Euclid Algorithm Coding is a free tutorial by Tim Buchalka's Learn Programming Academy from Java Algorithms course
Link to this course(Special Discount):
https://www.udemy.com/course/advanced-algorithms-using-java/?ranMID=39197&ranEAID=Gw%2FETjJoU9M&ranSiteID=Gw_ETjJoU9M-uUOEp2dz.uCT7gvinx2Spg&utm_source=aff-campaign&LSNPUBID=Gw%2FETjJoU9M&utm_medium=udemyads
This is the best Java Algorithms Course
Course summary:
Have an understand of how algorithms work, at a deep level
Write better Java code that is more optimised
English [Auto]
In this video we are going to code our Euclid rhythm. So to start with that let's go to search main Java. Let's create a new packaging here. Which will be called Akademi dog learn programming not algorithm. Dog Euclid. OK. So you should see something like this. Now let's create a new class which we don't need to invent any crazy name let's just call Euclid right. Let's get some comment here saying Euclide algorithm. And Euclid it will calculate or actually it calculates the greatest common divisor. Greatest Common Divisor between two numbers a and b. Right. So it's a greater common divisor between A and B. All right. So for us implementation we are going to make is a implementation using recursion. So let's create a public int greater common divisor just GCD. Let's say int number and divisor k. And what we do here. Remember we had let's add a little comment here so we can the same situation we had in our introduction implementation using recursion. And let's break line here and then here I'm going to say we had 22 and 6 which was three and rest for. Then we had six and four. Right. Got six from here four from there. And the result are these is one rest of two. And then we had four and two which was to rest or zero. So let's implement that and talk to this as we implement first thing we need to do is get this number. So we get we have two numbers here and here we need to divide them and get the rest. So let's call remaining call remaining equals and we can just say number two is this modulo divisor. This is going to give us. Number four we were assigned number four to the remaining or 0. Right. And in this case year 22 and six were before. So what we need to do is let's create an IF condition here say if my remaining not equals here I do call it again. Right. So I would return grade common divisor. But what I'm going to send back is remember I need to send a divisor as a number. So I'm going to say in here devising and number is actually my remaining divisor is actually my remaining. So the main called again sending divisor and remaining and it's going to call as many times as it takes to reach zero when it reaches zero. We are going to return the divisor. So remember when it reaches zero divisor is our common greatest common divisor between those two numbers. And that's it. This is the implementation. Well let's suppose that you are in a interview or I don't know you need to implement this some other way. Right. So let's implement have the same implementation but not using recursion that say public in great common divisor that's called great common divisor to and in number and is divisor right. And the difference now is what I need to do is create a look right this one didn't need the loop because it keeps calling again and again and again and in this case I actually need a while loop and I'm going to do while this happens. Right. Remaining which in my case I'm not going to keep creating variables I'm going to change the divisor. Divisor is not a for sure. There are many ways to implement this. This is the way I'm implementing here just to illustrate but if you find another way feel free to do it just create unit tests and be sure that it's working properly. So what I'm going to do is I'm going to create a temporary variable. Let me show you what I'm going to do here. So implementation aim without much recursion. Right. And we're going to use the same example we add in here. So basically what I what I'm going to do is we have the number. So this is the number divided by there are two stages here. One is this is the divisor and also the vizor or Tamm or it's actually divisor. And the Tim can equals result. Grasp of and the rest of it would be will get there would be actually the divisor. So does that mean it will become the divisor. So that's the latest to make life simpler. This is what we are going to have after you start modifying me show me what I mean with that. I'm going to start create a temporary variable and say hey my divisor is my name now. So whatever I have here became my temp. Right. And what I need to do now is do the calculations so I'm going to change my divisor and my divisor to be the model of this calculation. Why. Because I need to call it again sending the divisor. So I'm just preparing the divisor here to do that already. So I'm going to say number Marjoe divisor. So divisor. So let's say we have 22 a
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Euclid Algorithm Coding - Java Algorithms Tutorial», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.