Top 7 Algorithms for Coding Interviews Explained SIMPLY

Поділитися
Вставка
  • Опубліковано 16 тра 2024
  • Today we'll be covering the 7 most important algorithms you need to ace your coding interviews and land a job as a software engineer. We'll be showing visualizations, common uses, and time complexity. Hope you enjoy!
    📘 Chapters
    0:00 - Intro
    0:57 - Binary Search
    3:43 - Depth-First Search
    6:39 - Breadth-First Search
    9:13 - Insertion Sort
    10:57 - Merge Sort
    12:52 - Quick Sort
    15:57 - Greedy
    🔗 Resources
    Data Structures Video - • Top 7 Data Structures ...
    Big O Video - • Big O in 2 Minutes
    Recursion Video - • Recursion in 2 Minutes
    Coding Interviews at FAANG Video - • Software Engineering I...
    🎵 Music
    Music Courtsey of Epidemic Sound
    Wizzle - Guustavv
    Slapperoni Pizza - Jobii
    Unfettered - Jobii
    At My Own Pace - Sarah, the Illstrumentalist
    Deadlines - Dylan Sitts
    Sleepy + Hungry - baegel
    Tea Tree - Jobii
    Taargus - Jobii
    Pick Up Your Phone Please - baegel
    Brontosaurus - Dylan Sitts
    #coding #softwareengineer #algorithm
  • Наука та технологія

КОМЕНТАРІ • 147

  • @Codebagel
    @Codebagel  Рік тому +47

    Hey guys! Sorry for lack of uploads lately, hopefully this 20 MINUTE comprehensive guide to algorithms makes up for it a bit! Please like and share with friends, I worked really hard on it and want it to help lots of people!

    • @ReluctantSpirit
      @ReluctantSpirit Місяць тому

      This video is one of the finest and well defined educational video on algorithms.

  • @shadowrl7637
    @shadowrl7637 2 місяці тому +71

    Algorithms
    Binary Search:
    - Used to find a specific element in a sorted list efficiently.
    - Inefficient: O(n) for linear search, incrementally guessing from start to end.
    - Efficient: O(log2(n)) for binary search, repeatedly dividing the search interval in half until the correct element is found.
    Depth-First Search (DFS):
    - Begins at the root node and explores as far as possible along each branch before backtracking.
    - Utilizes a visited array to track already visited nodes.
    - Continues backtracking until all nodes are visited.
    - Real-life example: Solving a maze by systematically exploring paths until the exit is found.
    Breadth-First Search (BFS):
    - Looks at every node at one level before going down to the next level.
    - Utilizes a visited array to track already visited nodes and a queue to keep track of neighbors.
    - Begins at the root node and adds it to the visited array and all its connected nodes to the queue, then continues to explore nodes level by level.
    - Real-life example: Chess algorithms predict the best move by exploring possible moves at each level of the game tree.
    - Runtime: O(V + E), where V is the number of vertices and E is the number of edges.
    Insertion Sort:
    - Examine’s each element in the list, comparing it with the previous elements and shifting them to the right until the correct position for insertion is found.
    - Simple sorting algorithm suitable for small datasets or nearly sorted arrays.
    - Runtime:
    - Best case: O(n) when the list is already sorted.
    - Worst case: O(n^2) when the list is sorted in reverse order.
    - Efficient for small or nearly sorted lists, but inefficient for large unsorted lists.
    Merge Sort:
    - A divide-and-conquer sorting algorithm that breaks the problem into smaller subproblems and solves them recursively.
    - Starts by splitting the array into halves recursively until each subarray consists of single elements.
    - Merges pairs of subarrays by comparing elements and placing them in sorted order.
    - Continues merging subarrays until the full array is sorted.
    - Runtime: O(n log(n)) in both best and worst cases, making it efficient for large datasets.
    Quick Sort:
    - A complex sorting algorithm that follows the divide-and-conquer approach and is recursive.
    - Selects a pivot element, ideally close to the median, and partitions the list into two sublists: one with elements greater than the pivot and the other with elements less than the pivot.
    - Continues the process recursively on each sublist until the entire list is sorted.
    - Utilizes a pivot element that is moved to the end of the list, with pointers positioned at the leftmost and rightmost elements.
    - Compares the elements pointed to by the left and right pointers, swapping them if necessary, until the pointers cross.
    - Once the pivot is correctly positioned, the process repeats on the sublists.
    - Runtime:
    - Best case: O(n log(n)), when the pivot consistently divides the list into approximately equal halves.
    - Worst case: O(n^2), when the pivot selection consistently results in unbalanced partitions.
    Greedy Algorithm:
    - A problem-solving approach that makes the locally optimal choice at each stage with the hope of finding a global optimum.
    - May not always guarantee an optimal solution but is often simple and efficient.
    - Real-life example: Finding the shortest path in a weighted graph using Dijkstra's algorithm, where at each step, the algorithm selects the vertex with the smallest distance from the source.

    • @Leonhart_93
      @Leonhart_93 Місяць тому

      Good work, works for adding to quick documentation

    • @ptd3v
      @ptd3v Місяць тому +1

      My man

    • @Lu3ck
      @Lu3ck Місяць тому

      Not all hero’s wear capes

  • @bb-xj9ed
    @bb-xj9ed 7 місяців тому +188

    thank you bro, my gf broke up with me so i have nothing but to learn algos, your video made me laugh at the greedy algo part. thank you u earned a sub

    • @vedagyasharma5438
      @vedagyasharma5438 3 місяці тому +10

      stay strong brother!

    • @ryostyles9904
      @ryostyles9904 3 місяці тому +6

      Great choice bro

    • @airman122469
      @airman122469 3 місяці тому +5

      Sounds like you just need some greedy algos and a creative application of the traveling salesman problem.
      (Routes through all bars, and pickup techniques)

    • @kaushalrautela6
      @kaushalrautela6 3 місяці тому +13

      Broke up and still leveling up GOD mode acticated 🤖

    • @wadzanaikanongovere4798
      @wadzanaikanongovere4798 3 місяці тому +2

      Looks like someone was greedy 😂😂😂😂

  • @originallyme135
    @originallyme135 6 місяців тому +7

    This video is amazing! I was so surprised when I went to subscribe that you only had 5k subscribers, from the quality of these videos I expected at least 100k! Thank you for your awesome work, you really helped me a lot

  • @tamalpaul4928
    @tamalpaul4928 2 місяці тому +5

    Brother, You gotta be my best teacher on youtube. You making lesson just the way I want. You start a topic by first being pause. Then continue with the easiest way possible.
    Please make more videos like these.

  • @Redyf
    @Redyf 3 місяці тому +45

    Code examples would help a lot too, great video

  • @i_am_spex6312
    @i_am_spex6312 4 місяці тому +1

    Dude , you explain so well. Thank you

  • @thaisb.7708
    @thaisb.7708 2 місяці тому

    Amazing content, very clearly explained and the illustrations helped a lot, thank you for sharing.

  • @antonthordarson3610
    @antonthordarson3610 Місяць тому

    This is great, Very well explained and straight to the point. Way better than any teacher I have seen explain this..

  • @user-vr3pt7yp9d
    @user-vr3pt7yp9d День тому +1

    This vid is doing quite well for explaining,appreacting your hard work.

  • @ngocchaunguyen1195
    @ngocchaunguyen1195 3 місяці тому +1

    This is an incredible video. I didn't understand most algorithms as a student, because I focused on theories and code. This video helps me save time in understanding these popular algorithms. Indeed, I rarely use them in my work, it is simply because we don't have many situations to apply. I usually use linear search in JavaScript. there was a time I had a problem with sort of 10,000 objects. I have to use the binary-sort library without understanding. Once again, thanks for your video.

  • @MadhuKumar-zi4qp
    @MadhuKumar-zi4qp 3 місяці тому +1

    easy to understand bro.. great. Thanks!

  • @mitkomilev4690
    @mitkomilev4690 3 місяці тому

    Good explanation, thank you. A small note for the quicksort -
    keep in mind that the unshift operation at 13:44 is really computational costly as you will have to unshift all elements to the left. It is better to just swap the chosen pivot element with the last one.

  • @khndokar2382
    @khndokar2382 4 місяці тому

    Love your videos ! please do more, ive learned so much

  • @omgh8287
    @omgh8287 Рік тому +12

    I enjoyed the explanations and presentation about the different important algorithms in this video. I am subscribing to this channel in the hope of similar good content in the future. Wish you the best with growing your channel :)

    • @Codebagel
      @Codebagel  Рік тому +1

      Thanks so much! I’m glad you enjoyed it. Content will definitely continue to get even better, so I’m happy you’re going to stick around :)

  • @hassanriaz4274
    @hassanriaz4274 14 днів тому +1

    Thank you so much for this detailed video bro👊👊

  • @durantburner7428
    @durantburner7428 Рік тому +4

    With content like this you'll be big in no time, excited for what's to come!

    • @Codebagel
      @Codebagel  Рік тому +1

      Thank you so much! I really appreciate the support!

  • @katurr_Real_Estate
    @katurr_Real_Estate 9 днів тому +1

    This is the best explained algorithm I came across

  • @mesta3329
    @mesta3329 3 місяці тому

    Great job bro. It was very interesting & easy to understant

  • @NormieDead
    @NormieDead Місяць тому

    thank you soo much.
    i know this could have taken so much affrords to make .

  • @yuqingpeng6523
    @yuqingpeng6523 Рік тому +1

    Very detailed explanation as always! I learnt a lot, thank you so much!!

    • @Codebagel
      @Codebagel  Рік тому

      You’re welcome! Thanks for the kind words :)

  • @a.rohimsama7222
    @a.rohimsama7222 Місяць тому

    Great explanation! Thank you

  • @akshaypatelindia
    @akshaypatelindia Місяць тому

    Really impressive contents mate keep going . appreciate you'r contents and efforts. :)

  • @wlqpqpqlqmwnhssisjw6055
    @wlqpqpqlqmwnhssisjw6055 Рік тому +5

    You should explain how machine learning works and more of that types of videos too ,your explanation is on another level

    • @Codebagel
      @Codebagel  Рік тому +4

      Thanks so much! I’ll definitely tackle machine learning at some point in the near future, it’s on the list of future videos!

  • @simonetumolillo9400
    @simonetumolillo9400 Рік тому +1

    I love the fact that you took the time for writing the outcome numbers of TSP in the comments haha. Nice work as always, keep it up!

    • @Codebagel
      @Codebagel  Рік тому

      Haha yeah, to me that’s such a strong way to explain why certain algorithms are used. I’m glad you enjoyed!

  • @vasylshkrum8007
    @vasylshkrum8007 2 місяці тому

    Great job, mate!

  • @Antariksha
    @Antariksha Рік тому +1

    Please keep going, your explanations are on point! Subscribed.

  • @franciagarciaromero2589
    @franciagarciaromero2589 2 місяці тому

    Loved this, please make more videos

  • @ShengjunSun-on1jr
    @ShengjunSun-on1jr 18 днів тому

    Great contents! Thank you!

  • @MeditateRelaxEtcetera
    @MeditateRelaxEtcetera 2 місяці тому

    Great explanation!👍

  •  3 місяці тому

    Amazing video!! thank you.

  • @abyss_v
    @abyss_v 3 місяці тому

    Great video, helped me a lot

  • @ektasingh5967
    @ektasingh5967 23 дні тому

    I love all of your videos. Amazing they are. Please make videos on System Design as well.

  • @ankiitamalik
    @ankiitamalik 2 місяці тому

    Thanks🙏 very clear explanation

  • @ann.z.z.
    @ann.z.z. Місяць тому

    Thank you so much, amazing content

  • @ranvirkumar108
    @ranvirkumar108 7 місяців тому

    Great work men...

  • @puneetparashar2935
    @puneetparashar2935 26 днів тому

    Love your videos.❤

  • @seannaeger9563
    @seannaeger9563 3 місяці тому

    I've been trying to understand these concepts for ages. Your videos rock! Even if you spell neighbor wrong. 🙂

  • @catarinaivf
    @catarinaivf 6 місяців тому

    It was really great! Thanks

  • @bonginscandinavia
    @bonginscandinavia Місяць тому

    Great explaination. 👍

  • @user-xs9el5ek6n
    @user-xs9el5ek6n 2 місяці тому

    Good work bro keep on doing 👍

  • @chamarr
    @chamarr Рік тому +2

    goated video🐐🐐

  • @LastShade
    @LastShade 8 днів тому

    For the traveling salesman, I would use a set of controlled variables that you could programmatically cycle through to optimize results. One example would be a tolerance on overlapping routes. Cycle through 0-10 overlaps and calculate results. Compare results. As long as you keep the number of variables and variable values low, it’s a great way to squeeze out extra optimization.

  • @therealzeon
    @therealzeon Рік тому +2

    I know ur working hard my guy but keep pushing you'll breeze to 100 k by the end of the year dw 💪🧠
    Keep up the amazing content man

    • @Codebagel
      @Codebagel  Рік тому

      Thanks so much! Been such a grind lately with everything going on, but definitely going to start pumping out more videos so that’s good :)

  • @TrishalWalia
    @TrishalWalia 29 днів тому

    Best Explanation!

  • @voegel
    @voegel Рік тому +1

    Thank you for this comprehensive video! 21 minutes is a good length. Btw, did your job interviews went well?

    • @voegel
      @voegel Рік тому +1

      Oh and here is some advice that I think might be helpful: I know music in videos is vastly used, but mostly it‘s a bit too much. The music in this video was okay, but I actually liked the music-free videos more. They *seem* to me better structured/clean. I know this video has the same great content as always, but (maybe it‘s just me) I have problems following you. Idk, maybe I‘m wrong and using music is a good idea ^^ Just a friendly tip :)

    • @Codebagel
      @Codebagel  Рік тому

      @@voegel thank you for the feedback! I’ve been experimenting a bit with the music, but I get that it might be a bit hard to follow with it. I’m going to experiment a bit with audio levels/not including it at all, thanks for letting me know :)

  • @FaheemQazi
    @FaheemQazi 3 місяці тому +1

    Hi, i really like the graphical representation of these topics in simple manner, however i think that @10:40 the explanation of bubble sort is mentioned as insertion sort.

  • @hlubradio2318
    @hlubradio2318 18 днів тому

    Thanks I'll subscribe for your hard work. Now to implement them in Python.

  • @khndokar2382
    @khndokar2382 5 місяців тому

    can you please upload the separate data structure videos? i really liked the hashmap one

  • @user-de4yn8rv9l
    @user-de4yn8rv9l 4 місяці тому

    I really wonder how this video hasn't blown up after a whole year

  • @coffeewithjava4
    @coffeewithjava4 14 днів тому

    Explaining Data Structures with Code Examples would be more beneficial. This video is informative too.

  • @rutwikpatil8491
    @rutwikpatil8491 17 днів тому

    Amazing video !!!

  • @arthurmorgan718
    @arthurmorgan718 Рік тому +4

    Your content is literally quality over quantity , keep the good work man

    • @Codebagel
      @Codebagel  Рік тому +1

      Thank you! I really appreciate it :)

  • @aaryankedia3919
    @aaryankedia3919 9 місяців тому

    Hey, Thanks for the video.
    I am a final year CSE student and I have the placement season starting soon. I am left with a lot of DSA. Could you suggest me with some tips?

  • @llmll6447
    @llmll6447 Місяць тому

    Very good explanation

  • @sujeet4410
    @sujeet4410 Рік тому +2

    I was here before this channel exploded. Keep the contents coming.

    • @Codebagel
      @Codebagel  Рік тому

      Thanks so much Sujeet! I’ll keep working towards making better and better content for you to enjoy!

  • @K9Megahertz
    @K9Megahertz 2 місяці тому +1

    You don't really need to keep track of the visited nodes in a DFS. You just visit the left node first and then the right node, or in the case of a tree with n children per node, just visit them in sequential order. At least if you're doing it recursively. Maybe there's a reason to keep track of the nodes outside of the recursion for other purposes but not for the actual traversal.

  • @servantofthelord8147
    @servantofthelord8147 7 місяців тому

    Thank you :)

  • @LucasNunes-vg6zk
    @LucasNunes-vg6zk 3 місяці тому

    Excelent content 🚀🚀

  • @aninditabatra3810
    @aninditabatra3810 8 місяців тому +1

    great video

  • @nurfuis
    @nurfuis 2 місяці тому

    Thank you for the video =)

  • @FunnySubmarine-ij4zk
    @FunnySubmarine-ij4zk 3 місяці тому

    Thank you

  • @kikocassola
    @kikocassola 3 місяці тому

    Great job 👏👌😉

  • @tony310430
    @tony310430 2 місяці тому

    no hay un video que te enseñe todo, al final debemos consumir mucho contenido de calidad e intentar quedarnos con lo positivo de dicho contenido para internalizarlo y realmente poder implementarlo de manera adecuada. Este video a mi criterio cumple con el criterio de ser un video de calidad.... No comenté en inglés porque siento que los hispano hablantes que no son angloparlantes merecen también hacerse notar en las cuentas de tecnología donde usualmente solamente se habla inglés

  • @Math_kru_earng
    @Math_kru_earng Місяць тому

    thank you!

  • @sreyakarmakar4248
    @sreyakarmakar4248 2 місяці тому

    Dynamic Programming left the chat..🏃🏻‍♂️🏃🏻‍♂️
    PS: amazing visuals & explanations. Thanks ❤

  • @kwanxyz
    @kwanxyz День тому

    Nice job

  • @austinkry
    @austinkry 2 місяці тому

    Man, this just helped me so much in ways I can't even explain. Took the entire time taking notes and all. Really appreciate the hard work that was put into this, like and sub from me cheers!

  • @varanasikirankumar8501
    @varanasikirankumar8501 2 місяці тому

    Best video ever watched

  • @Rajukumarmsbsndb
    @Rajukumarmsbsndb 3 місяці тому

    Hey! It was awesome.

  • @hlubradio2318
    @hlubradio2318 18 днів тому

    This so weird. I leaned all these in 1994 to 1997 but never heard of greedy or maybe I did but I certainly remembered the shortest path algorithm which is greedy

  • @Daniel-jt3dn
    @Daniel-jt3dn 2 місяці тому

    Excelente

  • @deniz.7200
    @deniz.7200 3 місяці тому

    DFS and BFS require sorted binary trees to operate, right?

  • @voegel
    @voegel Рік тому +1

    Hey, I‘m wondering if you are still planning to make a video about how to pass the resume screening? That might be quite interesting :)

    • @Codebagel
      @Codebagel  Рік тому

      Yes, it’s actually the next video coming out! I’m hoping to get it finished and uploaded for Monday! :)

    • @Codebagel
      @Codebagel  Рік тому

      Okay so I didn’t finish it in time for Monday haha, had 2 last minute interviews come up. It will be out by tomorrow though, guaranteed!

  • @oulaoula349
    @oulaoula349 Місяць тому

    Travelling salesman problem is à good support to practise genetic algorithms

  • @beeTechSE
    @beeTechSE Місяць тому

    Wait for Dynamic programming video 😁🤘

  • @archivegaming9112
    @archivegaming9112 2 місяці тому

    nice !!!

  • @shawnedwards5369
    @shawnedwards5369 2 місяці тому

    What's with the use of arrays over stacks?

  • @YoYouWildinBro
    @YoYouWildinBro Рік тому +1

    When I get my coding gig in the future, I'm gonna look back at these videos and think "This is why I landed this job".

    • @Codebagel
      @Codebagel  Рік тому +1

      Wow, you have no idea how awesome that is to hear. Thank you so much for that, and I hope I can continue to keep helping you on your journey towards breaking into the tech industry!

    • @itsaaron6423
      @itsaaron6423 Рік тому

      I learnt one and it never feels enough . 😅🥲

  • @chamarr
    @chamarr Рік тому +1

    can you possible make a video on how to code up these algorithms? that is what i have the most trouble with

    • @Codebagel
      @Codebagel  Рік тому +1

      Yes! That’s what’s coming out next! I’ll be doing kind of 8-10 minute in-depth videos explaining how the code works, and how to solve problems of using the algorithm! Stay tuned :)

    • @chamarr
      @chamarr Рік тому +1

      @@Codebagel yessir goated youtuber🐐

  • @kvelez
    @kvelez 6 місяців тому

    Cool video.

  • @rondlh20
    @rondlh20 27 днів тому +1

    11:48 How does this sorting work in detail?

  • @muhannadalsabbagh8956
    @muhannadalsabbagh8956 8 місяців тому +2

    Really appreciate your work but you are wrong about the insertion sort algorithm you explained the bubble sort insertion sort will compare each number with the previous numbers and put it in place. Hope you will fix the video

    • @panthrax555
      @panthrax555 3 місяці тому +1

      I came here to say this. I've not heard of insertion sort before, this is definitely a Bubble sort.

  • @egsnowindy
    @egsnowindy Місяць тому

    Thanks for the video.
    Note: Merge sort is not properly explained.
    1. it requires creation of temporary arrays of size equal to the sorted array.
    2. the "merging" process itself is not highlighted in video.

  • @mydream8513
    @mydream8513 4 місяці тому

    Bro i could gaurantee you that you can get a million sub in a year if u upload a video once per 3 days.

  • @ACBros_06
    @ACBros_06 Місяць тому

    Nice

  • @Sachin-je7ue
    @Sachin-je7ue 2 місяці тому

    Well explained but you mentioned binary search only works for sorted list but it is not true .It also works for unsorted.

  • @user-sp3ew1rs5m
    @user-sp3ew1rs5m 4 місяці тому

    I rly wonder how those algorithms would help me to be better in solving coding problems

  • @GenericInternetter
    @GenericInternetter 2 місяці тому

    Greedy Algorithms prevent Analysis Paralysis.
    Good for coding and good for life.
    Sometimes in life you gotta just pick the immediately most beneficial step and jump into it.

  • @tonyg861
    @tonyg861 2 місяці тому

    This is for the UA-cam algorithm!!

  • @aninditabatra3810
    @aninditabatra3810 22 дні тому

    🎉🎉

  • @GenericInternetter
    @GenericInternetter 2 місяці тому

    How can you magically know in advance the "median value" used in quick sort?

  • @phir9255
    @phir9255 4 місяці тому

    Is Introduction to Algorithms a good book?

  • @carlospena98
    @carlospena98 2 місяці тому +1

    Three fucking ads on a video ? I feel like I’m getting milked

  • @arkan7rb
    @arkan7rb 2 місяці тому

    i have a channel and i know how its time consuming specially wonderful videos like yours sir
    thank you in all languages of the world
    greetings from Yemen

  • @MarkyGoldstein
    @MarkyGoldstein 3 місяці тому

    Software engineers should first focus on real world problems, such as progressing standardizations and protocols, de-powerize monopolys, and then of course optimize

  • @VivanRangra
    @VivanRangra 3 місяці тому

    where is dynamic programming ?

  • @alabhyapandey2999
    @alabhyapandey2999 Місяць тому

    Greedy is hard!

  • @tskito7200
    @tskito7200 3 місяці тому

    Binary Litht

  • @siphiweparker6178
    @siphiweparker6178 5 місяців тому

    Im about to become a chess grand master with BFS