Programming at a high level. Developing a Computer Program Programmer  Writes program in source code (VB or other language) Compiler  Converts source.

Slides:



Advertisements
Similar presentations
Program Development Cycle Prof. Carlos Rodríguez Sánchez.
Advertisements

CE 311 K Introduction to Computer Methods VB Controls and Events Daene C. McKinney.
Lesson 8 Searching and Sorting Arrays 1CS 1 Lesson 8 -- John Cole.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
1.4 Programming Tools Flowcharts Pseudocode Hierarchy Chart
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 2 - Problem Solving
Chapter 9: Searching, Sorting, and Algorithm Analysis
Copyright © 2012 Pearson Education, Inc. Chapter 8: Searching and Sorting Arrays.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2- Visual Basic Schneider
Programming Tools Flowcharts Pseudocode Algorithm Chapter 2.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
Program Flow Charting How to tackle the beginning stage a program design.
Program Flow Charting How to tackle the beginning stage a program design.
Program Development and Programming Languages
Searching and Sorting Arrays
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
Introduction to Computing Dr. Nadeem A Khan. Lecture 5.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 9 Searching.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
PRE-PROGRAMMING PHASE
1 Chapter 1 - An Introduction to Computers and Problem Solving 1.1 An Introduction to Computers 1.2 Windows, Folders, and Files 1.3 Program Development.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 8: Searching and Sorting Arrays.
Copyright © 2012 Pearson Education, Inc. Chapter 8: Searching and Sorting Arrays.
Chapter 1 - VB 2008 by Schneider1 Chapter 1 - An Introduction to Computers and Problem Solving 1.1 An Introduction to Computers 1.2 Windows, Folders, and.
Chapter 2 - VB.NET by Schneider1 Chapter 2 - Problem Solving Program Development Cycle Programming Tools.
SEARCHING UNIT II. Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances.
Chapter 8 Searching and Sorting Arrays Csc 125 Introduction to C++ Fall 2005.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 9 Searching Arrays.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 8: Searching and Sorting Arrays.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Introduction to Data Structures and Algorithms CS 110: Data Structures and Algorithms First Semester,
Flowcharts. Problem Solving Computer programs are written to solve problems or perform tasks Programmers translate the solutions or tasks into a language.
Programming at a high level. Developing a Computer Program Programmer  Writes program in source code (VB or other language) Compiler  Converts source.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Modified for use by MSU Dept. of Computer Science.
Chapter 9 slide 1 Introduction to Search Algorithms Search: locate an item in a list (array, vector, table, etc.) of information Two algorithms (methods):
1 Programming Tools Flowcharts Pseudocode Hierarchy Chart Direction of Numbered NYC Streets Algorithm Class Average Algorithm.
Introduction to Computing Dr. Nadeem A Khan. Lecture 2.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
The Hashemite University Computer Engineering Department
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Expressing Algorithms as Flowcharts and Pseudocode
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
 Introduction to Search Algorithms  Linear Search  Binary Search 9-2.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 8: Searching and Sorting Arrays.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Program Development Cycle
Searching and Sorting Arrays
Introduction to Search Algorithms
Chapter 9: Searching, Sorting, and Algorithm Analysis
Chapter 2- Visual Basic Schneider
Introduction to Computing
Lecture 2 Introduction to Programming
Searching and Sorting Arrays
Standard Version of Starting Out with C++, 4th Edition
Chapter 2- Visual Basic Schneider
Chapter 2- Visual Basic Schneider
Flowcharts and Pseudocode
Searching and Sorting Arrays
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Presentation transcript:

Programming at a high level

Developing a Computer Program Programmer  Writes program in source code (VB or other language) Compiler  Converts source code to machine language code Linker  Combines machine language with libraries & converts them to an executable module Interpreter  Converts source code to machine language and executes one line at a time CompilerLink/load Executable module Source code Machine language Output Input data High-level language Low-level Language

Programming Process Grace M. Hopper First “Bug” Algorithm Design (underlying logic of program) Program Composition Debug & test (error free & reliable) Program Documentation Program Maintenance

Programming Tools Tools to convert algorithms into computer programs Algorithm: Step-by-Step procedure for solving a problem Example Problem: You write a letter. To mail it, you must decide how much postage to put on the envelop. Rule of Thumb: One stamp for every 5 sheets of paper. Algorithm: see next slide

Algorithm 1. Request the number of sheets of paper; call this “Sheets” 2. Divide Sheets by 5 3. Round the quotient up to the next highest whole number; call it “Stamps” 4. Reply with the number Stamps 5. Example: INPUT (16) Processing Output (4)

Flowchart Symbols Flow Line Start/Stop Input/Output Processing Decision

Stamp Problem Program: Determine the proper number of stamps for a letter  Read sheets  Set the number of stamps to sheets/5  Round the number of stamps up to the next whole number  Display the number of stamps Start Read sheets Set stamps = sheets/5 Round stamps up To next whole # Display stamps End Input Processing Output Flowchart Pseudocode

Decisions If condition is true, then Process step(s) 1 Else Process step(s) 2 End if Is condition True? Process Step(s) 1 Process Step(s) 2 No Yes Flowchart Pseudocode

Pseudocode Structure Start and stop begin and end Output Return Decisions If-then-else Loops For While-do Repeat-until

Real world problems A traffic light A vending machine An elevator An ATM

Mathematical problems Calculate the summation of a list of numbers Calculate the average of a list of numbers Find the maximum number from a list Find the minimum number from a list

Average Grade Problem Start Sum=0 Count = 0 Input Grade More grades? Sum = Sum + Grade Count = Count + 1 Average = Sum/Count Stop No Yes Flowchart Pseudocode BEGIN Average Grade sum=0 count = 0 DO WHILE grade > 0 sum = sum + grade count = count +1 END DO average = sum/count END Average Grade

Introduction to Search Algorithms Search: locate an item in a list (array, vector, etc.) of information Two algorithms:  Linear search  Binary search  Interpolation search

Linear Search Tradeoffs Benefits  Easy algorithm to understand  Array can be in any order Disadvantage  Inefficient (slow): for array of N elements, examines N/2 elements on average for value in array, N elements for value not in array

Binary Search Algorithm 1. Divide an ordered array into three sections.  middle element  elements on one side of the middle element  elements on the other side of the middle element 2. If the middle element is the correct value, done. Otherwise, go to step 1, using only the half of the array that may contain the correct value. 3. Continue steps 1 and 2 until either the value is found or there are no more elements to examine.

Binary Search Tradeoffs Benefit  Much more efficient than linear search (For array of N elements, performs at most log 2 N comparisons) Disadvantage  Requires that array elements be ordered

Interpolation Search Tradeoffs Benefits  Much more efficient than binary search (For array of N elements, performs log 2 log 2 N comparisons on an average) Disadvantage  Requires that array elements be ordered  Elements need to be uniformly distributed for best performance