Coding Challenge #35.2: Lexicographic Order

Поделиться
HTML-код
  • Опубликовано: 24 дек 2024

Комментарии • 153

  • @aadityamayankar3407
    @aadityamayankar3407 4 года назад +59

    it feels like he's learning, understanding and teaching all at the same time.

  • @zinsy23
    @zinsy23 5 лет назад +14

    I actually learn best from people who make mistakes. I believe they make the best teachers!

  • @flippyflopper2360
    @flippyflopper2360 7 лет назад +170

    You're like the Bob Ross of programming, but instead of nice little trees or clouds, you have nice little functions or algorithms.

    • @davislast7891
      @davislast7891 7 лет назад +4

      I see this comment on every one of his videos

    • @mazza420
      @mazza420 7 лет назад +7

      he's still got nice little trees though!

    • @lerenah
      @lerenah 6 лет назад +1

      parse-like trees :)

    • @lukehenry9682
      @lukehenry9682 6 лет назад +4

      Nice little fractal trees

    • @MrCmon113
      @MrCmon113 6 лет назад +1

      I hope he will be remembered like that. He is not only a great educator, but also an embodiment of wholesomeoness.

  • @shad.baksh1
    @shad.baksh1 8 лет назад +113

    I like this weird man.

  • @shawnmofid7131
    @shawnmofid7131 4 года назад +4

    Thank you so much for the video. It helped me understand the lexicographic order and the algorithm for its permutations.

  • @khopcraft
    @khopcraft 8 лет назад +15

    I think it's good to have a look at the debugging portion. Allow's people to see the entire process.

  • @AnkushSingh-hi6gj
    @AnkushSingh-hi6gj 8 лет назад

    This is exactly what i was looking for a few days. Thanks for explanation.

  • @pradikapratama9895
    @pradikapratama9895 5 лет назад

    i see myself while coding when i see u, thanks i'm not alone

  • @adityaojha2701
    @adityaojha2701 4 года назад

    This is the only video on RUclips. Thanks for this.

  • @51GL
    @51GL 2 года назад

    It made me crazy when you first wrote the code for largest y wrong. ... i paused the video for 10 minutes figuring out why you did it like that because i thaught I !!! was wrong ... when i finally gave up and 5 minutes lateer you corrected yourself ... oh maaaan ... i should not doubt my self :D

  • @sohailape
    @sohailape 6 лет назад +1

    you are amazing , just started watching you videos a few days ago and now i am determined to complete all your tutorials . And you book (not sure you wrote it??) is amazing too. It's so simple and explains many basic concept in a clear way.
    I am in computer engineering 1st year atm but the education system of my country we learn almost nothing in college(at least not learned anything useful in first year).

    • @graceh.2157
      @graceh.2157 5 лет назад

      ha, is there a book about this?

  • @chrizzie1
    @chrizzie1 5 лет назад +3

    Just a couple of optimisations (which seems important when the number of permutations increases factorially with array length):
    1. For finding the largest index k such that something(...) it's faster to search from the end of the array and break out of the loop once you've found a case where something(...) is true, i.e.
    largestK = -1;
    for (var k = vals.length -1; k >=0; k--) {
    if(something(...)) {
    largestK = k;
    break;
    }
    }
    This means that we don't need to waste time checking all indices less than largestK. Here, the loop runs for about half as many iterations before breaking, on average.
    2. If I'm not mistaken, increasing the length of an array is typically a slow operation that requires copying all elements in the array to a new location in memory, so for the partial array reversal, it'd likely be more computationally efficient to just perform a sequence of swaps, i.e.
    for (int k = 0; k < (end-start)/2; k++) {
    swap(vals, start+k, end-k);
    }
    This way the array never changes length, and you already had the swap(...) function implemented anyway.

  • @telugutv1743
    @telugutv1743 6 лет назад +6

    I likes this mad progrmmer... 🤗🤗🤗

  • @betterculture
    @betterculture 7 лет назад

    I know I'm late to the party @ 9:55, but as reference, you can reverse the values in-place without added complexity:
    var next = largest + 1;
    var middle = (vals.length + next) >> 1;
    var last = vals.length - 1;
    for(var current = next; current < middle; ++current, --last){
    swap(vals, current, last);
    }

    • @TheCodingTrain
      @TheCodingTrain  7 лет назад

      Thanks for this tip!!!

    • @betterculture
      @betterculture 7 лет назад

      Anytime boss! Glad I could help :)
      Kindly checkout my implementation of the lexicographical permutation algorithm (with round-trip reordering): github.com/karagulamos/Euler/blob/master/Euler.Algorithms/Permutations/Permuters/LexicographicalPermuter.cs
      Let me know your thoughts. Thanks.

    • @KnakuanaRka
      @KnakuanaRka 4 года назад

      Or that loop can be while (next < last) {swap(vals, next, last); next++; last-;}, which looks a bit simpler and avoids potential off-by-one errors with the middle.
      Or even for (i = 0; 2i < last - next; i++) {swap(vals, next + i, last - i);}

  • @vincentcleaver1925
    @vincentcleaver1925 7 лет назад

    Buenos Aires! I love saying that... and I understand it's a charming city, too.

  • @readysetfire7144
    @readysetfire7144 8 лет назад

    you're so fun to watch man

  • @ahura2018
    @ahura2018 8 лет назад +1

    I Like How You Explain Your Code :D

  • @beyondcatastrophe_
    @beyondcatastrophe_ 7 лет назад +13

    What the heck happened at 8:25?! He missed quite a few things, didn't he? Confused... ':o

  • @preoalex8298
    @preoalex8298 Год назад +1

    We were taught this in 11th grade in computer science, i hate it.

  • @SimonTiger
    @SimonTiger 5 лет назад +1

    13:08 vals.push(...endArray) will work!

    • @DanKaschel
      @DanKaschel 4 года назад

      I'm sure that falls into the "JavaScript magic" territory that he's avoiding. Array.push.apply would probably be best, but short of that he just just use a while loop and pop off the end array to push into the original array. That also reverses the order so he wouldn't need the reverse () call which is a little magic-y itself.

    • @Fun-Planet
      @Fun-Planet 4 года назад

      That wasnt a thing during the recording of this

    • @SimonTiger
      @SimonTiger 4 года назад

      @@Fun-Planet Was it though? ES6 has been around since 2015. Or is the spread operator ES7 or something?
      EDIT: The spread operator is ES6. So it was a thing when this was recorded

    • @Fun-Planet
      @Fun-Planet 4 года назад

      @@SimonTiger oh ok my bad, he actually started using es6 when es8 came out

  • @The_Foreman
    @The_Foreman 5 лет назад +1

    Been having fun learning to program in java by translating all this so far. But it'd help if javascript splice and java splice weren't completely different functions. I've spent half an hour just trying to figure out how to translate these 5 lines of code. Sticking with my lessons of fail faster and moving onwards.

  • @VoyivodaFTW1
    @VoyivodaFTW1 7 лет назад +2

    I love the bell.

  • @30svich
    @30svich 8 лет назад +6

    Hi, Daniel, I love ur vids. I have a suggestion to make another challenge: simple physics engine, bubbles and rectangles are colliding etc.

    • @30svich
      @30svich 8 лет назад +1

      Gravity changes according to position of mouse with respect to the center of the screen

  • @Honken
    @Honken 8 лет назад

    If you only call the endArray bit after the sorting is done, this program runs 1000x faster.
    Initiate done = false, endArray only runs if(done), and done is set to true when largestI loop is broken.

  • @ThankYouESM
    @ThankYouESM 2 года назад

    Could we also get an (on-demand) index_to_lexico permutations version --
    index_to_lexico(index,base,baselength)?
    Example... 0=000, 1=001, 2=010, 3=100, 4=011, 5=101, 6=110, 7=111...
    Therefore... index_to_lexico(8,9,3) = 002

  • @doukain2096
    @doukain2096 5 лет назад +6

    You' ve mistaken in 7:40 and I was asking myself 'What I am doing wrong' xd

  • @rebornreaper194
    @rebornreaper194 3 года назад

    This one was a bit hard to follow. It might have helped to describe the problem statement that the lexical ordering was meant to solve here (ie not just "traveling salesman"). Love your vids, btw ✌️

  • @josbexerr5166
    @josbexerr5166 4 года назад

    Gracias mister Coding.... si la proxima aplica metodo heuristico --> Simulated annealing

  • @morphman86
    @morphman86 6 лет назад

    I don't know what have changed in the past 2 years, but for some reason, a[j] = temp now makes a[j] an object rather than the value of temp, meaning the swap function no longer works.

    • @sujals7108
      @sujals7108 6 лет назад

      Maybe you changed some of the code? Because it still works for me.

  • @nagesh007
    @nagesh007 2 года назад

    Awesome

  • @jared_per
    @jared_per 5 лет назад +1

    I know this is a late comment, by does anyone know why the first log of vals is missing 8 in his p5 code? (not in video, but in the p5 web editor)

    • @MitchellMcKinnon
      @MitchellMcKinnon 4 года назад +1

      Ran into the same issue and haven't figured it out. :(

    • @Fun-Planet
      @Fun-Planet 4 года назад +2

      Use this instead of console log line
      console.log(JSON.parse(JSON.stringify(vals)))
      This is due to the fact that console logs don't happen when they are supposed to. By the time it happens, the value of the array had changed, so it doesn't get displayed. By using parse and stringify, we are telling it to not log the vals array, but a copy of it
      Ps u can use vals.slice() as well

    • @jared_per
      @jared_per 4 года назад

      @@Fun-Planet Thank you. I'll have to try that.

  • @RodrigoNishino
    @RodrigoNishino 4 года назад

    I get drunk and watch Daniel coding

  • @rucklerful
    @rucklerful 8 лет назад

    you are AWESOME! Thank you.

  • @skeleton_craftGaming
    @skeleton_craftGaming 7 месяцев назад

    Letters are numbers. Always have been always will be, [just instead of them representing amount of something they are representing an index in our alphabet kind of. It's a little bit more complicated but yeah.]

  • @chrismanning5232
    @chrismanning5232 4 года назад

    6:30 in, shouldn't you be looping from the end and breaking at the first occurrence of largestI? Starting at the beginning is silly.

  • @sindhusiva4580
    @sindhusiva4580 3 года назад

    which programming language you used to solve this problem
    sir?

  • @HenryRSeymour
    @HenryRSeymour 8 лет назад

    Will there every be another print run of the coding rainbow shirts?

  • @morphman86
    @morphman86 6 лет назад +1

    A lot of people fear computer science because of the complex words. Same with any science, really. Even the word "science" itself is rather complex.
    Please don't, it's just words. If you don't know how to pronounce them, it's OK. Most of the people working with the words every day have no clue how to pronounce them either, they just know what they mean.
    But anyway, here's a hint. Slash the word down into its smallest spoken parts. For example, lexicographic: Lek Si Ko Gra Fik
    When you either learn to ignore the pronunciation or learn how to pronounce the scary words, the words stop being scary and you'll realize that science is actually quite easy to understand. It's just a lot of those words to take in. You just remember the meaning behind the words, ignore the words themselves and all of a sudden you're doing science.
    Pretty much what this channel has been doing for a long time now. You've been doing science without even knowing it. And what's even more awesome, most of that is maths!

    • @avananana
      @avananana 6 лет назад

      And your point is??? Are you saying that science is easy? I think you missed some vocabulary tests in school, just sayin'.

    • @morphman86
      @morphman86 6 лет назад

      @@avananana No, I'm saying it's easier than people think it is. That doesn't make it easy in any way, but it is not nearly as hard as people seem to think it is. And the reason people think this is because as soon as they hear these complicated words, they get turned off about the whole idea and think they can never understand it.
      Then you explain the (in context) simple concepts collected under those words, and people go "Oh, this is easy".

  • @pankakes_102
    @pankakes_102 6 лет назад

    will it still give all perms if the beginning array is not sorted asc?

  • @Akshatgiri
    @Akshatgiri 7 лет назад +4

    It will take *16.8* hours to finish that computation.

  • @arefdelphi8520
    @arefdelphi8520 6 лет назад

    All this work is with the j.s software or a special library??
    pleas help

  • @jerryn3l988
    @jerryn3l988 8 лет назад

    Daniell! when do you stream and where? btw your bids are great

  • @יםת
    @יםת 8 лет назад +2

    Coding Chalange: Conway's Game Of Life BUT with an infinite grid!

    • @purpleice2343
      @purpleice2343 7 лет назад +2

      It's solvable.
      Except the problem of ya know, infinite monitor which shows entire grid...

  • @igricRBX
    @igricRBX 6 лет назад +4

    You can't imagine how hard it was to do this in lua. You don't have functions like splice, reverse, concat...

    • @panunurmilaukas5519
      @panunurmilaukas5519 6 лет назад +2

      Dont know about lua.. but you know.. you can always write such simple functions yourself.

    • @igricRBX
      @igricRBX 6 лет назад

      @@panunurmilaukas5519 You are right, but I didn't know exactly what they do. I've managed to write them eventually.

    • @jared_per
      @jared_per 5 лет назад +1

      I'm actually in the process of doing this in lua. I love LUA! love love love lua. I just either use a library for some of these types of functions, or write my own and save them as my own library. I use lume for a lot of simple variable. github.com/rxi/lume (I realize this comment is a year old. Just saw "lua" and I had to jump in!)

    • @John-mj1kk
      @John-mj1kk 3 года назад

      no reason to use lua anymore considering that almost no industry employs it now. stick to java to learn the fundamentals.

    • @igricRBX
      @igricRBX 3 года назад

      @@John-mj1kk You clearly haven't educated yourself on the applications of lua. One literally can't escape the influence of lua nowadays. For example, many animations and 2d simulations are made in LÖVE engine, which explicitly uses lua, native modding tool for Scrap Mechanics and many other games is implemented in lua, even the two biggest companies in the gaming industry, namely Epic Games (Core) and Roblox, let you develop your own games in lua and it worked flawlessly for years. Needless to say, Java will never be considered a "basic", though it has a low-level syntax, the behind-the-scenes is much different. Java forces you to run a virtual machine every time you execute a piece of code and has its own environment that it has to convert into the machine language. Very not "basic", if ask me.
      TL;DR: *LUA IS THE BEST*

  • @shubhamsk473
    @shubhamsk473 7 лет назад

    I got so furious at Step 2 thinking is he really doing it wrong or I have gone crazy.. I actually paused the video and coded the whole thing myself just to prove myself that I'm not understanding it wrong.

  • @jeancvd
    @jeancvd 4 года назад

    Your video code is not doing the same thing as what was recorded on the video. If you open in the web editor Web p5.js. It is producing:
    [0, 2]
    [1]
    [1, 2]
    [2]
    [2, 1]
    Rather than:
    [0, 1, 2]
    [0, 2 , 1]
    [1, 0, 2]
    [1, 2, 0]
    [2, 0, 1]
    [2, 1, 0]
    I wonder why?

    • @Fun-Planet
      @Fun-Planet 4 года назад

      I am exciting this the 4th time and here's why it happens
      It's due to the fact that console log Doesn't happen when it is supposed to happen.
      Use this instead of the original console log line
      console.log(JSON.parse(JSON.stringify(vals)))

  • @charbelsarkis3567
    @charbelsarkis3567 7 лет назад

    u could loop through the endArray and push each value

  • @forepan9981
    @forepan9981 8 лет назад

    This guy is elite!

  • @everestgjonaj
    @everestgjonaj 8 лет назад

    cool video Daniel i am just a beginner in javascript and i just finished some lessons in code academy now im learning objects and i am doing great .Anyway i watch your videos everyday even if i dont understand a lot on them.how much time do you think it will take me as a beginner to learn to code these kind of programs?

  • @hopemgd
    @hopemgd 8 лет назад

    what if i want to do this for finding nth Lexicographic permutation of array up to 100 elements eg. A[26]={A,B,C..,Z}
    I am given index 'n' whose lexicographic permutation . As an example, the factoradic number 2110_! is equal to * * 2 x 3! + 1 x 2! + 1 x 1! + 0 x 0! * = 2 x 6 + 1 x 2 + 1 x 1 + 0 x 1 * = 12 + 2 + 1 + 0 * = 15
    So if n = 3 {A,BC} or n =4 and {A,B,C,D} .....trying to solve this problem in c++. thanks for the help!

  • @firephoenix5556
    @firephoenix5556 5 лет назад

    20:18 16 hours, 48 minutes
    11 numbers should mean it takes 11x as long

  • @Mustafaq9
    @Mustafaq9 8 лет назад

    This assumes that the list is always in the right order, doesn't it? If you're supposed to be finding the LARGEST x for which it's true (or i), shouldn't you be checking if vals[i] > largestI as well?

  • @polyrtm5545
    @polyrtm5545 6 лет назад

    isn't there a js function that reverses arrays?

  • @qbaker20
    @qbaker20 8 лет назад

    Isn't this just sorting in reverse order? Lexiographical sorting makes more sense to me when the objects have more than one dimension. For instance: sorting [bee, bay, bear] -> [bay,bear,bee] where you first look at the first letter and then advance to the second dimension within the object (second letter in this case) and sorting there.

  • @aks6657
    @aks6657 3 года назад

    2:35 Asansol 😄

  • @OrangeC7
    @OrangeC7 6 лет назад +6

    To display all permutations of 10 digits at 60fps, it would take a little more than a month.

    • @gim913
      @gim913 6 лет назад +5

      Not really, assuming one permutation per frame you get 10! / 60 (fps) / 60 (sec) / 60 min =~ 16h 48min

  • @gabef9538
    @gabef9538 4 года назад

    Do quad-trees speed this u?

  • @ShubhamSurana393
    @ShubhamSurana393 8 лет назад +4

    funny guy...but nice explaination
    PS: keeps awake while watching :P

  • @Amy-sz4gq
    @Amy-sz4gq 8 лет назад +1

    Hopefully I can get a reply relatively quickly....
    Would this algorithm work on a two number "alphabet" that is literally just 0 is first, 1 is second? Something about the P[x] < p[x+1] seems a little bit fishy bc its literally just 0 and 1, but intuitively I think it should still work.
    I don't have too much time to really go down the wrong-algorithm-rabbit-hole, so I'd appreciate a confirmation from someone if they get the chance.

    • @sujals7108
      @sujals7108 6 лет назад

      Yes it would, x would be 0 and y would be 1. So after swapping, the array would be [1,0] and that is the last permutation.

  • @b4ux1t3-tech
    @b4ux1t3-tech 8 лет назад +5

    Batman!
    No, really, Batman:
    en.wikipedia.org/wiki/Batman,_Turkey

  • @ctbram0627
    @ctbram0627 6 лет назад +1

    He is confusing the heck out of me. He defines a function swap that has three parameters then calls it with only 2. Then says the highest value less then 7 is 3 when 6 is also in the array. By the time he got 3/4 of the way done I could not remember how to spell my own last name!!!

    • @andrewfurey21
      @andrewfurey21 6 лет назад

      He meant highest index in the array

  • @omsatpathy5455
    @omsatpathy5455 2 года назад

    Can someone please provide the C++ code?

  • @geoffwagner4935
    @geoffwagner4935 Год назад

    "try and guess which ball the cup is under" swap. this could become an embarrassing game with this guy, first he explains it tells you how, then asks which cup the ball is under.

  • @DanielSantoAngel
    @DanielSantoAngel 8 лет назад

    You have a 15 inch retina macbook pro don't you?

  • @jaidanbalea2629
    @jaidanbalea2629 8 лет назад +1

    I read redraw (re draw)
    As red raw
    😂

  • @ranielgarcia8685
    @ranielgarcia8685 4 года назад

    Is it better to use recursion for this? like the implementation in StackOverflow (First answer):
    stackoverflow.com/questions/9960908/permutations-in-javascript

    • @KnakuanaRka
      @KnakuanaRka 4 года назад +1

      raniel garcia Permutations via recursion are fantastic for something called backtracking: basically, if it’s possible to test the partial permutations for validity, then you can do that with each partial order you generate, and if it’s invalid, you can avoid generating all the full permutations that come from it, since you know they will be invalid. You can use this to solve sudokus, N-queens problems, etc ridiculously fast.

  • @kms8320
    @kms8320 4 года назад

    mumbai, delhi, etc.

  • @pdcx
    @pdcx 7 лет назад

    gosh..permutation algorithm from misof....hes so famous in competitive programming

  • @HitchcockTheBirds
    @HitchcockTheBirds 8 лет назад

    can't you just start at 0, then find the next largest number, then find the next largest number, etc. rather than loop through all the possibilities?

    • @HitchcockTheBirds
      @HitchcockTheBirds 8 лет назад +1

      var x = vals[0]
      While !vals.length = 0
      for(var i = 0, i < vals.length, i++)
      if (x < vals[i]) {
      x = vals[i]
      // i don't know javascript at all but now you can remove x from the array and put it into a new array, then keep doing this until vals doesn't have a length
      i think...
      I'm probably wrong tho

    • @TheCodingTrain
      @TheCodingTrain  8 лет назад +1

      Yes, this is known as a "selection sort" and would work for getting the array in sorted order (but not for going through all the permutations of the array.)

    • @HitchcockTheBirds
      @HitchcockTheBirds 8 лет назад

      Daniel Shiffman oh ok. thank you!

  • @Jkauppa
    @Jkauppa 3 года назад

    "it wasnt me, it was i in j"

    • @Jkauppa
      @Jkauppa 3 года назад

      b in c, that is be in christ

    • @Jkauppa
      @Jkauppa 3 года назад

      if you dont attempt to get a goal, you dont have any errors

    • @Jkauppa
      @Jkauppa 3 года назад

      wrong order

  • @ritikkhatri
    @ritikkhatri 6 лет назад

    when he did the function call wrong, I was yelling at him !!!!!!!!!!!!!!!!!!!! So its kind of annoying sometimes, but still its entertaining

  • @bechirjamousi6696
    @bechirjamousi6696 4 года назад

    But the TSP needs to return back to the city he starts with! Am i right?

    • @KnakuanaRka
      @KnakuanaRka 4 года назад +1

      bechir jamousi Not in most versions of the problem, though that is also an interesting version.

  • @sarbjitgahra4667
    @sarbjitgahra4667 7 лет назад

    for i in range(0, len(a) -1):
    if (a[i] < a[i+1]):
    largestI = i
    doesn't this also satisfy for 3 and 4 since 3 is less than i +1 .
    largestI should be 6 and a(largestI)=3
    can someone please enlighten me

    • @KnakuanaRka
      @KnakuanaRka 4 года назад

      Sarbjit Gahra No, he wants the last number that is less than the one after it, which here is 6 (6 < 8, while 8 > 4 > 3, so 6 is the last one).

  • @Transientpunk
    @Transientpunk 7 лет назад +3

    Should take 42 days to display all 10! possibilities.

    • @davislast7891
      @davislast7891 7 лет назад +4

      Correction:
      3628800 / 60 = Seconds
      60480 / 60 = Minutes
      1008 / 60 = Hours
      16.8 Hours total
      :) You forgot to divide by 60 since the program is running at 60 frames

  • @deansolistino
    @deansolistino 5 лет назад

    CocaCola🤣🤯

  • @fattysun1121
    @fattysun1121 3 года назад

    Come here from project euler

  • @Hyuts
    @Hyuts 6 лет назад

    14:43 #me endlessly

  • @evank6
    @evank6 5 лет назад

    i calculated how long it would take and that is 42 days lol
    u gonna wait 42 days or something??

  • @problemsolver3254
    @problemsolver3254 5 лет назад

    uk is best city

  • @firstphoton655
    @firstphoton655 7 лет назад

    how the fuck is he typing that fast

  • @novakingood3788
    @novakingood3788 3 года назад

    There really is nothing wrong in saying travelling salesman. Or saleswoman.

  • @pchelka_zh
    @pchelka_zh 2 года назад

    Чел на мефедроне

  • @harshvardhanpurohit6122
    @harshvardhanpurohit6122 5 лет назад

    who tf is this happy when they code ? smh.

  • @marsilv4319
    @marsilv4319 4 года назад

    lol anyone else think he's high?

  • @lirimkrasniqi3059
    @lirimkrasniqi3059 7 лет назад

    can you make a calculator

    • @megatrollsplit1282
      @megatrollsplit1282 7 лет назад

      Lirim Krasniqi I made a calculator in c ++.
      It takes 10 hours to me :(

  • @tehsimo
    @tehsimo 8 лет назад

    I didn't understand the concept of this video at all :(

    • @kamoroso94
      @kamoroso94 8 лет назад

      It's just about implementing an algorithm that generates permutations of an array.

    • @rob_h_se
      @rob_h_se 8 лет назад

      lol. sorry? Have you taken a higher level programming class/calc/discrete math?

    • @tehsimo
      @tehsimo 8 лет назад

      +Robert Hird no. didn't understand the reasoning for his combinations. just seemed like he was listing them all

    • @rob_h_se
      @rob_h_se 8 лет назад +1

      +tehsimo he was trying to list with the algorithm. in the last video he used the swapping technique to get all the possibilities. the problem with that is you need an extra variable that is your temp to store the date. extra variables take up memory, which isn't a problem with small data, but with big data it can become a problem. he is trying to make his program efficient to handle large amounts of data. remember factorials, so if he has 3 possible locations A,B,C, the number of possible routes is 3! (3x2x1) but let's say he has 1000 locations, that's 1000! (1000x999x998x...) possibilities. hope that makes sense, he is trying to make his program more efficient with the algorithm he is modeling with code. (did not proof read this, hope it makes sense)

    • @tehsimo
      @tehsimo 8 лет назад

      +Robert Hird ah that makes sense
      I kinds forgot about the problem of even doing the sort on the longer character sets. thank you ;) I was baffled by the technical names

  • @mrboyban
    @mrboyban 4 года назад

    ?

  • @thomaslippert9708
    @thomaslippert9708 5 лет назад

    I don't wanna grow up

  • @volekvolek1
    @volekvolek1 6 лет назад +1

    Dana Carvey teaching algorithms :) too much coffee , slow down a little bit.

  • @prateekdwivedi1473
    @prateekdwivedi1473 7 лет назад

    An alien dislike this awesome video (only one dislike )....

  • @vivsh.1999
    @vivsh.1999 5 лет назад

    are you single?

  • @ripsquid873
    @ripsquid873 8 лет назад +3

    plz make a platformer/physics engine plz

  • @alexchase1856
    @alexchase1856 6 лет назад

    The explanation was alright, but the implantation was too contrived. You should have rehearsed.