x Contents
21 Parallel Programming Using Threads 335
21.1ParallelProgramming .............................. 335
21.2Multi-Tasking .................................. 336
21.3POSIXThreads ................................. 336
21.4 Subset Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
21.4.1 GenerateTestCases ........................... 339
21.4.2 SequentialSolution............................ 341
21.4.3 Multi-ThreadedSolution......................... 345
21.5InterleavingtheExecutionofThreads ..................... 348
21.6ThreadSynchronization ............................. 353
21.7AmdahlsLaw .................................. 356
IV Applications 357
22 Finding the Exit of a Maze 359
22.1MazeFileFormat ................................ 359
22.2ReadingtheMazeFile ............................. 361
22.3TheMazeStructure ............................... 365
22.4AnEscapeStrategy ............................... 369
22.5ImplementingtheStrategy ........................... 371
22.5.1 canMove Function ............................ 372
22.5.2 getOut Function ............................. 372
22.5.3 PrintingVisitedLocations........................ 378
23 Image Processing 381
23.1StructureforImage ............................... 381
23.2ProcessingImages ................................ 387
23.2.1 ImagePixelsandColors......................... 388
23.2.2 ProcessingFunctions........................... 388
23.2.3 ApplyingaColorFilter ......................... 389
23.2.4 InvertingtheImageColors ....................... 389
23.2.5 EdgeDetection.............................. 390
23.2.6 ColorEqualization............................ 391
24 Huffman Compression 395
24.1Example ..................................... 395
24.2Encoding ..................................... 397
24.2.1 CountFrequencies ............................ 397
24.2.2 SortbyFrequency ............................ 399
24.2.3 BuildaCodeTree ............................ 400
24.2.4 BuildaCodeBook............................ 410
24.2.5 CompressaFile ............................. 415
24.2.6 CompresswithBits ........................... 418
24.3Decoding ..................................... 423
ALinux 443
A.1 Options for Installing Linux . . . . . . . . . . . . . . . . . . . . . . . . . . 443
A.2 GettingUbuntuLinux.............................. 444
A.3 Downloading and Installing VirtualBox . . . . . . . . . . . . . . . . . . . . 445
A.4 InstallandUpdateLinux ............................ 445
A.5 InstallProgrammingTools ........................... 445
Contents xi
B Version Control 447
B.1 Github.com .................................... 447
B.2 CloningaRepositoryandModifyingaFile .................. 447
B.3 AddingFilesandDirectories .......................... 449
B.4 RevisingaProgram ............................... 449
C Integrated Development Environments (IDE) 451
C.1 Eclipse ...................................... 452
C.2 CreateandBuildaProject ........................... 452
C.3 DebuggingtheProgram ............................. 454
Index 461
This page intentionally left blankThis page intentionally left blank
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset