Data Structures & Algorithms for Beginners - 5

Searching Algorithms

 


linear-search

1. Time

 BestWorst
Time ComplexityO(1)O(n)

 

2. Code

2.1 Example for Int

2.2 Example for String

 

 

binary-search

1. Time

 RecursiveLterative
Time ComplexityO(log n) 
Space ComplexityO(log n)O(1)

 

2. Code

2.1 Example for Int

 

2.2 Example for String

 

 

ternary-search

1. Time

 Big O Notation
Time ComplexityO(log 3 n)

 

2. Code

2.1 Example for Int

 

2.2 Example for String

 

 

jump-search

1. Time

 Big O Notation
Time ComplexityO(√n)

 

2. Code

 

 

exponential-search

1. Time

 Big O Notation
Time ComplexityO(log i)

 

2. Code (Need use Binary Search (Recursive))