Top Banner
Algorithm development
26

Algorithm development. The invention of the computer Programming language developments: 1. Machine code 2. Assembler easier to write, debug, and update.

Dec 28, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Algorithm development

Page 2: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

The invention of the computer

Programming language developments:1. Machine code2. Assembler

easier to write, debug, and update3. High level languages

strive to be machine independent easier to learn and use 1954 – FORTRAN 1961 – COBOL then ALGOL, LISP, BASIC 1970 – Pascal 1980’s – C 1990’s – C++, Java (originally called ?) and many, many others

Page 3: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

High level langauges (HLL)

Not directly understood by the computer

Humanly readable

Requires the user of a compiler Compiler = program

Input = code written in a HLL Output = machine code

Page 4: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Pascal (an HLL)

1970’s Support for “structured programming”

Control constructs1. Linear sequence of commands/instructions

2. Repetition

3. Selection

Top-down programming Problem is broken down into a series of smaller

problems which are solved. Divide-and-conquer technique.

Page 5: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Types of software

1. OS (operating system)

2. Programming environment/tools

3. Applications

Page 6: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Operating Systems (OS)

Windows Linux

Android (linux-based) Unix Mac OS many others

Page 7: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Programming environments/tools

Tools emacs (an editor – not a word processor) vi g++ gdb

Page 8: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Programming environments/tools

IDE’s (Integrated Development Environment) consist of: editor, compiler or interpreter,

debugger, linker

examples: jGrasp, netbeans, Eclipse, Ready, Visual C++, Visual BASIC, JBuilder, and many others

Page 9: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Applications

Computer games Word processors Graphics packages Virtual reality software Web browsers Presentation Database Spreadsheet And many others.

Page 10: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Social issues

Privacy/anonymity

Quality of information

Page 11: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Program development

Our programming language is Java.

The IDE we will use is jGrasp. Editor is used to type in program text (it is

not a word processor; don’t use a word processor).

Compiler (syntax errors) Run/execute (semantic errors)

Page 12: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Program development

Java is an object-oriented language. (Note: Case sensitive.)

Method named operation constructor (ctor)

special method w/ same name as class performs initialization class may have more than 1 ctor

Class named group of related methods

Page 13: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Recall “What is a computer?”

INPUT

(information)

PROCESSING OUTPUT

(information)

MEMORY

Page 14: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Definitions (from http://mathworld.wolfram.com/Algorithm.html)

An algorithm is a specific set of instructions for carrying out a procedure or solving a problem, usually with the requirement that the procedure terminate at some point.

Page 15: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Definitions (from http://mathworld.wolfram.com/Algorithm.html)

Specific algorithms sometimes also go by the names: method procedure routine subroutine technique

Page 16: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Definitions (from http://mathworld.wolfram.com/Algorithm.html)

The word “algorithm” is a distortion of al-Khwārizmī, a Persian mathematician who wrote an influential treatise about algebraic methods.

Page 17: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Definitions (from http://mathworld.wolfram.com/Algorithm.html)

The process of applying an algorithm to an input to obtain an output is called a computation.

Page 18: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Recall “What is a computer?”

INPUT

(information)

PROCESSING OUTPUT

(information)

MEMORY

How can a Java program perform output?

Page 19: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

How can a program perform output?

System.out.println( "hello world" );

Page 20: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

blocks

{

System.out.println( "Welcome!" );

System.out.println( "Enjoy the show." );

}

Page 21: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Method/function/procedure

public static void main ( String param[] ) {

System.out.println( "hi there" );

}

Page 22: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Defining our own objects

class MyFirstClass {

public static void main ( String param[] ) {

System.out.println( "hi there" );

}

}

Page 23: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Recall “What is a computer?”

INPUT

(information)

PROCESSING OUTPUT

(information)

MEMORY

How can a Java program perform input?

Page 24: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

How can a Java program perform input?

Scanner s = new Scanner( System.in );

String str = s.nextLine();

Page 25: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

We can mix input and output.

Scanner s = new Scanner( System.in );

System.out.print( "Enter your name: " );

String name = s.nextLine();

System.out.println( "Thanks." );

s.close();

Page 26: Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.

Complete program that does both input & output.import java.util.Scanner;

class MySecondClass {

public static void main ( String param[] ) {

Scanner s = new Scanner( System.in );

System.out.print( "Enter your name: " );

String name = s.nextLine();

System.out.println( "Thanks." );

s.close();

}

}