1 / 34

CS1010 Programming Methodology A beginning in problem solving in Computer Science

CS1010 Programming Methodology A beginning in problem solving in Computer Science. Aaron Tan http://www.comp.nus.edu.sg/~cs1010/. Contents. What is Computer Science (CS)? What is Problem Solving? What is Algorithmic Problem Solving?. What is Computer Science?.

lucien
Télécharger la présentation

CS1010 Programming Methodology A beginning in problem solving in Computer Science

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. CS1010 Programming MethodologyA beginning in problem solving in Computer Science Aaron Tan http://www.comp.nus.edu.sg/~cs1010/

  2. Contents • What is Computer Science (CS)? • What is Problem Solving? • What is Algorithmic Problem Solving? [CS1010: A beginning in problem solving in CS]

  3. What is Computer Science? Computing Curricula 2001 (Computer Science) Report identifies 14 knowledge focus groups • Discrete Structures (DS) • Programming Fundamentals (PF) • Algorithms and Complexity (AL) • Architecture and Organization (AR) • Operating Systems (OS) • Net-Centric Computing (NC) • Programming Languages (PL) • Human-Computer Interaction (HC) • Graphics and Visual Computing (GV) • Intelligent Systems (IS) • Information Management (IM) • Social and Professional Issues (SP) • Software Engineering (SE) • Computational Science (CN) O(n2) P = NP ? [CS1010: A beginning in problem solving in CS] 3

  4. Problem Solving Exercises • The exercises in the next few slides are of varied nature, chosen to illustrate the extent of general problem solving. • Different kinds of questions require different domain knowledge and strategies. • Apply your problem solving skills and creativity here! [CS1010: A beginning in problem solving in CS]

  5. Warm-up #1: Glasses of milk • Six glasses are in a row, the first three full of milk, the second three empty. By moving only one glass, can you arrange them so that empty and full glasses alternate? [CS1010: A beginning in problem solving in CS]

  6. Warm-up #2: Bear • A bear, starting from the point P, walked one mile due south. Then he changed direction and walked one mile due east. Then he turned again to the left and walked one mile due north, and arrived at the point P he started from. What was the colour of the bear? [CS1010: A beginning in problem solving in CS]

  7. Warm-up #3: Mad scientist • A mad scientist wishes to make a chain out of plutonium and lead pieces. There is a problem, however. If the scientist places two pieces of plutonium next to each other, KA-BOOM!!! • In how many ways can the scientist safely construct a chain of length 6? • General case: What about length n? [CS1010: A beginning in problem solving in CS]

  8. Warm-up #4: Silver chain • A traveller arrives at an inn and intends to stay for a week. He has no money but only a chain consisting of 7 silver rings. He uses one ring to pay for each day spent at the inn, but the innkeeper agrees to accept no more than one broken ring. • How should the traveller cut up the chain in order to settle accounts with the innkeeper on a daily basis? [CS1010: A beginning in problem solving in CS]

  9. Warm-up #5: Dominoes • Figure 1 below shows a domino and Figure 2 shows a 44 board with two squares at opposite corners removed. How do you show that it is not possible to cover this board completely with dominoes? Figure 1. A domino. Figure 2. A 44 board with 2 corner squares removed. • General case: How do you show the same for an nn board with the two squares at opposite corners removed, where n is even? • Special case: How do you show the same for an nn board with the two squares at opposite corners removed, where n is odd? [CS1010: A beginning in problem solving in CS]

  10. Warm-up #6: Triominoes • Figure 3 below shows a triomino and Figure 4 shows a 4  4 board with a defect (hole) in one square. How do you show that the board can be covered with triominoes? Figure 3. A triomino. Figure 4. A 44 board with a hole. • General case: How do you show that a 2n 2n board (where n 1) with a hole in one square (anywhere on the board) can be covered with triominoes? [CS1010: A beginning in problem solving in CS]

  11. Problem Solving Process (1/5) • Analysis • Design • Implementation • Testing • Determine the inputs, outputs, and other components of the problem. • Description should be sufficiently specific to allow you to solve the problem. [CS1010: A beginning in problem solving in CS]

  12. Problem Solving Process (2/5) • Analysis • Design • Implementation • Testing Describe the components and associated processes for solving the problem. [CS1010: A beginning in problem solving in CS]

  13. Problem Solving Process (3/5) • Analysis • Design • Implementation • Testing Develop solutions for the components and use those components to produce an overall solution. [CS1010: A beginning in problem solving in CS]

  14. Problem Solving Process (4/5) • Analysis • Design • Implementation • Testing Test the components individually and collectively. [CS1010: A beginning in problem solving in CS]

  15. Problem Solving Process (5/5) Determine problem features Analysis Rethink as appropriate Write algorithm Design Produce code Implementation Check for correctness and efficiency Testing [CS1010: A beginning in problem solving in CS]

  16. CS1010: Description and Objectives • This module introduces the fundamental concepts of problem solving by computing and programming using an imperative programming language. • Outcomes: • Know how to solve simple algorithmic problems. • Know how to write good small programs. • C is merely a tool. • This module is not just about C. [CS1010: A beginning in problem solving in CS]

  17. CS1010: Your Friendly Lecturers [CS1010: A beginning in problem solving in CS]

  18. CS1010: Sectional and Discussion Groups • Sectional groups are small lecture groups, small enough to fit in a programming lab. • Discussion groups are tutorial groups. They are even smaller, and are also conducted in programming labs. • Your sectional group and discussion groups will be pre-allocated to you. • All groups cover the SAME syllabus, and have common tests, and all students are graded together as a whole. [CS1010: A beginning in problem solving in CS]

  19. A Peek at a Lecture Session (1/2) Lecturer’s screen is broadcast to every student’s monitor. Interacting with students always makes me happy. [CS1010: A beginning in problem solving in CS]

  20. A Peek at a Lecture Session (2/2) Explaining how to edit and compile a program. Discussing MasterMind. [CS1010: A beginning in problem solving in CS]

  21. Module Website • http://www.comp.nus.edu.sg/~cs1010 Very important! [CS1010: A beginning in problem solving in CS]

  22. IVLE Watch out for announcements • http://ivle/nus.edu.sg Participate in the forum [CS1010: A beginning in problem solving in CS]

  23. Workload (4 MCs) • Lectures: • 3 hours/week in a lab setting. • Discussion sessions: • 2 hours/week in a lab setting. • Continual assessment: • Take-home lab assignments • 2 Practical Exams • Term Test • Final Exam [CS1010: A beginning in problem solving in CS]

  24. Algorithm Input Output Algorithmic Problem Solving • An algorithm is a well-defined computational procedure consisting of a set of instructions, that takes some value or set of values, as input, and produces some value or set of values, as output. [CS1010: A beginning in problem solving in CS]

  25. Programming C constructs Problem solving Program [CS1010: A beginning in problem solving in CS]

  26. A C Program (welcome.c) library // Author: Aaron Tan // Purpose: Ask for user’s name and display a welcome message. #include <stdio.h> • intmain(void) { char name[20]; printf("What is your name? "); scanf("%s", name); printf("Hi %s.\n", name); printf("Welcome to CS1010!\n"); return 0; } } Input Outputs [CS1010: A beginning in problem solving in CS]

  27. Algorithmic Problem Solving #1: Maze [CS1010: A beginning in problem solving in CS] 27

  28. Algorithmic Problem Solving #2: Sudoku [CS1010: A beginning in problem solving in CS] 28

  29. Algorithmic Problem Solving #3: MasterMind (1/2) Sink: Correct colour, correct position Hit: Correct colour, wrong position Secret code Sinks Hits Secret code Sinks Hits 1 1 1 0 Guess #1 Guess #1 1 2 0 1 Guess #2 Guess #2 2 2 1 0 Guess #3 Guess #3 4 0 1 1 Guess #4 Guess #4 [CS1010: A beginning in problem solving in CS] 29

  30. Algorithmic Problem Solving #3: MasterMind (2/2) 6 colours: R: Red B: Blue G: Green Y: Yellow C: Cyan M: Magenta • Given a secret code (secret) and a player’s guess (guess), how do we compute the number of sinks and hits? [CS1010: A beginning in problem solving in CS] 30

  31. CS1010 versus CS1101S The differences The similarities If you intend to take the Turing Programme, you might consider CS1101S. [CS1010: A beginning in problem solving in CS] 31

  32. Have a great time in School of Computing! [CS1010: A beginning in problem solving in CS] 32

  33. Announcements Please attend the Course Briefing (LT17, 2:30pm) Choosing CS1010 or CS1101S URL: http://ntsa.comp.nus.edu.sg/programmingmodule Deadline: 26 July 2010, Monday Default: CS1010 No bidding queue in CORS for both CS1010 and CS1101S DDP students in CS and Maths/Applied Maths will be pre-allocated CS1101S Diploma holders who are exempted CS1010 will be pre-allocated CS1102 For more details, please contact the SoC Undergraduate Office at COM1, level 2 [CS1010: A beginning in problem solving in CS] 33

  34. THE END [CS1010: A beginning in problem solving in CS]

More Related