Download presentation
Presentation is loading. Please wait.
Published byDustin Gibbs Modified over 8 years ago
1
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012
2
Overview Data and Information Computer Operations Problem Solving Steps Programs and Programming Types of Computer Languages Levels of Computer Languages Programming and Problem Solving Algorithms
3
Data and Information Data are raw facts : e.g. transactions, dates and amounts. Information are data that have been processed into a usable form: e.g. tables, documents, and charts. Goal of computer applications is to process data into information
4
Data and Information Calculate the total amount of purchasing a video game with tax. Output (Information) Processing Input (Data) Taxes amount due Tax= Price x Percentage Total amount = Price + Tax Video game price Tax Percentage 1070Tax= 1000 x 0.07 Total amount = 1000 + 70 Price = 1000 Percentage = 7%
5
Computer Operations There are six basic computer operations: 1. Receive data (input). 2. Store data in memory. 3. Perform arithmetic and logic operations. 4. Make Decisions. 5. Repeat a group of operations. 6. Output the processed data (information).
6
Computer Operations
7
Program and Programming Program is a collection of instructions that tell the computer what to do. It is generically known as "software”. The process of creating a program is called programming. A program is written in a programming language, such as C, C++ or Java.
8
Program and Programming The computer only knows what it is told through programs, so they must be accurate and very specific. The instructions are written by the programmer. The instructions are converted into the computer's machine language by software called "compilers“.
9
Types of Computer Languages Procedural: Monolithic programs that run from start to finish with no intervention from user other than input Basic, QBasic, QuickBasic COBOL FORTRAN C Object Oriented/Event Driven (OOED): Programs that use objects which respond to events; use small segments to code for each object Visual Basic Visual C++
10
Levels of Computer Languages Low Level: at the level of the computer, i.e., in binary (0-1) format Computer can only execute a binary form of a program Intermediate Level: close to the computer but uses English words, e.g., Assembler, that is converted directly into binary High Level: at the level of the programmer using English words and clearly defined syntax; must be converted or translated into binary for computer to implement it, e.g., Visual C++. Need a software program to handle the conversion of high-level into binary
11
Translating from High-level Language to Binary Interpreted: each statement translated as it is executed-- slow but easy to use Compiled: entire program is converted to binary--executes faster, but more difficult to use (.exe files are compiled programs)
12
Translating from High-level Language to Binary
13
Programming and Problem Solving Steps Programming is a process of problem solving Problem solving techniques Analyze the problem Outline the problem requirements Design steps (algorithm) to solve the problem Algorithm: Step-by-step problem-solving process
14
Problem Solving Process Step 1 - Analyze the problem Outline the problem and its requirements Design steps (algorithm) to solve the problem Step 2 - Implement the algorithm Implement the algorithm in code Verify that the algorithm works Step 3 - Maintenance Use and modify the program if the problem domain changes
15
Analyze The Problem Thoroughly understand the problem Understand problem requirements : Does program require user interaction? Does program manipulate data? What is the output? If the problem is complex, divide it into subproblems Analyze each subproblem as above
16
What is an algorithm? The idea behind the computer program Stays the same independent of Which kind of hardware it is running on Which programming language it is written in Solves a well-specified problem in a general way Is specified by Describing the set of instances (input) it must work on Describing the desired properties of the output
17
What is an algorithm? (Cont’d) Before a computer can perform a task, it must have an algorithm that tells it what to do. An algorithm is an ordered set of unambiguous executable steps, defining a terminating process.” Ordered set of steps: structure! Executable steps: doable! Unambiguous steps: follow the directions! Terminating: must have an end!
18
Important Properties of Algorithms Correct always returns the desired output for all legal instances of the problem. Unambiguous Precise Efficient Can be measured in terms of Time Space Time tends to be more important
19
Representation of Algorithms A single algorithm can be represented in many ways: Formulas: F = (9/5)C + 32 Words: Multiply the Celsius by 9/5 and add 32. Flow Charts. Pseudo-code. In each case, the algorithm stays the same; the implementation differs!
20
Representation of Algorithms (Cont’d) A program is a representation of an algorithm designed for computer applications. Process: Activity of executing a program, or execute the algorithm represented by the program
21
Expressing Algorithms English description Flow Chart Pseudo-code High-level programming language More precise More easily expressed
22
End
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.