Java Data StructuresLesson 74Free preview
Java Algorithms
This lesson is part of Java · All levels
Summary
Collections classes provide a variety of ready-made algorithms for Collections, ranging from sequencing, searching, to computing. Using built-in algorithms is safer and more efficient than rewriting proven logic. Popular examples of commonly used are binarySearch, frequency, max, min, reverse, and shuffle.
Key points
- BinarySearch is only valid if the list is sorted first
- The negative value of binarySearch means the element does not exist, i.e. -(slip point) - 1
- Frequency(list, obj) calculates how many times objects appear in the list
- Max, min, reverse, and shuffle change or read the list directly
- Check if two collections do not share elements at all
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.