pbm-solving

pbm-solving - 4/21/10 Problem Solving Assigned reading for...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
4/21/10 1 Problem Solving Assigned reading for this week: TICPP Chpt 1 TICPP Vol 2 Chpt 1, 2 See updated lecture and assignments page for future reading assignments http://www.cs.ucsb.edu/~cs32/ user/pwd: cs32S10/myCS32 1 Problem Solving At this point you should know The basics of writing a program (getting the computer to do some work for you) The process of how this source program in some language gets converted to an executable Which then can be loaded into memory and executed Before we go through this process, lets talk about Designing programs Problem solving techniques The software design process Tools to help with this process » Testing & debugging, before and during runtime Then we will talk about the problem on which we will focus for the remainder of the class 2 Problem Solving Step 1: Discover the method of solution The most difficult part of solving a problem Step 2: Translate it into some computer language (ours is C++ for now) Key: Ignore the programming language Its just a tool to communicate with the computer Many different ones, some work better than others on particular types of problems Concentrate on formulating the steps of the solution Write them down in plain english and/or draw pictures As if you were instructing another human to solve the problem for you 3 Algorithm A sequence of precise instructions which leads to a solution Approximately equivalent to the words r ecipe, method, set of directions, procedure, routine When written in a computer language, it is a program Ex: Algorithm for determining how many times a name occurs in a list of names 1. Get the list of names 2. Get the name we are looking for 3. Set a counter to 0 4. Do the following for each name on the list: 1. Compare the name we are looking for with the current name from the list 2. If the names are the same, increment the counter 5. Announce that the number of occurances found is the value of the counter 4
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4/21/10 2 Program Design A creative process No precise set of rules, but here’s an outline 5 Problem defni±on Algorithm design By‐Hand and Desktop tes±ng Translate to C++ Tes±ng Start Working program Problem‐solving phase Implementa4on phase Problem-solving phase Outline general solution as well as the corner cases Be thorough Describe your expectations and assumptions (your view of the world, ie state of the program) at every step Do NOT short circuit this phase! It will NOT save you time! Program Design A creative process No precise set of rules, but here’s an outline 6 Problem defni±on Algorithm design By‐Hand and Desktop tes±ng Translate to C++ Tes±ng Start Working program Problem‐solving phase Implementa4on phase Testing Occurs throughout both phases Use your assumptions and expectations to write tests for all parts of the code to verify that your view of the world at this point in
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/18/2010 for the course CS CS32 taught by Professor Krintz during the Spring '10 term at UCSB.

Page1 / 12

pbm-solving - 4/21/10 Problem Solving Assigned reading for...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online