11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

6 Chap. 1 <strong>D<strong>at</strong>a</strong> <strong>Structures</strong> <strong>and</strong> <strong>Algorithm</strong>s• Are all d<strong>at</strong>a items inserted into the d<strong>at</strong>a structure <strong>at</strong> the beginning, or areinsertions interspersed with other oper<strong>at</strong>ions? St<strong>at</strong>ic applic<strong>at</strong>ions (where thed<strong>at</strong>a are loaded <strong>at</strong> the beginning <strong>and</strong> never change) typically require onlysimpler d<strong>at</strong>a structures to get an efficient implement<strong>at</strong>ion than do dynamicapplic<strong>at</strong>ions.• Can d<strong>at</strong>a items be deleted? If so, this will probably make the implement<strong>at</strong>ionmore complic<strong>at</strong>ed.• Are all d<strong>at</strong>a items processed in some well-defined order, or is search for specificd<strong>at</strong>a items allowed? “R<strong>and</strong>om access” search generally requires morecomplex d<strong>at</strong>a structures.1.1.2 Costs <strong>and</strong> BenefitsEach d<strong>at</strong>a structure has associ<strong>at</strong>ed costs <strong>and</strong> benefits. In practice, it is hardly evertrue th<strong>at</strong> one d<strong>at</strong>a structure is better than another for use in all situ<strong>at</strong>ions. If oned<strong>at</strong>a structure or algorithm is superior to another in all respects, the inferior onewill usually have long been forgotten. For nearly every d<strong>at</strong>a structure <strong>and</strong> algorithmpresented in this book, you will see examples of where it is the best choice. Someof the examples might surprise you.A d<strong>at</strong>a structure requires a certain amount of space for each d<strong>at</strong>a item it stores,a certain amount of time to perform a single basic oper<strong>at</strong>ion, <strong>and</strong> a certain amountof programming effort. Each problem has constraints on available space <strong>and</strong> time.Each solution to a problem makes use of the basic oper<strong>at</strong>ions in some rel<strong>at</strong>ive proportion,<strong>and</strong> the d<strong>at</strong>a structure selection process must account for this. Only after acareful analysis of your problem’s characteristics can you determine the best d<strong>at</strong>astructure for the task.Example 1.1 A bank must support many types of transactions with itscustomers, but we will examine a simple model where customers wish toopen accounts, close accounts, <strong>and</strong> add money or withdraw money fromaccounts. We can consider this problem <strong>at</strong> two distinct levels: (1) the requirementsfor the physical infrastructure <strong>and</strong> workflow process th<strong>at</strong> thebank uses in its interactions with its customers, <strong>and</strong> (2) the requirementsfor the d<strong>at</strong>abase system th<strong>at</strong> manages the accounts.The typical customer opens <strong>and</strong> closes accounts far less often than heor she accesses the account. Customers are willing to wait many minuteswhile accounts are cre<strong>at</strong>ed or deleted but are typically not willing to waitmore than a brief time for individual account transactions such as a depositor withdrawal. These observ<strong>at</strong>ions can be considered as informal specific<strong>at</strong>ionsfor the time constraints on the problem.It is common practice for banks to provide two tiers of service. Humantellers or autom<strong>at</strong>ed teller machines (ATMs) support customer access

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

Saved successfully!

Ooh no, something went wrong!