Embed presentation
Download as PDF, PPTX

![O(n) - Linear Time var input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] function linearSearch(key) { for (var i = 0; i < input.length; i++) { if (input[i] === key) return i } return null }](https://image.slidesharecdn.com/algorithms-150924060822-lva1-app6891/75/Algorithms-2-2048.jpg)
![O(log n) - Logarithmic Time var input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] function binarySearch(key, imin, imax) { var midIndex = (imin + imax) / 2 var midNumber = input[midIndex] if (midNumber > key) { binarySearch(key, imin, midIndex - 1) } else if (midNumber < key ) { binarySearch(key, midIndex + 1, imax) } else { return midIndex } }](https://image.slidesharecdn.com/algorithms-150924060822-lva1-app6891/75/Algorithms-3-2048.jpg)




This document discusses Big O notation and time complexity of algorithms. It introduces common time complexities like O(n) linear time, O(log n) logarithmic time, and O(n^2) quadratic time. Examples are given of linear search which is O(n) and binary search which is O(log n). Common sorting algorithms are also listed like insertion sort, bubble sort, quick sort, merge sort, and selection sort along with their time complexities.

![O(n) - Linear Time var input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] function linearSearch(key) { for (var i = 0; i < input.length; i++) { if (input[i] === key) return i } return null }](https://image.slidesharecdn.com/algorithms-150924060822-lva1-app6891/75/Algorithms-2-2048.jpg)
![O(log n) - Logarithmic Time var input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] function binarySearch(key, imin, imax) { var midIndex = (imin + imax) / 2 var midNumber = input[midIndex] if (midNumber > key) { binarySearch(key, imin, midIndex - 1) } else if (midNumber < key ) { binarySearch(key, midIndex + 1, imax) } else { return midIndex } }](https://image.slidesharecdn.com/algorithms-150924060822-lva1-app6891/75/Algorithms-3-2048.jpg)


