1 / 23

Chapter 1 Basic Computer Concept

Chapter 1 Basic Computer Concept. 國立雲林科技大學 資訊工程研究所 張傳育 (Chuan-Yu Chang ) 博士 Office: ES 709 TEL: 05-5342601 ext. 4337 E-mail: chuanyu@yuntech.edu.tw. Textbook.

Download Presentation

Chapter 1 Basic Computer Concept

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. Chapter 1Basic Computer Concept 國立雲林科技大學 資訊工程研究所 張傳育(Chuan-Yu Chang ) 博士 Office: ES 709 TEL: 05-5342601 ext. 4337 E-mail: chuanyu@yuntech.edu.tw

  2. Textbook • G. Michael Schneider & Judith L. Gersting, “Invitation to Computer Science C++ Version”, 3rd Edition, 2004, ISBN:0-534-39097-8 • 台灣代理商:滄海書局 Tel:04-27088787Fax :04-27087799

  3. A few Common Misconceptions about Computer Science • Misconception 1: • Computer science is the study of computers. • Many researchers investigate problems not with actual computers but rather with formal models of computation, which are easier to study and analyze mathematically. • Misconception 2: • Computer science is the study of how to write computer programs. • Programming is so primarily as a tool by which researchers can study new ideas and build and test new solutions. • Misconception 3: • Computer science is the study of the uses and applications of computers and software. • The computer scientist is responsible for specifying, designing, building, and testing software packages as well as the computer systems on which they run.

  4. The Definition of Computer Science • The central concept in computer science is the algorithm. [Gibbs and Tucker, 1986] • Computer science is the study of algorithms, including: • 1. Their formal and mathematical properties • 2. Their hardware realizations • 3. Their linguistic realizations • 4. Their applications

  5. The Definition of Computer Science (cont.) • Based on the definition, the tasks of the computer scientist are • Study the behavior of algorithms to determine whether they are correct and efficient. • Designing and building computer systems that are able to execute algorithms • Designing programming languages and translating algorithms into these languages so that they can be executed by the hardware. • Identifying important problems and designing correct and efficient software packages to solve these problems.

  6. The Definition the word Algorithm • Algorithm: • A procedure for solving a mathematical problem in a finite number of steps that frequently involves repetition of an operation; broadly: a step-by-step method for accomplishing some task. • An algorithm is an ordered sequence of instructions that is guaranteed to solve a specific problem. It looks like:Step 1 Do somethingStep 2 Do somethingStep 3 Do something : :Step N Stop, you are finished

  7. Three categories of operations • The operations used to construct algorithms can be categorized as • Sequential operations : • carries out a single well-defined task, usually expressed as simple declarative sentences. • Conditional operations : • “question-asking” instructions of an algorithm • Iterative operations : • “looping” instructions of an algorithm.

  8. Example:Algorithm for Programming the VCR • Step1 : • If the clock calendar are not correctly set, then go to page 9 of the instruction manual and follow the instructions there before proceeding. • Step2 : • Place a blank tape into the VCR tape slot. • Step3 : • Repeat step 4 through 7 for each program that you wish to record, up to maximum of 10 shows. • Step4 : • Enter the channel number that you wish to record, and press the button labeled CHAN.

  9. Algorithm for Programming the VCR (cont.) • Step5 : • Enter the time that you wish recording to start, and then press the button labeled TIME-START. • Step6 : • Enter the time that you wish recording to stop, and then press the button labeled TIME-FINISH. • Step7 : • This completes the programming of one show. If you do not wish to record anything else press the button labeled END-PROG. • Step8 : • Press the button labeled TIMER. Your VCR is now ready to record.

  10. Example:Algorithm for Adding Two m-digit Numbers • Given m >=1 and two positive numberseach containing m digits: am-1am-2 ……a0and bm-1bm-2……b0 • Wanted: cm-1cm-2…c0 where cm-1cm-2…c0 = (am-1am-2 ……a0 )+ (bm-1bm-2……b0)

  11. Example:Algorithm for Adding Two m-digit Numbers • Step 1: • Set the value ofcarry to 0 • Step 2: • Set the value of i equal to the value 0 • Step 3: • Repeat the instructions in steps 4 through 6 until the value of i is greater than m-1 • Step 4: • Add the two digits aiand bito the current value of carry to get ci • Step 5: • if ci>= 10 , reset cito (ci -10) and reset the value of carry to 1; otherwise, set the new value of carry to 0 • Step 6: • Add 1 to i , effectively moving one column to the left

  12. Algorithm for Adding Two m-digit Numbers (cont.) • Step 7: • set cm to the value of carry • Step 8: • print out the final answer, cmcm-1cm-2 … … … c0 • Step 9: • Stop

  13. Analyzing the algorithm • Steps 1,2,4,6,7,8,9: sequential operations • Step 5: conditional operations • Step 3: iterative operations

  14. Why formalizing the steps? • Why are formal algorithms so important in computer science ? • If we can specify an algorithm to solve a problem, then we can automate its solution. • The machine, robot, person , or thing carrying out the steps of the algorithm is called a computing agent. • Computer science can be viewed as “the science of algorithmic problem solving”. • Computability: is it true that every problem can be solved algorithmically? • Unsolvable problem • To specify an algorithm, but it would take a computing agent so long to execute that the solution is useless. • Ex. Chessboard: brute force algorithm • 假設在每一狀態有40個合法的移動,每盤棋約30步,則決定下第一步可有40x40x40x…x40=4030=1048 • 假設每秒可評估1012步,則須花3x1025年才能下哪一步。 • We do not yet know how to solve algorithmically. • Ex. intelligence

  15. The Formal definition of an Algorithm • The formal definition of an algorithm • A well-ordered collection of unambiguous and effectively computable operations that, when, executed, produces a result and halts in a finite amount of time.

  16. Examples of algorithmsshampooing instructions • Step 1 Wet hair • Step 2 Lather • Step 3 Rinse • Step 4 Repeat

  17. Examples of algorithmsmaking a cherry pie • Step 1: Make the crust • 1.1 Take one and one-third cups flour • 1.2 Sift the flour • 1.3 Mix the sifted flour with one-half cup butter and one-fourth cup water. • 1.4 Roll into two 9-inch pie crusts. • Step 2: Make the cherry filling • 2.1 Open a 16-oz can of cherry pie filling and pour into bowl • 2.2 Add a dash of cinnamom and nutmeg, and stir. • Step 3: Pour the filling into the crust • Step 4: Bake at 350F for 45 minutes.

  18. Unambiguous • An unambiguous operation is one that can be understood and carried out directly by the computing agent without needing to be further simplified or explained. • An operation is unambiguous , we call it a primitive operation • It is not enough for an operation to be understandable. It must also be doable by the computing agent. • Doable means there exists a computational process that allows the computing agent to complete that operation successfully. • Effectively computable.

  19. Examples of algorithmsprime number • Step 1: Generate a list L of all the prime numbers: L1, L2, L3,… • Step 2: Sort the list L into ascending order. • Step 3: Print out the 100th element in the list L100. • Step 4: Stop Not doable

  20. Some examples of operations that may not be effectively computable: • Write out the exact decimal value p. • Set average to sum/number • Set the value of result to (N)1/2 • Add 1 to the current value of x

  21. …halts in a finite amount of time. • The result must be produced after the execution of a finite number of operations. • We must guarantee that the algorithm eventually reaches a statement that says “Stop, you are done”

  22. A correct solution to the Shampooing problem (1) • Step 1: Wet your hair. • Step 2: Set the value of WashCount to 0 • Step 3: Repeat step 4 through 6 until the value ofWashCount equals 2. • Step 4: Lather your hair • Step 5: Rinse your hair • Step 6: Add 1 to the value of WashCount • Step 7: Stop, you have finished shampooing your hair.

  23. A correct solution to the Shampooing problem (2) • Step 1: Wet your hair • Step 2: Lather your hair • Step 3: Rinse your hair • Step 4: Lather your hair • Step 5: Rinse your hair • Step 6: Stop, you have finished shampooing your hair.

More Related