




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The importance of order in data structures and the efficiency gains of searching in ordered sets. It covers the concept of binary search and binary search trees, providing examples and code snippets in java. The text also touches upon generic methods and the comparable interface.
Typology: Study notes
1 / 8
This page cannot be seen from the preview
Don't miss anything!
public static final boolean contains(Comparable item, Comparable[] array,int n) { int low = 0; int high = n-1; while (low <= high) { int mid = (low+high) / 2; int compare = item.compareTo(array[mid]); if (compare < 0) { high = mid – 1; } else if (compare > 0) { low = mid + 1; } else { return true; } } return false; }
coldplay busted pink madonna U macy gray shakira LHS: value is “smaller” RHS: value is “larger” The concepts of “smaller” and “larger” are defined according to the data you are processing …
class EmptyTree extends SearchTree { protected boolean isEmpty() {} public boolean isEmpty() { return true; } … more methods } class NodeTree extends SearchTree { private Comparable data; private SearchTree left; private SearchTree right; protected NodeTree(Comparable item) { data = item; left = empty(); right = empty(); } public boolean isEmpty() { return false; } … more methods }