CS 105 Lecture Notes - Lecture 11: Bubble Sort, Big Data, Merge Sort

46 views3 pages
CS 105 Full Course Notes
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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents