Over 10 Million Study Resources Now at Your Fingertips


Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Language:EN
Pages: 2

The basic operation look the item the middle the range

CHAPTER 7. ARRAYS 349

above contain values that are greater than or equal to 93. These locations can be eliminated as possible locations of the number 42.

*

satisfies A[i] == N.

If N is not in the array, then the

* return value is -1.

// At this point, highestPossibleLoc < LowestPossibleLoc, // which means that N is known to be not in the array. Return // a -1 to indicate that N could not be found in the array.

return -1;

Association lists are very widely used in computer science. For example, a compiler has to keep track of the location in memory associated with each variable. It can do this with an association list in which each key is a variable name and the associated value is the address of that variable in memory. Another example would be a mailing list, if we think of it as

associating an address to each name on the list.

The data for a phone directory consists of an array of type PhoneEntry[ ] and an integer variable to keep track of how many entries are actually stored in the directory. The technique of “dynamic arrays” (Subsection 7.3.2) can be used in order to avoid putting an arbitrary limit on the number of entries that the phone directory can hold. Using an ArrayList would be another possibility. A PhoneDirectory class should include instance methods that implement the “get”and “put” operations. Here is one possible simple definition of the class:

/**
* A PhoneDirectory holds a list of names with a phone number for * each name. It is possible to find the number associated with * a given name, and to specify the phone number for a given name.

}

private PhoneEntry[] data; private int dataCount;

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Payment
Make payment
Document download
Download File
PageId: ELIAE18E62
img
Uploaded by :
DKDRlQ5b
Page 1 Preview
the basic operation look the item the middle the r
Sell Your Old Documents & Earn Wallet Balance