Discussion
Consider what TreeSet offers beyond the Set interface. Which statement is correct?
Answer: B
Correct answer: Navigation methods such as first, last, higher and lower.
TreeSet implements NavigableSet, so beyond the plain Set contract it offers first, last, higher, lower, ceiling, floor and the range views headSet, tailSet and subSet. What it gives up is speed: operations are logarithmic rather than constant time, because the elements are held in a balanced tree rather than hashed. It is not synchronized, and every set rejects duplicates.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development