All language subtitles for 27. Extra Recursion 4 - Find if Digits are Ascending, Descending, or not - Question

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,880 --> 00:00:01,750 All right. 2 00:00:01,850 --> 00:00:07,750 What is going on, ladies and gentlemen, and welcome to this video where we are going to develop a 3 00:00:07,750 --> 00:00:11,390 recursive function that receives an integer number. 4 00:00:11,650 --> 00:00:13,930 OK, so we are going to do some recursion. 5 00:00:15,100 --> 00:00:22,810 Another exercise and you are going to become even better and you will get more knowledge and more experience 6 00:00:22,810 --> 00:00:24,730 working with recursion. 7 00:00:25,480 --> 00:00:31,180 So what do you have to do is to develop a recursive function that receives an integer number and all 8 00:00:31,180 --> 00:00:36,250 the functions you do is it should observe the digits from left to right. 9 00:00:36,580 --> 00:00:42,850 And then based on the order of these digits, the function should return one. 10 00:00:43,270 --> 00:00:51,370 If the digits from left to right are very ascending, the function should return minus one if the digits 11 00:00:51,370 --> 00:00:54,130 from left to right are very descending. 12 00:00:55,090 --> 00:00:57,280 And the function should return is zero. 13 00:00:57,430 --> 00:00:58,270 Otherwise. 14 00:00:58,810 --> 00:01:05,890 So simply saying we look at the digits from left right and we say if they are incrementing from left 15 00:01:05,890 --> 00:01:11,120 to right, we will return one if they are a discriminating from left to right. 16 00:01:11,140 --> 00:01:12,700 We will return minus one. 17 00:01:13,090 --> 00:01:21,340 And if we have any other case, like if maybe two digits are the same or basically if two digits, we 18 00:01:21,340 --> 00:01:27,100 have one digits smaller than the other and then we have another digit smaller than this one. 19 00:01:27,310 --> 00:01:32,150 Then basically, we can say that it's definitely not very ascending, neither. 20 00:01:32,230 --> 00:01:38,170 It's also not a very descending a sequence of digits. 21 00:01:38,470 --> 00:01:38,830 OK. 22 00:01:39,820 --> 00:01:40,180 So. 23 00:01:41,400 --> 00:01:48,030 We know that this exercise can be easily solved just by using some loops, right, we can use some loop 24 00:01:48,030 --> 00:01:51,180 iterating over each and every one of the digits. 25 00:01:51,660 --> 00:01:58,050 Probably we will do also the same here, but for now, because we are requested to develop a function, 26 00:01:58,050 --> 00:01:59,550 a recursive function. 27 00:01:59,910 --> 00:02:04,170 We will say, at least at the beginning, we will say, OK, we have. 28 00:02:05,110 --> 00:02:11,700 First, the idea of using loops, let's take loops, put them aside and try to solve it in another way, 29 00:02:11,710 --> 00:02:13,330 in a recursive manner. 30 00:02:13,540 --> 00:02:22,120 When we are going to take a bigger problem, splitting it up to smaller problems, some problems in 31 00:02:22,130 --> 00:02:25,230 making conclusions based on this day vision. 32 00:02:25,640 --> 00:02:29,170 OK, that's what we are requested to do to write the recursive function. 33 00:02:30,160 --> 00:02:36,280 Also, a couple of assumptions that we need to take into account is, first of all, that we can take 34 00:02:36,280 --> 00:02:43,060 some assumption that the initial noun verb to function is going to receive is basically has more than 35 00:02:43,060 --> 00:02:44,860 two digits, two digits and beyond. 36 00:02:44,860 --> 00:02:49,120 OK, it's not just one one digit number. 37 00:02:49,420 --> 00:02:53,740 If it was like if we had to take into consideration all the possibilities. 38 00:02:54,010 --> 00:03:00,280 So basically just there were a couple of few changes that we would need to add. 39 00:03:00,460 --> 00:03:07,570 But for now, we will assume that our now is at least of two digit size and all digits in some are different. 40 00:03:07,720 --> 00:03:08,110 OK. 41 00:03:08,140 --> 00:03:14,860 That's very important to take into account because if not, we would need to add a few more lines of 42 00:03:14,860 --> 00:03:15,220 code. 43 00:03:15,730 --> 00:03:21,610 That's basically something that we can do, but for now, that will be sufficient for us to work and 44 00:03:21,610 --> 00:03:26,840 to develop these recursive function with these pretty much nice assumptions. 45 00:03:26,860 --> 00:03:32,080 OK, so we have initial number of two plus digits and all digits in some are different. 46 00:03:32,110 --> 00:03:36,370 No pair of digits are the same, meaning all the digits are going to be different. 47 00:03:36,640 --> 00:03:39,460 In this example, we will simply use it like this. 48 00:03:39,550 --> 00:03:41,470 OK, so all the digits will be different. 49 00:03:41,890 --> 00:03:48,640 So for example, if we have, this number now equals two one two four, then we can say that the function 50 00:03:48,640 --> 00:03:49,720 should return one. 51 00:03:50,020 --> 00:03:56,080 Because if we take a look at the digits from left to right, we will see that the digits are very ascending. 52 00:03:56,980 --> 00:04:02,170 If we will take a look at this one, we will see that although the digits seem to be very ascending, 53 00:04:02,560 --> 00:04:04,510 the last digit is descending. 54 00:04:04,690 --> 00:04:11,830 And that means that the sequence of these digits from left to right is neither very ascending nor very 55 00:04:11,830 --> 00:04:12,460 descending. 56 00:04:13,540 --> 00:04:19,240 Final option is when, whenever we return, minus one is when we have from left to right. 57 00:04:19,450 --> 00:04:25,480 If we take a look at the digits and we see that they are very descending, meaning for every pair of 58 00:04:25,480 --> 00:04:29,890 digits that we take, the left digit will be greater than the right one. 59 00:04:30,310 --> 00:04:32,320 OK, so that's the function that you have to develop. 60 00:04:33,340 --> 00:04:35,560 Take some time to think about what should be the solution. 61 00:04:35,560 --> 00:04:37,390 How to approach this exercise. 62 00:04:37,390 --> 00:04:38,740 Write some code on your own. 63 00:04:38,740 --> 00:04:47,320 Try to run it using some function, some main call for these function and make sure that your idea works 64 00:04:47,320 --> 00:04:51,130 and then compare it with the results that we are going to do together. 6587

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.