Think Like a Programmer: An Introduction to Creative Problem Solving

Think Like a Programmer: An Introduction to Creative Problem Solving

V. Anton Spraul

Language: English

Pages: 256

ISBN: 1593274246

Format: PDF / Kindle (mobi) / ePub


Rewire your brain

Examples in this book are written in C++, but will improve your ability to think like a programmer in any language.

The real challenge of programming isn't learning a language's syntax—it's learning to creatively solve problems so you can build something great. In this one-of-a-kind text, author V. Anton Spraul breaks down the ways that programmers solve problems and teaches you what other introductory books often ignore: how to Think Like a Programmer. Each chapter tackles a single programming concept, like classes, pointers, and recursion, and open-ended exercises throughout challenge you to apply your knowledge. You'll also learn how to:

  • Split problems into discrete components to make them easier to solve
  • Make the most of code reuse with functions, classes, and libraries
  • Pick the perfect data structure for a particular job
  • Master more advanced programming tools like recursion and dynamic memory
  • Organize your thoughts and develop strategies to tackle particular types of problems

Although the book's examples are written in C++, the creative problem-solving concepts they illustrate go beyond any particular language; in fact, they often reach outside the realm of computer science. As the most skillful programmers know, writing great code is a creative art—and the first step in creating your masterpiece is learning to Think Like a Programmer.

C++ Cookbook: Solutions and Examples for C++ Programmers

Game Physics Engine Development: How to Build a Robust Commercial-Grade Physics Engine for your Game (2nd Edition)

Programming iOS 9: Dive Deep into Views, View Controllers, and Frameworks

Learn Unity3D Programming with UnityScript: Unity's JavaScript for Beginners

Code Complete: A Practical Handbook of Software Construction (2nd Edition)

 

 

 

 

 

 

 

 

 

 

 

much easier on your muscles. Let’s tackle another shape problem before moving on. P R O B L E M : A S ID E WA Y S T R I A N GL E Write a program that uses only two output statements, cout << "#" and cout << "\n", to produce a pattern of hash symbols shaped like a sideways triangle: # ## ### #### ### ## # We’re not going to go through all the steps we used on the previous problem, because we don’t need to. This “Sideways Triangle” problem is analogous to the “Half of a Square” problem, so we can

earlier, the median of a set of values is the “one in the middle,” such that half of the other values are higher and half of the other values are lower. If there is an even number of values, the median is the simple average of the two values in the middle. For example, in the set 10, 6, 2, 14, 7, 9, the values in the middle are 7 and 9. The average of 7 and 9 is 8, so 8 is the median. 3-3. Write a bool function that is passed an array and the number of elements in that array and determines

should also create a copy constructor. This is a constructor that takes another object of the same class as an object. The copy constructor can be invoked explicitly whenever we need to create a duplicate of an existing studentCollection, but copy constructors are also invoked implicitly whenever an object of that class is passed as a value parameter to a function. Because of this, you should consider passing object parameters as const references instead of value parameters unless the function

as follows: 1. Pass all customer files except one to a subordinate employee. 2. Get the highest revenue of those files back from the subordinate employee. 3. Tally the revenue in the one customer file. 4. Pass the larger of those two revenues to the superior. As in the “counting parrots” problem, the head recursion technique allows each employee to pass the minimum amount of information to the subordinate. The Big Recursive Idea We now arrive at the Big Recursive Idea. In fact, if you’ve

rootPtr); };  int binaryTree::privateCountLeaves(treePtr rootPtr) { if (rootPtr == NULL) return 0; if (rootPtr->right == NULL && rootPtr->left == NULL) return 1; int leftCount = privateCountLeaves(rootPtr->left); int rightCount = privateCountLeaves(rootPtr->right); return leftCount + rightCount; }  int binaryTree::publicCountLeaves() { return privateCountLeaves(_root); } Although C++ would allow both functions to have the same name, for clarity I’ve used different names to distinguish between

Download sample

Download