12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

22 Chap. 1 <strong>Data</strong> <strong>Structures</strong> <strong>and</strong> <strong>Algorithm</strong>sterms of its input <strong>and</strong> output. Then define two different physical representationsfor strings.1.4 Define an ADT for a list of integers. First, decide what functionality yourADT should provide. Example 1.4 should give you some ideas. Then, specifyyour ADT in Java in the form of an abstract class declaration, showingthe functions, their parameters, <strong>and</strong> their return types.1.5 Briefly describe how integer variables are typically represented on a computer.(Look up one’s complement <strong>and</strong> two’s complement arithmetic in anintroduc<strong>to</strong>ry computer science textbook if you are not familiar with these.)Why does this representation for integers qualify as a data structure as definedin Section 1.2?1.6 Define an ADT for a two-dimensional array of integers. Specify preciselythe basic operations that can be performed on such arrays. Next, imagine anapplication that s<strong>to</strong>res an array with 1000 rows <strong>and</strong> 1000 columns, where lessthan 10,000 of the array values are non-zero. Describe two different implementationsfor such arrays that would be more space efficient than a st<strong>and</strong>ardtwo-dimensional array implementation requiring one million positions.1.7 Imagine that you have been assigned <strong>to</strong> implement a sorting program. Thegoal is <strong>to</strong> make this program general purpose, in that you don’t want <strong>to</strong> definein advance what record or key types are used. Describe ways <strong>to</strong> generalizea simple sorting algorithm (such as insertion sort, or any other sort you arefamiliar with) <strong>to</strong> support this generalization.1.8 Imagine that you have been assigned <strong>to</strong> implement a simple sequential searchon an array. The problem is that you want the search <strong>to</strong> be as general as possible.This means that you need <strong>to</strong> support arbitrary record <strong>and</strong> key types.Describe ways <strong>to</strong> generalize the search function <strong>to</strong> support this goal. Considerthe possibility that the function will be used multiple times in the sameprogram, on differing record types. Consider the possibility that the functionwill need <strong>to</strong> be used on different keys (possibly with the same or differenttypes) of the same record. For example, a student data record might besearched by zip code, by name, by salary, or by GPA.1.9 Does every problem have an algorithm?1.10 Does every algorithm have a Java program?1.11 Consider the design for a spelling checker program meant <strong>to</strong> run on a homecomputer. The spelling checker should be able <strong>to</strong> h<strong>and</strong>le quickly a documen<strong>to</strong>f less than twenty pages. Assume that the spelling checker comes with adictionary of about 20,000 words. What primitive operations must be implementedon the dictionary, <strong>and</strong> what is a reasonable time constraint for eachoperation?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!