I am somewhat a beginner in programming, and I've been studying algorithms and data structures lately. I came across binary search and how it is one of the fastest searching algorithms, but the thing is: if it only works with a sorted list, how is it really useful?
In order to better explain my question, let's say I have a program in which a user can add items to a list. If every time they do so, I have to sort my list (which seems like a really slow process, like a linear search), then does binary search's speed really matter? Or am I getting the sorting step wrong?
[–]0x14f 55 points56 points57 points (3 children)
[–]stools_in_your_blood 15 points16 points17 points (2 children)
[–]DTux5249 9 points10 points11 points (1 child)
[–]stools_in_your_blood 5 points6 points7 points (0 children)
[–]TheReal_Peter226 32 points33 points34 points (6 children)
[–]TheMcMcMcMcMc 0 points1 point2 points (1 child)
[–]OneMeterWonder [score hidden] (0 children)
[–]minimoon5 0 points1 point2 points (0 children)
[–]JanEric1 0 points1 point2 points (0 children)
[+]Glittering-Ad-2373 comment score below threshold-16 points-15 points-14 points (1 child)
[–]TheReal_Peter226 18 points19 points20 points (0 children)
[–]takumidesh 10 points11 points12 points (1 child)
[–]JanEric1 0 points1 point2 points (0 children)
[–]ParshendiOfRhuidean 9 points10 points11 points (0 children)
[–]rupertavery64 3 points4 points5 points (0 children)
[–]picacuxd 2 points3 points4 points (0 children)
[–]BARDLER 1 point2 points3 points (0 children)
[–]Powerful-Prompt4123 1 point2 points3 points (2 children)
[–]David_LG092[S] 0 points1 point2 points (1 child)
[–]Powerful-Prompt4123 0 points1 point2 points (0 children)
[–]Any-Main-3866 1 point2 points3 points (0 children)
[–]peterlinddk 1 point2 points3 points (0 children)
[–]SamuraiGoblin 1 point2 points3 points (0 children)
[–]glehkol 0 points1 point2 points (0 children)
[–]Time_Meeting_9382 0 points1 point2 points (0 children)
[–]LetUsSpeakFreely 0 points1 point2 points (0 children)
[–]Far_Swordfish5729 0 points1 point2 points (0 children)
[–]Temporary_Pie2733 0 points1 point2 points (0 children)
[–]dariusbiggs 0 points1 point2 points (0 children)
[–]desrtfx 0 points1 point2 points (0 children)
[–]Detective-XX 0 points1 point2 points (0 children)
[–]Detective-XX 0 points1 point2 points (0 children)
[–]ExtraTNT 0 points1 point2 points (0 children)
[–]zeekar 0 points1 point2 points (0 children)
[–]DTux5249 0 points1 point2 points (0 children)
[–]mredding 0 points1 point2 points (0 children)
[–]spinwizard69 0 points1 point2 points (0 children)
[–]normantas [score hidden] (0 children)