Please can someone tell when or why to use algorithms | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please can someone tell when or why to use algorithms

I know algorithms are for step-by-step plans of how you going to write your code. But I don't get the use of algorithms like bubble sort, selection etc.

6th Sep 2020, 11:51 AM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
2 Answers
+ 3
Everything you code, every single app even if it makes some basic calculations, is an algorithm. So yeah, you use them all of the time.. but as you saiid there are algorithms that are known and predefined, which you don't have to use,but they can significantly help you sometimes. Youll think of them once you get some more complex problems to solve 😊
6th Sep 2020, 10:26 PM
Kkristina
Kkristina - avatar
+ 1
Bubble sort and selection sort could be useful if you were forced to write a sort algorithm from scratch and efficiency wasn't a concern but this hardly ever happens. They are most often used for educational purposes to learn about algorithm design and properties of algorithms in general. After learning those simpler to understand sorting algorithms, more efficient quick sort and merge sort algorithms are usually explained. Bubble sort, selection sort are mostly useless in professional software development work because sorting is solved more efficiently in most programming languages. JavaScript's Array sort method, Python's sort and sorted functions are both much more efficient since they average O(n log n) time instead of O(n^2). Algorithms in general are used in every programming language, though. You're always writing "a sequence of steps to solve a problem". In other words, you're always writing an algorithm.
6th Sep 2020, 4:44 PM
Josh Greig
Josh Greig - avatar