CS 1337 Lecture Notes - Lecture 19: Binary Search Algorithm, Iterator

18 views2 pages

Document Summary

* a set that can contain duplicate values. * find returns an iterator to an instance of the value. * equal_rang() member function returns a range with multiple elements. * the algorithms provide functionality on a range of elements in a container. * a range starts with an iterator and ends one past the end of the range of interest. * iterator1 and iterator2 - beginning and end of a range. * iterator3 is the beginning of the second range. * returns true if the second range is a permution of the first range. * m. is_permutation(m. begin(), m. begin()+2, m. rbegin(), 5); void doubleval(int& n) { bool iseven(int& n) { int main() { //auto p = m. equal_range(3); n *= 2; return ! (n % 2); //p. first; set m = {1, 2, 2, 3, 3, 3, 4, 5, 6}; sort(m. cbegin(), m. cend()); //if it"s sorted, use binary search cout << binary_search(m. begin(), m. end(), 5) < endl;

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