Data Structures and Algorithm Analysis in C++ (3rd Edition)

Data Structures and Algorithm Analysis in C++ (3rd Edition)

Language: English

Pages: 586

ISBN: 032144146X

Format: PDF / Kindle (mobi) / ePub

In this text, readers are able to look at specific problems and see how careful implementations can reduce the time constraint for large amounts of data from several years to less than a second. Class templates are used to describe generic data structures and first-class versions of vector and string classes are used. Included is an appendix on a Standard Template Library (STL). This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amount of efficiency. Readers should have some knowledge of intermediate programming, including topics as object-based programming and recursion, and some background in discrete math.

Operating Systems: Internals and Design Principles (6th Edition)

Concise Guide to Databases: A Practical Introduction (Undergraduate Topics in Computer Science)

Windows 7 Device Driver (Addison-Wesley Microsoft Technology Series)















behavior that allowed default copy operations even if a destructor was written. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class IntCell { public: explicit IntCell( int initialValue = 0 ) { storedValue = new int{ initialValue }; } int read( ) const { return *storedValue; } void write( int x ) { *storedValue = x; } private: int *storedValue; }; Figure 1.16 Data member is a pointer; defaults are no good 33 34 Chapter 1 1 2 3 4 5 6 7 8 9 10 11 12 Programming: A General Overview int f( ) { IntCell a{ 2

operations that were introduced in C++11. r Chapter 7 now contains material on radix sort, and a new section on lower-bound proofs has been added. Sorting code makes use of move operations that were introduced in C++11. r Chapter 8 uses the new union/find analysis by Seidel and Sharir and shows the O( M α(M, N) ) bound instead of the weaker O( M log∗ N ) bound in prior editions. r Chapter 12 adds material on suffix trees and suffix arrays, including the linear-time suffix array construction

std::swap( theSize, rhs.theSize ); std::swap( theCapacity, rhs.theCapacity ); std::swap( objects, rhs.objects ); return *this; } Figure 3.7 vector class (Part 1 of 2) 3.4 Implementation of vector 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 void resize( int newSize ) { if( newSize > theCapacity ) reserve( newSize * 2 ); theSize = newSize; } void reserve( int newCapacity ) { if( newCapacity < theSize ) return; Object *newArray = new Object[ newCapacity ]; for( int k = 0; k <

performing the restructuring described above is to perform single rotations, bottom up. This means that we rotate every node on the access path with its parent. As an example, consider what happens after an access (a find) on k1 in the following tree: 4.5 Splay Trees k5 k4 F k3 E k2 D k1 A B C The access path is dashed. First, we would perform a single rotation between k1 and its parent, obtaining the following tree: k5 k4 F k3 E k1 D k2 C A B Then, we rotate between k1 and k3 ,

a name), and that a record is 256 bytes. We assume this does not fit in main memory and that we are 1 of 20 users on a system (so we have 1/20 of the resources). Thus, in 1 sec we can execute many millions of instructions or perform six disk accesses. The unbalanced binary search tree is a disaster. In the worst case, it has linear depth and thus could require 10,000,000 disk accesses. On average, a successful search would require 1.38 log N disk accesses, and since log 10000000 ≈ 24, an average

Download sample