Docsity

Introduction to Java Programming: CSC 1051 Algorithms & Data Structures I, Slides of Logic

Partial preview of the text

Download Introduction to Java Programming: CSC 1051 Algorithms & Data Structures I and more Slides Logic in PDF only on Docsity!

CSC 1051 Algorithms & Data

Structures I

Introduction to Java

2

COMPUTER PROCESSING

CSC 1051

Communication

4

Humans converse with each other using natural languages

Humans converse with computers using programming languages

Talking to the Computer

5

You tell the computer what to do using a sequence of step- by-step instructions called a program

Developing a program involves a few activities:

  • Writing the program in a specific high-level language (such as Java)
  • Translating the program into a low-level language or machine code that the computer can run

History of Computer Programming

Starting in the mid-20th^ century…

Colossus Mark I – first electronic computer to be programmable (Alan Turing, England 1944) Stored program and the fetch/ decode/execute cycle (John von Neumann, USA 1945) ENIAC - first fully electronic digital computer (Eckert and Mauchley, University of Pennsylvania, 1946)

Alan Turing (1912 -1954) The Imitation Game (2014)

Compiling the Program

8

The source program is written by a programmer in a high- level language, like Java, Python, or C.

The target program comes out of the compiler in either a textual form called assembly language or a binary (1s and 0s) form called machine code.

A compiler translates from source to target language.

System Components

10

Hardware

  • the physical, tangible parts of a computer
  • keyboard, monitor, disks, wires, chips, etc.

Software

  • programs and data
  • a program is a series of step-by-step instructions

A computer needs both

  • Requires both hardware and software
  • Each is essentially useless without the other

The von Neumann Architecture

11

Modern computers all use a computer architecture created in 1945 by a mathematician and inventor named John von Neumann containing 5 essential computer components.

Software

13

Hardware needs software to tell it what to do. There are two categories of software:

Operating Systems

  • Provides a user interface to the computer (console or GUI)
  • Provides a program interface to the hardware
  • Manages system resources like CPU and memory
  • Examples: Windows, Mac OS, Linux, Unix

Application Programs

  • Generic term for any type of software
  • Examples: Word processor, browser, games, mobile apps

Counting Things

The natural way for

humans to count things is

with our 10 fingers. This is

why we our number system

is decimal or base 10.

14

This approach is called Place Value. The place

or position of each digit determines its value.

Binary Numbers

Binary numbers use the position of each bit, just like decimal numbers do, to determine their values.

Each position is a power of two. From right to left, the values are 1s, 2s, 4s, 16s, 32s, 64s, 128s, etc.

Bit Permutations

1 bit 0 1

2 bits 00 01 10 11

3 bits 000 001 010 011 100 101 110 111

4 bits 0000 0001 0010 0011 0100 0101 0110 0111

1000 1001 1010 1011 1100 1101 1110 1111

Each additional bit doubles the number of possible permutations

Hexadecimal

19

To save space, the hexadecimal number system was devised using base 16 numbers to represent numbers from 0 to 15 with a single hex digits. It uses decimal digits 0 to 9 followed by letters A (for 10), B (11), C (12), D (13), E (14), and F (15).

1 A 3 F

1 x 16 3

10 x 16 2

3 x 16 1

15 x 16 0

Bit Permutations – Example

How many bits would you need to represent ten digits in decimal system?

  1. How many unique items?
    • 10 digits ( 0 through 9)
  2. How many bits at least?
    • 2 3 = 8
    • 2 4 = 16
    • 8 < 10 < 16
    • Need 4 bits

0000 0

0001 1

0010 2

0011 3

0100 4

0101 5

0110 6

0111 7

1000 8

1001 9

The rest of the permutations are not needed