Вы находитесь на странице: 1из 127

Computer Fundamentals

Course Plan
Basic Understanding

Muhammad Asim Rehmat

MS Computer Science in Artificial Intelligence, UET


Lahore, B.S. in CS&E UET Lahore.
PhD in Automation.. Thesis in progress
Belongs to SIALKOT
Got First prizes in many National/International
software/hardware competitions
Development of PAK Linux at UET any many eGovernment projects
Got more than 30 First prizes in All Asia and All
Pakistan Engineering & Software Competitions as
Project Advisor
Subjects Taught so far:
Robotics & CNC Machines, Embedded Systems,
Industrial Automation, Control Systems, Artificial
Intelligence, DLD, Numerical Analysis etc

Lab Performance
Personal/Professional Growth
Term Project
Mids
Final

40%
30%
60%
30%
40%

How is a computer defined?

Electronic device operating under the control


of instructions stored in its own memory
A computer is an electronic machine that
takes input from the user, processes the
given input and generates output in the form
of useful information.
An electronic device that receives data,
processes data, stores data, and produces a
result (output).

Computers are
everywhere

In Business

In Publication Field

In Education Field

In Government Organizations

In Medical Field

In Science Field

In Entertainment Field

Business
A computer has high speed of calculation,
diligence, accuracy, reliability, or versatility
which made it an integrated part in all
business organizations.
Payroll calculations
Budgeting
Sales analysis
Financial forecasting
Managing employees database
Maintenance of stocks etc.

Banking
Today banking is almost totally dependent
on computer. Banks provide following
facilities:
Banks provide online accounting facility,
which includes current balances, deposits,
overdrafts, interest charges, shares, and
trustee records.
ATM machines are making it even easier
for customers to deal with banks

Education
Computers are being vastly used in
education:
Admission systems
Examination
Library
Research publications
Simulation softwares

Sales and Marketing


Computers are being vastly used in
education:
Advertising - With computers, advertising
professionals create art and graphics, write
and revise copy, and print and disseminate
At Home Shopping - Home shopping has
been made possible through use of
computerized catalogues that provide
access to product information and permit
direct entry of orders to be filled by the
customers.

Health Care
Computers have become important part in
hospitals, labs, and dispensaries
Diagnostic
Lab-diagnostic System
Patient Monitoring System
Pharma Information System
Surgery
Patient Information System

Engineering Design
One of major areas is CAD (Computer aided
design). That provides creation and
modification of images. Some fields are:
Structural Engineering -Requiresstressand
strainanalysisfordesignofShips,Buildings,cars,
Airplanesetc.
Industrial Engineering -Computersdealwith
design,implementationandimprovementofintegrated
systemsofpeople,materialsandequipment.
Architectural Engineering -Computershelpin
planningtowns,designingbuildings,determininga
rangeofbuildingsonasiteusingboth2Dand3D
drawings.

Military
Computers are largely used in armies
Missile Control
Military Communication
Military Operation and Planning
Smart Weapons

Communication
Some main areas in this category are:
E-mail
Chatting
Social Networking
Video-conferencing
Smart phones

Capabilities
The unique capabilities and characteristics
of a computer are:
Speed
Storage capacity
Accuracy
Reliability
Versatility

CPU

Input devices

Memor
y

Storage
devices

Output
devices
16

1.

Input Devices (Keyboard, Mouse, etc.)

2.

Output Devices (Monitor, Speakers, etc.)

3.

Central Processing Unit (CPU) and memory

4.

Motherboard (Circuit Board)

5.

Expansion Cards (Video Card, Sound Card, or


NIC)

6.

Hard Drive Ports and Connections (USB,


Firewire, etc.)

Mouse

Keyboard

Microphone

Scanner

Webcam

Monitor

Printer

Speaker/Headphone

A device that interprets and runs the


commands that you give to the computer.

Also referred to as the processor.

Two major brands are Intel and AMD.

Examples: Intel Core 2 Duo, AMD Turion X2

Memory is where information is stored and


retrieved by the CPU.

There are two main types of memory:


Random Access Memory (RAM): It is the
main memory and allows you to
temporarily store commands and data.
Read Only Memory (ROM): It is the
memory that retains its contents even
after the computer is turned off.

o Is the main circuit board inside the computer.


o Has tiny electronic circuits and other
components on it.
o Connects input, output, and processing
devices together (CPU, Memory, Hard Drive,
DVD Drive)
o Tells the CPU how to run.

Video Card is connected to the computer


monitor and is used to display information
on the monitor.

Network Interface Card (NIC) is connected


to other computers so that information can
be exchanged between them.

Sound Card converts audio signals


(microphone or audio tape) which can be
stored as a computer audio file.

Hard Disk

Flash Drive

CD-ROM

DVD-ROM

Universal Serial Bus (USB) Port

FireWire (similar to USB but faster)

Network Port (Ethernet)

Parallel Port and Serial Port

Display Adapter

Power

Software

Operating system
Gives services to
software:

Hardwar
e

Access
input/output
devices
Memory
allocations

26

The intangible set of instructions that tells


the computer what to do; known as
programs or software programs.

Operating System Software


Sets the rules for how computer hardware and
application software work together, controls the
operation of the computer.
Example: Windows

Application Software
Lets you accomplish specific tasks based on your
needs.
Examples: MS Word, Excel, Access, MS Works

Boots (starts up) the computer


Formats disks
Creates folders
Saves and retrieves files
Moves and copies files

Every Computer Has Operating System


Software!

Software that works with the operating system to meet a


specific need or perform a specific task

Examples:
MS Word
MS Excel
MS PowerPoint
Internet Explorer

Word Processing
Program that allows you to create, edit, and print
text documents
Report, flyer, memo

Spreadsheet
Numbered Rows and Lettered Columns
Intersection of a row and column is a cell
Grade book, financial info

Database
Lets you set up an electronic filing system
Enter text and numbers
Find, search, and print info in different ways
Address book, Card Catalog

I want to add one and


one

1+1
C+
+/Java/VC/VB/.N
et/C#

Human
language

Prgrammin
g language

0100110100
11

compiler

Computer
language
Operating
System

32

What is a network?
Collection of computers and devices connected together

Communications
Communications
Device
Device
Enables
Enablesaa
connection
connection
between
between
computers
computers

Communications
Communications
Media
Media
Satellites

Cables
Telephone
lines

Cellular
radio

One type is
a modem

33

Why do we need network?

To
Toshare
share
Resources
Resources
Hardware
Hardware
devices
devices Software
Software
programs
programs

To
save
To
save
Data
Data
time
time
Information
and
Information
and
money
money

34

What is a server?
Manages the
resources on
a network

A client accesses
the resources
on the server

What is the Internet?


Worldwide collection of networks that connects
millions of computers

Why do users access the Internet?


1. Communications
2. Information
3. Shopping
4. Banking and Investing
5. Classes
6. Entertainment

What is the World Wide Web (WWW)?


Billions of documents, called Web pages, available to
anyone connected to the Internet

AAWeb
Website
siteisis
aacollection
collectionof
of
related
relatedWeb
Webpages
pages

AAWeb
Webpage
pagecontains
contains
text,
text,graphics,
graphics,sound,
sound,
video,
video,and
andlinks
linksto
to
other
otherWeb
Webpages
pages

You
Youcan
canshare
share
information
informationby
by
creating
creatingWeb
Webpages
pages
or
orposting
postingphotos
photoson
on
aaphoto
photocommunity
community
3

How do you install and run a software program?

A program is a series of instructions that tells the


computer what to do

Step 2. Install the

Step 1.

software program by
instruction in the disc,
then run the program

Insert the program


disc into the CDROM drive

Step 3.
The program executes

What is a graphical user interface (GUI)?

Allows you to interact with the software


using graphics and icons

Controls how you enter data and how the


screen displays information

What is system software?


Programs that control the operations of the computer
and its devices

Operating
OperatingSystem
System(OS)
(OS)
isisaaset
setof
ofprograms
programs
that
thatcoordinates
coordinatesall
all
activities
activitiesamong
among
computer
computerhardware
hardware
devices
devicesand
andallows
allows
users
usersto
torun
run
application
applicationsoftware
software

Utility
UtilityPrograms
Programsallow
allowthe
theuser
userto
to

perform
performmaintenance-type
maintenance-typetasks
tasks
usually
usuallyrelated
relatedto
tomanaging
managingaa
computer,
computer,its
itsdevices
devicesor
orits
itsprograms
programs

What is application software?


Programs that perform specific tasks for users

Suite
Popular software applications
bundled together as a single unit
Word
Processing

Spreadsheet

Database

Presentation
Graphics

What is a programmer?
Someone who develops application or system software

Programmer writes instructions


to direct computer to process
data into information

What are the categories of computers?


Personal computers (desktop)
Mobile computers and mobile
devices
Midrange servers
Mainframe computers
Supercomputers

What

are the two most popular series of


personal computers?

PC and compatibles
use the Windows
operating system

Apple Macintosh
uses the Macintosh
operating system
(Mac OS)

What is a desktop computer?


Designed so all of the components fit on or under
a desk or table

What

is a notebook
computer?

Portable, small enough to fit on


your lap(2 lbs to 9 lbs )

Also called a laptop

Generally more expensive than


a desktop computer

47

What

is a tablet PC?

Resembles a letter-sized slate


Allows you to write on the screen
using a stylus
Smaller version is the modular
computer

What are Web-enabled handheld computers?

Allow you to check e-mail and access the Internet


Web-enabled telephone is a smart phone

48

What

is a personal digital assistant (PDA)?

Provides personal organizer functions

Calendar
Appointment book
Address book
Calculator
Notepad

49

What

types of servers are there?

Midrange server Powerful, large


computer that supports up to a few
thousand computers
Mainframe Very powerful,
expensive computer that supports
thousands of computers
Supercomputer The fastest, most
powerful, most expensive
computer. Used for applications
requiring complex mathematical
calculations
50

What

are five categories of computer users?

Home

Large Business

Small Office/
Home Office (SOHO)

Mobile

Power

What software is available for a home user?

Webaccess

Entertainment

Communications

Personalfinancemanagement

What

software is available for a small


office/home office (SOHO) user?

Local area network (LAN)

Productivity software

Specialty software

Web usage

E-mail

What

is available for
a mobile user?

Hardware

Software

Productivity
Presentation
Personal
information
manager

Notebook
computers

Handheld computers

Web-enabled
cellular phones

What are the needs of the large business user?

Web access
Public kiosk
Telecommuting
Network
Productivity software
Scheduling

What are the needs of a power user?

Speed and large amounts of storage

Types of power users

Engineers
Architects
Desktop publishers
Graphic artists

What

are some examples


of computer applications
in society?

Education
Finance
Government
Healthcare
Science
Publishing
Travel
Industry

What are information system elements ?


People
Procedures
Data
Software
Hardware

Step 1.
People
develop
procedures
for processing
data
Step 3.
Software processes
data and directs
hardware to store and
or output information

Step 2.
People use software to
enter data into
computer (hardware)

Database:
a very large, integrated
collection of data.
Models a real-world enterprise
Entities (e.g., teams, games)
Relationships
(e.g., student grade and marks)
More recently, also includes active
components , often called business logic.
(e.g., ranking system)
A Database Management System (DBMS) is a
software system designed to store, manage,
and facilitate access to databases.

From Friendster.com on-line tour

Fairly sophisticated search available


crawler indexes pages on the web
Keyword-based search for pages
But, currently
data is mostly unstructured and untyped
search only:
cant modify the data
cant get summaries, complex combinations of data

few guarantees provided for freshness of data,


consistency across data items, fault tolerance,
Web sites typically have a DBMS in the background to
provide these functions.
The picture is changing
Semantic Web can help data modeling
Research groups (e.g., at Berkeley) are working on
providing some of this functionality across multiple web
sites.

=
Thought Experiment 1:
You and your project partner are editing the
same file.
You both save it at the same time.
Whose changes survive?
A) Yours B) Partners
C) Both D) Neither
E) ???

Thought Experiment 2:
Youre updating a file.
The power goes out.
Which of your changes survive?

A) All B) None C) All Since Last Save D) ???

A major part of the software industry:


Oracle, IBM, Microsoft, Sybase
also Informix (now IBM), Teradata
smaller players: java-based dbms, devices, OO,

Lots of related industries


data warehouse, document management, storage,
backup, reporting, business intelligence, app
integration

Open Source coming on strong


MySQL, PostgreSQL, BerkeleyDB

Shift from computation to information


always true for corporate computing
Web made this point for personal computing
more and more true for scientific computing
Need for DBMS has exploded in the last years
Corporate: retail swipe/clickstreams, customer
relationship mgmt, supply chain mgmt, data
warehouses, etc.
Scientific: digital libraries, Human Genome project,
Planet Earth, physical sensors, grid physics network
DBMS encompasses much of CS in a practical discipline
OS, languages, theory, AI, multimedia, logic
Yet traditional focus on real-world apps

Users

Views describe how


users see the data.
View 1

Conceptual schema
defines logical
structure
Physical schema
describes the files
and indexes used.

View 2

View 3

Conceptual Schema
Physical Schema

DB

Conceptual schema:
Students(sid: string, name: string,
login: string, age: integer, gpa:real)
Courses(cid: string, cname:string,
View 1 View 2 View 3
credits:integer)
Enrolled(sid:string, cid:string,
Conceptual Schema
grade:string)
External Schema (View):
Physical Schema
Course_info(cid:string,
enrollment:integer)

DB

A typical DBMS has a


layered architecture.
Each database
system has its own
variations.

These layers
must consider
concurrency
control and
recovery

Query Optimization
and Execution
Relational Operators
Files and Access Methods
Buffer Management
Disk Space Management

DB

Efficient data access


Data integrity & security
Data administration
Concurrent access, crash recovery
Reduced application development time
So why not use them always?
Expensive/complicated to set up & maintain
This cost & complexity must be offset by need
General-purpose, not suited for special-purpose tasks (e.g.
text search!)

DBMS vendors, programmers


Oracle, IBM, MS, Sybase,
End users in many fields
Business, education, science,
DB application programmers
Build enterprise applications on top of DBMSs
Build web services that run off DBMSs
Database administrators (DBAs)
Design logical/physical schemas
Handle security and authorization
Data availability, crash recovery
Database tuning as needs evolve

DBMS used to maintain, query large


datasets.

can manipulate data and exploit semantics

Other benefits include:

recovery from system crashes,


concurrent access,
quick application development,
data integrity and security.

DBAs, DB developers the


bedrock of the information
economy

DBMS R&D represents a broad,


fundamental branch of the scien
of computation

Problem definition
Method (how to solve it)

Algorithm
Data structure
Verification for correctness
Analysis for efficiency

Coding in given programming language


Understanding of computer architecture
Compilation, testing, de-bugging
Documentation

Most difficult
Requires interaction between programmer
and user
Specs include:
Input data
Type, accuracy, units, range, format, location, sequence

Special symbols to signal end of data


Output data (results)
type, accuracy, units, range, format, location, headings

How is output related to input


Any special constraint

Example: find the phone no. of a person


Problems get revised often

It is the process of planning a sequence of


steps (called instructions) for a computer to
follow.
STEP 1
STEP 2
STEP 3
. . .

How Do We Write a Program?


A computer is not intelligent.
A computer frees people from repetitive and
boring tasks.

Life Cycle Phases


Problem-Solving Phase
Implementation Phase
Maintenance Phase

This series of stages is known as the


waterfall model of software development.

ANALYZE the problem and SPECIFY what the


solution must do.

Develop a GERNAL SOLUTION (Algorithm) to


solve the problem.

VERIFY that your solution really solves the


problem.

What Is an Algorithm?
A step by step procedure for solving a problem in
a finite amount of time.

The heart of the programming process.

How do you start your car?

After being satisfied with the algorithm, we


translate it into a programming language.

A set of rules, symbols, and special words


used to construct a computer program.

Translating your algorithm into a


programming language is called coding.
No single way to implement an algorithm.

With C++, we use:


Documentation your written comments
Compiler translates your program into machine
language
Main Program may call sub-algorithms

TESTING your program means running


(executing) your program on the computer,
to see if it produces correct results.

If it does not, then you must find out what is


wrong with your program or algorithm and
fix itthis is called debugging

USE and MODIFY the program to meet


changing requirements or correct errors
that show up in using it.

Maintenance begins when your program is


put into use and accounts for the majority
of effort on most programs.

Problem-Solving Phase
Analysis and Specification
General Solution (Algorithm)
Verify

Implementation Phase
Concrete Solution (Program)
Test

Maintenance Phase
Use
Maintain

DEBUG
REVISE

REVISE

DEBUG
Sh

t?
u
c
ort

DEBUG
REVISE

CODE

GOAL
TEST
THINKING

CODE

Is NOT portable

Runs only on a specific type of computer

Is made up of binary-coded instructions


(strings of 0s and 1s)

Is the language that can be directly used by


the computer

ARE portable

User writes a program in a language similar to


natural language

Examples:
FORTRAN
JAVA
C++

Most are standardized by ISO/ANSI to provide


an official description of the language

myprog.cpp

myprog.obj

myprog.exe

SOURCE

OBJECT

EXECUTABLE

written
written in
in
C++
C++

written
written in
in
machine
machine
language
language

via compiler

written
written in
in
machine
machine
language
language

via linker
other
other code
code
from
from libraries,
libraries,
etc.
etc.

A sequence is a series of statements that


execute one after the other

Selection (branch) is used to execute different


statements depending on certain conditions.

Looping (repetition) is used to repeat


statements while certain conditions are met.

A subprogram is used to break the program into


smaller units.

Statement

Statement

Statement

...

IF Condition THEN Statement1 ELSE


Statement2

True Statement1

Condition
Stateme
False Statement2
nt

...

WHILE Condition DO statement1

False
Condition
Tru
e

Statemen
t

...

SUBPROGRAM1

...

SUBPROGRAM1
a meaningful collection
of SEQUENCE,
SELECTION, LOOP,
SUBPROGRAM

Ask Questions about the data, the process, the


output, error conditions.

Look for familiar things certain situations arise


again and again.

Solve by Analogy it may give you a place to


start.

Use Means-Ends Analysis Determine the I/O


and then work out the details.

Divide and Conquer break up large


problems into manageable units

Building Block approach solve small pieces


of the problem

Merge Solutions instead of joining them


end to end to avoid duplicate steps.

Overcome mental block by rewriting the


problem in your own words.

It is a finite set of instructions which, if


followed accomplish a particular task.
It is basically used to describe a
problem solving method suitable for
implementation
as
a
computer
program.
Algorithm is independent of the
machine and language used for
implementation.

Input

Zero or more quantities are supplied


externally

Output

At least one quantity is produced

Definiteness

Each instruction is clear & unambiguous

Finiteness

It terminates after finite steps

Effectiveness

Each instruction is simple to be carried out


manually.

An unambiguous specification of a method


Is characterized by:
Ordered sequence of well-defined, effective
operations that, when executed, will produce a result
after terminating within a finite no of steps

Well-defined and effective


No ambiguity, a method must exist
Good Examples:

Add 1 to x
compute largest prime no. < 100
compute square root of x to 4 decimal
places
Bad examples:

divide 10 by x
compute largest prime
compute square root of x

Always terminate, and be sure about it


Produce correct results
this may require some hard thinking
testing helps, but is not adequate

Basic differences are:


Program is written in programming
language whereas algorithm is in
English like pseudo language.
Program may be non terminating (OS)
whereas algorithm should terminate in
finite steps.

Study of algorithm can be


classified in four distinct areas
namely how to

devise
express
validate
analyze algorithms

Devising good algorithm:

Requires study of various design techniques


Top down, bottom up and
object oriented
approaches

Expressing an algorithm:

Good algorithms are expressed using principle of


structured programming

Validation of algorithm:

It should be validated for correctness of all possible


legal inputs.
(correct, incorrect, exceptions)

Note that algorithm need not yet be expressed as a


computer program.

Analysis

of an algorithm:

Study of behavior pattern or performance


profile.
It can be calculated in terms of computing
time and space requirement in the
machine.
Time Complexity: Running time of the
program as a function of the size of input.
Space Complexity: Amount of computer
memory required during the program
execution.

In top-down model, an overview of


the system is formulated, without
going into detail for any part of it.
Each part of the system is then
refined in more details.
Each new part may then be refined
again, defining it in yet more details
until the entire specification is
detailed enough to validate the
model.

This design model can also be


applied while developing algorithm.
It basically refers to successive
refinement of the problem (task)
into sub problems (subtasks).
Refinement is applied until we reach
to the stage where the subtasks can
be directly carried out.

Main Task

subtask1

subtask2

subtask3

In bottom-up design individual parts


of the system are specified in details.
The parts are then linked together to
form larger components, which are in
turn linked until a complete system is
formed.
Object-oriented languages such as
C++ or JAVA use bottom-up approach
where each object is identified first.

It is a technique using which one can write


algorithms (programs) in top down fashion.
This technique should be used with every
level of refinement.
In SP, one entry and one exit principle is
adopted in all the constructs.
Basically there are three structures in SP

Sequential (sequence)
entry

T1
T2
exit

Selection (test)

If cond then task1


Y
Cond

task1

If cond then task1 else task2


task2
task1

Cond

Repetition
While

While (cond) do
endwhile

Do while /Repeat
Do
while (cond)

Ordered sequence
T1
T1, T2, T3
T2
T3

T1, repeat 5 times T2, T3


same as T1, T2, T2, T2, T2, T2, T3

T1
T2
T3

5 times

T1, T2, if C = true, go to second T2, T3

resulting sequence is
T1, T2, T2,...until C is true,T3

T1
T2

C
T3

What is the difference between:


S1
S2

S1
C

S2

S3

S3

Computation of income tax


Given a tax table as below, compute the tax, T, on
an income, X.
INCOME
0<=INC<=100000
100001<=INC<=200000
200001<=INC<=300000
300001<=INC

TAX
0
0+0.10*(INC-100000)
10000+0.20*(INC-200000)
30000+0.30*(INC-300000)

Here is an algorithm:
Step 1: Input INC;
Step 2: Compute tax, T;
Step 3: Output T

Step 1: Input INC;


Step 2a: if INC > 300000
then T 30000 + 0.30*(INC-300000);
Step 2b: if INC > 200000 and INC 300000
then T 10000 + 0.20*(INC-200000);
Step 2c: if INC > 100000 and INC 200000
then T 0 + 0.10*(INC-100000);
Step 2d: if INC 100000 then T 0;
Step 3: Output T

Table look-up: Consider:


special key K,
length of list, 5 or N, more generally
unsorted L = [(x1, y1), (x2, y2), (x3, y3), (x4, y4), (x5, y5)],
where xi is key and yi is corresponding output value

Problem is to search whether key K is in the list


and output relevant pair if it exist
Here is an algorithm:
Step 1: Input all data, K, and list L;
Step 2: Search for K in L;
Step 3: Output results

Here is refined version of the algorithm:


Input K;
Input (x1, y1);
Input (x2, y2);
Input (x3, y3);
Input (x4, y4);
Input (x5, y5);
If K = x1 then output (x1, y1);
If K = x2 then output (x2, y2);
If K = x3 then output (x3, y3);
If K = x4 then output (x4, y4);
If K = x5 then output (x5, y5)

This algorithm does the same thing, except


that it is compact:

Input K;
Repeat these operations 5 times:
[Input (x, y);
If K = x then output (x, y)
]

An even better algorithm:

Input n;
If n > 0 then
[Input K;
Repeat these operations n times:
[Input (x, y);
If K = x then output (x, y)
]
]

Use flowcharts to visualize the working of an


algorithm
start
For example:
S1
S2
true
C

false

S3
stop

Problem 1:
Find the roots of a quadratic equation of the
form
a*x2 + b*x + c = 0

Formula:
fact = n * n-1 * n-2 * * 2
*1

Algorithm:
input n;
i = 0; initialization
fact = 1;
looping
while (i < n)
{
i = i + 1;
fact = i * fact;
}
output fact

Execution
Let n = 4;
i = 0; fact = 1;
while loop
0 < 4; i = i +1=1; fact = 1 *
1;
1 < 4; i = i +1=2; fact = 1 *
2;
2 < 4; i = i +1=3; fact = 2 *
3;
3 < 4; i = i +1=4; fact = 6 *
4
4 < 4 is false so
exit the while loop;
output fact = 24

Вам также может понравиться