0% found this document useful (0 votes)
38 views

Programming Challenges 14-14

This document discusses data structures and strings. Chapter 2 covers elementary data structures like stacks, queues, dictionaries, priority queues and sets. It also discusses object libraries in C++ and Java and includes programming examples and problems. Chapter 3 discusses strings, including character codes, representing strings, searching patterns in strings, manipulating strings, and string library functions. It also includes programming problems related to strings.

Uploaded by

Sandeep Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Programming Challenges 14-14

This document discusses data structures and strings. Chapter 2 covers elementary data structures like stacks, queues, dictionaries, priority queues and sets. It also discusses object libraries in C++ and Java and includes programming examples and problems. Chapter 3 discusses strings, including character codes, representing strings, searching patterns in strings, manipulating strings, and string library functions. It also includes programming problems related to strings.

Uploaded by

Sandeep Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Contents xiii

2 Data Structures 27
2.1 Elementary Data Structures . . . . . . . . . . . . . . . . . . . . . . . 27
2.1.1 Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.1.2 Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.1.3 Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.1.4 Priority Queues . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.1.5 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.2 Object Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.2.1 The C++ Standard Template Library . . . . . . . . . . . . . 33
2.2.2 The Java java.util Package . . . . . . . . . . . . . . . . . . 33
2.3 Program Design Example: Going to War . . . . . . . . . . . . . . . . 34
2.4 Hitting the Deck . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.5 String Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.6 Winning the War . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.7 Testing and Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.8 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.8.1 Jolly Jumpers . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.8.2 Poker Hands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.8.3 Hartals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.8.4 Crypt Kicker . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.8.5 Stack ’em Up . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
2.8.6 Erdös Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 50
2.8.7 Contest Scoreboard . . . . . . . . . . . . . . . . . . . . . . . . 52
2.8.8 Yahtzee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.9 Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.10 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

3 Strings 56
3.1 Character Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.2 Representing Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.3 Program Design Example: Corporate Renamings . . . . . . . . . . . 59
3.4 Searching for Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.5 Manipulating Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.6 Completing the Merger . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.7 String Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.8 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.8.1 WERTYU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.8.2 Where’s Waldorf? . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.8.3 Common Permutation . . . . . . . . . . . . . . . . . . . . . . 69
3.8.4 Crypt Kicker II . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.8.5 Automated Judge Script . . . . . . . . . . . . . . . . . . . . . 71
3.8.6 File Fragmentation . . . . . . . . . . . . . . . . . . . . . . . . 73
3.8.7 Doublets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
3.8.8 Fmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3.9 Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

You might also like