CS 105 Lecture Notes - Lecture 11: Bubble Sort, Big Data, Merge Sort
11
CS 105 Full Course Notes
Verified Note
11 documents
Document Summary
How do i search for a string inside an array: var s = carrot , var fruits = [ apple", banana ], for (var i = o; i < fruits. length; i++) If (s =: function linearsearch(s, list, for (var i = o; i < fruits. length; i++) Linear search: move sequentially trough an array, checking each element for a match. If the length of the array is. : 100: check up to 100 elements, 1000: check up to 1000 elements. Look at an element in the center of an array. Remove the half of the array where the element would not be. If the length of the array is : 9: up to 3 comparisons, 18: up to 4 comparisons, 7,000,000,000: only 33 comparisons! Look at an element in the center of a sorted array. Remove the half of the array where the element would not exist.