1 / 60

CS 180 Problem Solving and Object Oriented Programming Fall 2010

CS 180 Problem Solving and Object Oriented Programming Fall 2010. http://www.cs.purdue.edu/homes/apm/courses/CS180Fall2010/. Notes for Week 1: August 23-27, 2010. Aditya Mathur Department of Computer Science Purdue University West Lafayette, IN, USA. About CS 180.

haruko
Download Presentation

CS 180 Problem Solving and Object Oriented Programming Fall 2010

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 180 Problem Solving and Object Oriented Programming Fall 2010 http://www.cs.purdue.edu/homes/apm/courses/CS180Fall2010/ Notes for Week 1: August 23-27, 2010 Aditya Mathur Department of Computer Science Purdue University West Lafayette, IN, USA

  2. About CS 180 CS 180. Fall 2010. Week 1

  3. Course Web Site and Other Resources Course Web site: http://www.cs.purdue.edu/homes/apm/courses/CS180Fall2010/ Java Resources: http://download.oracle.com/javase/1.4.2/docs/api/ http://download.oracle.com/javase/tutorial/ CS 180. Fall 2010. Week 1

  4. Please note…. Classes will begin at 4:30pm and end at 5:20pm. Please try to be in your seat a few minutes before the class begins and leave after the class ends. All students are encouraged to ask questions. You may interrupt the instructor at any time. The instructor is here to help you learn. Make full use of the instructor. Make full use of the instructor’s office hours I want you to succeed in this class and in your major. I will do all I can to help you succeed; this is my primary responsibility as a professor at Purdue. CS 180. Fall 2010. Week 1

  5. Assumptions You have little or no expertise in computer programming using Java. You are hard working. You will not sleep during classes, an if you do, you will not snore! You will not use phones during class and turn them off when you enter the class and leave them off until the class is adjourned. You will not disturb others by talking to your neighbors. You will try to participate in the class by asking questions and responding to questions asked by the instructor. You will use iClickers in the class when requested. CS 180. Fall 2010. Week 1

  6. Impact of Assumptions Some of you may get bored during the first four weeks of classes, but others may find appealing the slow pace. For those with some Java experience, we recommend participating in the programming competition. Refer to the course web site for details. Please buy an iClicker. You should skip the class if you need to discuss important matters with your friends. But skipping a class is not a good idea! So maybe you might consider rescheduling the important matters with your friend. CS 180. Fall 2010. Week 1

  7. Expectations: Academic Honesty Unless specified otherwise, all labs, projects, and exams are to be completed by you without assistance from anyone else other than the course instructor and the graders. Read the Policies page on the course web site. CS 180. Fall 2010. Week 1

  8. Expectations: Attendance You will attend all lectures, labs, and recitations. Attendance is not mandatory but highly recommended. If you miss a lecture, lab or recitation then it is your responsibility to (a) learn on your own the material covered (b) find out if there were any announcements that might affect your course grade. CS 180. Fall 2010. Week 1

  9. Textbook Title A Gentle Introduction to Concurrent Programming. Authors Barry Wittman, Aditya Mathur, and Tim Korb Edition Draft 3.0, 2010 Avaialble at Boiler CopyMaker, Room 157, Purdue Memorial Union. Additional resource Java Tutorial iClickers You may buy an iClicker from one of several local bookstores. CS 180. Fall 2010. Week 1

  10. Grading Component Weight (%) Points Exam 1: W 9/29. 8-10pm. EE 129. 15 480 Exam 2: Tue 11/09. 8-10pm. EE 192. 15 480 Lab exercises [14] 15 540 Project 1 [Individual] 2 64 Project 2 [Individual] 3 96 Project 3 [Individual] 4 128 Project 4 [Team of 2] 6 192 Project 5 [Team of 3] 10 320 Final Exam 30 960 TOTAL 100 3260 Relative grading (curved). CS 180. Fall 2010. Week 1

  11. Exams You will be allowed to consult one book of your choice during the all exams. CS 180. Fall 2010. Week 1

  12. Feedback • Weekly feedback: anonymous via iClickers • Tell us about the lectures, labs, recitations • How are we doing? • Weekly feedback: open • Tell us in an open forum what needs to improve. • Constructive criticism of the class is highly appreciated. CS 180. Fall 2010. Week 1

  13. Week 1: August 23-27, 2010 What is Computer Science? CS 180. Fall 2010. Week 1

  14. Computer Science... …is a discipline just as any other discipline like Mechanical Engineering, Electrical Engineering, Biomedical Engineering,… …educates and trains students to work as software engineers, information security specialists, systems engineers,…. …deals with software that drives a large number of devices and systems that we use in our day to day lives,… …consists of subfields such as algorithms, artificial intelligence, computational science and engineering, databases, graphics and visualization, information retrieval, information security, machine learning, modeling and simulation, networking, programming languages and compilers, software engineering,… CS 180. Fall 2010. Week 1

  15. Computer Scientists... …develop software that drives consumer devices such as smart phones, TVs, stereo systems,… …develop software systems that control and manage aircrafts, automobiles, health care networks, power grids, intelligent transportation systems,… …develop systems software such as compilers, operating systems, databases, and search engines on which are built a myriad of other user applications,…. …work alongside engineers to develop software that drives devices such as smart phones or more complex systems such as aircrafts,… CS 180. Fall 2010. Week 1

  16. Week 1: August 23-27, 2010 Readings And Learning Outcomes CS 180. Fall 2010. Week 1

  17. Readings and Exercises from the textbook:Week 1 Chapter 1: 1.1, 1.2 Solve: 1.3, 1.4, 1.7, 1.11, 1.14, 1.26 CS 180. Fall 2010. Week 1

  18. Learning Outcome-1 Through a sequence of well defined steps you will be able to map a problem statement presented in natural language to a computer program written in the Java programming language. CS 180. Fall 2010. Week 1

  19. Learning Outcome-2 You will learn the basics of computer programming that will aid you in learning programming languages other than Java. Some of these other languages include C#, Python, and C. CS 180. Fall 2010. Week 1

  20. Learning Outcome-3 You will learn the differences between sequential and concurrent solutions to given problem. This will allow you to write concurrent programs that exploit the power of multi-core microprocessors. CS 180. Fall 2010. Week 1

  21. Learning Outcome-4 You will learn about Computer Science as a discipline. This will help you decide whether or not Computer Science is for you! CS 180. Fall 2010. Week 1

  22. Learning Outcome-5 You will learn how to use DrJava to edit, compile, debug, and execute Java programs. CS 180. Fall 2010. Week 1

  23. Learning Outcome-6 You will learn how to program RidgeSoft robots using Java. CS 180. Fall 2010. Week 1

  24. Learning Outcome-7 You will learn how to program Android-based smart phones using Java. CS 180. Fall 2010. Week 1

  25. Learning Opportunities in CS 180 Lectures: Basic concepts and techniques Labs: Practice solving simple problems on the computer; use robots and smart phones Recitations: Practice solving simple problems by hand; lots of discussion and participation; work in small teams Projects: Solve more complex problems; design, implement, test, document. CS 180. Fall 2010. Week 1

  26. Learning in CS 180: Prerequisite Desire to learn and the ability to work hard. CS 180. Fall 2010. Week 1

  27. Learning in CS 180 Practice, practice and practice You will write programs that do not compile at first And when they compile they do not run as expected And when they run as expected, you scream Yippee! So do not be discouraged by errors, these are a part of life’s challenges; overcome them! We are here to help you. CS 180. Fall 2010. Week 1

  28. Week 1: August 23-27, 2010 Problem Solving and OO Programming CS 180. Fall 2010. Week 1

  29. What is “problem solving?” • “Problem solving” refers to a set of activities performed in order to solve a given problem. This is a generic term and applies to all disciplines, not only to Computer Science. • The following sequence of steps for solving a problem was proposed by George Polya in the 1950’s : • Understand the problem • Devise a plan • Execute the plan • Review the solution CS 180. Fall 2010. Week 1

  30. What is OO programming? OO, or Object Oriented, programming refers to a set of activities that lead to a computer program, written in an object-oriented language, that when executed on a computer will solve a problem. Java is an OO language used in CS 180. Other OO languages include C++, C#, Delphi, Modula, Oberon, Objective C, Simula, Smalltalk, and many more! CS 180. Fall 2010. Week 1

  31. What is Problem solving and OO programming? Problem solving and OO programming refers to a set of activities that allow the mapping of a problem to a computer program, written in an object-oriented language, that when executed on a computer will solves the problem. Here is a simplistic summary of activities that aid in solving a problem using OO programming: • Understand the problem • Design a solution using objects • Implement the design as a well documented program in an OO language • Test, debug, and correct the program CS 180. Fall 2010. Week 1

  32. What is a multi-core microprocessor? A multi-core microprocessor is a microprocessor chip that contains two or more cores. Each core is capable of executing its own sequence of instructions. A dual-core microprocessor contains 2-cores. A quad-core microprocessor contains 4-cores, and so on. CS 180. Fall 2010. Week 1

  33. What is a parallel computer? A computer capable of executing two or more programs in parallel is often referred to as a parallel computer. A computer containing a multi-core microprocessor is a parallel computer. A computer containing two or more single-core microprocessors is also a parallel computer. Nearly every desktop and laptop today is a parallel computer containing a multi-core microprocessor. CS 180. Fall 2010. Week 1

  34. What is a sequential program? A sequential program is one that is executed by a computer in a strict sequence, one instruction at a time. Thus, every instruction in the program is executed strictly in the specified sequence. CS 180. Fall 2010. Week 1

  35. What is a concurrent program? A concurrent program is one that contains instructions that may be executed in parallel, or concurrently, by a parallel computer. A concurrent program written in Java contains two or more threads. Each thread may be executed concurrently on a parallel computer. CS 180. Fall 2010. Week 1

  36. Example 1: Problem solving • Problem: • Find the maximum in a given set of N integers. • Step 1: Understand the problem • We know what is a set, an integer and what does “maximum” mean. • Can N be zero? Can N be negative? We assume that N>0. • Suppose the given set is: {4, -5, 29, 4}. N=4. • The maximum in this set is 29. CS 180. Fall 2010. Week 1

  37. Example 1: Problem solving: Sequential program Pictorial representation of a sequential algorithm: Sequential computation Input: Given set S Find the maximum m=max(S) Output: max integer in S m CS 180. Fall 2010. Week 1

  38. Example 1: Sequential program • Step 2: Design a sequential solution • Let S denote the given set. • Let S.next() denote the next element from the set. S.next() is empty if we have examined all elements of S. • Let currentMax=S.next(); • Scan each element of S until we have scanned all. The following two steps are performed for each element in S starting from the second. • Let newElement=S.next(); • If currentMax<newElementthen reset currentMax to newElement; • Display currentMax, it is the desired maximum. CS 180. Fall 2010. Week 1

  39. Example 1: Sequential program • Step 3: Implement the design as a well documented program in an OO language • We will write a Java program later in this course. • Step 4: Test, debug, and correct the program • We will do this after we have written the program. CS 180. Fall 2010. Week 1

  40. Example 1: Problem solving: Parallel program • Problem: • Find the maximum in a given set of N integers. • Step 1: Understand the problem • We know what is a set, an integer and what does “maximum” mean. • Can N be zero? Can N be negative? We assume that N>0. • Suppose the given set is: {4, -5, 29, 4}. N=4. • The maximum in this set is 29. • We can divide S into disjoint sets S1 and S2 such that their union is S. • For example, S1={4, -5}, S2={29, 4}. Maximum of S1 is 4 and of S2 is 29. The maximum of these two maximums is 29 which is the desired maximum. CS 180. Fall 2010. Week 1

  41. Example 1: Problem solving: Parallel program Pictorial representation of the parallel algorithm: Sequential computation Input: Given set S Split into S1 and S2 such that S=S1 U S2 S1 S2 Parallel computation Find max of each set using sequential method. m1=max(S1) m2=max(S2) Find max of max of each set. max=max(m1, m2) Sequential computation max Output: max integer in S CS 180. Fall 2010. Week 1

  42. Example 1: Problem solving: Parallel program • Step 2a: Design a concurrent solution assuming a dual core machine is to be used for executing this solution. • Let S denote the given set. • Let S.next() denote the next element from the set. S.next() is empty if we have examined all elements of S. • Divide S into sets S1 and S2 such that S=S1 U S2 • Let maxS1= max(S1) and maxS2=max(S2). • Let max be the larger of maxS1 and maxS2 • max is the desired maximum. CS 180. Fall 2010. Week 1

  43. Example 1: Problem solving: Parallel program • Step 2b: Design a concurrent solution: max(S) denotes the maximum of integers in set S. • Let S.next() denote the next element from the set. S.next() is empty if we have examined all elements of S. • Let currentMax=S.next(); • Scan each element of S until we have scanned all. The following two steps are performed for each element in S starting from the second. • Let newElement=S.next(); • If currentMax<newElementthen reset currentMax to newElement; • currentMax, is the desired maximum. CS 180. Fall 2010. Week 1

  44. Example 1: Problem solving: Parallel program • How many threads of computation do you see in our solution? • What does each thread do? • Will a thread wait? Why and when? CS 180. Fall 2010. Week 1

  45. Why parallel program? For faster solution to a problem. Example: search the entire internet for a keyword. For quick response to a request. Example: Customer request for bank balance. CS 180. Fall 2010. Week 1

  46. Example 2: Problem Solving Problem: Given real numbers a, b, and c, compute the value of the following expression: Step 1: Understand the problem This one is easy! So let us say we have understood the problem! CS 180. Fall 2010. Week 1

  47. Example 2: Problem Solving: Sequential Solution Step 2: Design a sequential solution 1: Get a, b, and c. 2: Compute x=b*b 3: Compute y=4*a*c 4: Compute z=x-y 5: Compute p= 6: Output p CS 180. Fall 2010. Week 1

  48. Example 2: Problem Solving: Parallel Solution Problem: Given real numbers a, b, and c, compute the value of the following expression: 1: Compute x=b*b 2: Compute y=4*a*c 3: Compute z=x-y 4: Compute p= 5: Output p CS 180. Fall 2010. Week 1

  49. Example 2: Problem solving: Parallel program Pictorial representation of the parallel algorithm: Sequential computation Input: Given numbers a, b, c Parallel computation Compute sub-expressions x=b*b y=4*a*c Compute another, dependent, sub-expression z=x-y Sequential computation Compute the square root p= Output: value of the given expression p CS 180. Fall 2010. Week 1

  50. Example 2: Problem solving: Parallel program • How many threads of computation do you see in our solution? • What does each thread do? • Will a thread wait? Why and when? CS 180. Fall 2010. Week 1

More Related