algorithm development. the invention of the computer programming language developments: 1. machine...

26
Algorithm development

Upload: terence-stephens

Post on 28-Dec-2015

222 views

Category:

Documents


0 download

TRANSCRIPT

Algorithm development

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

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

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.

Types of software

1. OS (operating system)

2. Programming environment/tools

3. Applications

Operating Systems (OS)

Windows Linux

Android (linux-based) Unix Mac OS many others

Programming environments/tools

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

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

Applications

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

Social issues

Privacy/anonymity

Quality of information

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)

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

Recall “What is a computer?”

INPUT

(information)

PROCESSING OUTPUT

(information)

MEMORY

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.

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

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

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.

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.

Recall “What is a computer?”

INPUT

(information)

PROCESSING OUTPUT

(information)

MEMORY

How can a Java program perform output?

How can a program perform output?

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

blocks

{

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

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

}

Method/function/procedure

public static void main ( String param[] ) {

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

}

Defining our own objects

class MyFirstClass {

public static void main ( String param[] ) {

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

}

}

Recall “What is a computer?”

INPUT

(information)

PROCESSING OUTPUT

(information)

MEMORY

How can a Java program perform input?

How can a Java program perform input?

Scanner s = new Scanner( System.in );

String str = s.nextLine();

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();

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();

}

}