© Elshad Karimov 2020
E. KarimovData Structures and Algorithms in Swifthttps://doi.org/10.1007/978-1-4842-5769-2_17

17. Choosing the Best Algorithm

Elshad Karimov1 
(1)
New York, New York, USA
 

We have learned different types of algorithms such as sorting, searching, and graph algorithms, and there are likely to be many possible algorithms which perform the same task. The question is, if we want to search for a value in the list, which type of searching algorithm do we have to choose? By analyzing various algorithms, we will study this question in this chapter.

There are many ways of comparing algorithms, but in this chapter, we will focus on time complexity and space complexity.
  • Time complexity: Required time for accomplishing the task

  • Space complexity ...

Get Data Structures and Algorithms in Swift: Implement Stacks, Queues, Dictionaries, and Lists in Your Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.