0% found this document useful (0 votes)
54 views

Introduction

This document provides information about a computer fundamentals course, including the instructor's background and subjects taught. It also covers various topics in computer fundamentals such as definitions of a computer, common components of a computer system, applications of computers in different fields, capabilities of computers, and basics of software, networks, the internet, and the world wide web. The evaluation criteria for the course include lab performance, personal growth, term project, and exams.

Uploaded by

Mumtaz Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Introduction

This document provides information about a computer fundamentals course, including the instructor's background and subjects taught. It also covers various topics in computer fundamentals such as definitions of a computer, common components of a computer system, applications of computers in different fields, capabilities of computers, and basics of software, networks, the internet, and the world wide web. The evaluation criteria for the course include lab performance, personal growth, term project, and exams.

Uploaded by

Mumtaz Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 127

 Computer Fundamentals

 Course Plan
 Basic Understanding
 Pakistan Zindabad !!!
 Molana Sim Zehmat Chutiya
 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 e-
Government 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 70%
 Personal/Professional Growth 30%
 Term Project 30%
 Mids 30%
 Final 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 - Requires stress and
strain analysis for design of Ships, Buildings, cars,
Airplanes etc.
 Industrial Engineering - Computers deal with
design, implementation and improvement of
integrated systems of people, materials and
equipment.
 Architectural Engineering - Computers help
in planning towns, designing buildings, determining
a range of buildings on a site using both 2D and 3D
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 Memory

Input devices 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:
 Access input/output
devices
Hardware
 Memory allocations
 And much more…
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 010011010011

compiler
C++/Java/VC/V
B/.Net/C#

Human Prgramming Computer


language language language
Operating
System

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

Communications
Device Communications
Media

Enables a Satellites
Cables
connection
Telephone Cellular
between
lines radio
computers
One type is
a modem

33
 Why do we need network?

To share

Resources
Hardware
devices
Software
programs To save
Data
time
Information and
money

34
What is a server?
 Manages the
resources on
a network

 A client accesses
the resources
on the server

3
5
What is the Internet?
 Worldwide collection of networks that connects
millions of computers

3
6
Why do users access the Internet?
1. Communications
2. Information
3. Shopping
4. Banking and Investing
5. Classes
6. Entertainment

3
7
What is the World Wide Web (WWW)?
 Billions of documents, called Web pages, available to
anyone connected to the Internet

A Web site is
a collection of
related Web pages
A Web page contains
text, graphics, sound,
video, and links to You can share
other Web pages information by
creating Web pages
or posting photos on
a photo community

3
8
 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
Insert the program instruction in the disc,
disc into the CD- then run the program
ROM drive

Step 3.
The program executes

3
9
 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

4
0
What is system software?
 Programs that control the operations of the computer
and its devices

Operating System (OS)


is a set of programs
that coordinates all
Utility Programs allow the user to
activities among perform maintenance-type tasks
computer hardware usually related to managing a
devices and allows computer, its devices or its programs
users to run
application software

4
1
 What is application software?

 Programs that perform specific tasks for users


 Suite
Popular software applications
bundled together as a single unit

Word
Spreadsheet
Processing

Presentation
Database
Graphics

4
2
 What is a programmer?

 Someone who develops application or system software

 Programmer writes instructions


to direct computer to process
data into information

4
3
What are the categories of computers?

Personal computers (desktop)


Mobile computers and mobile
devices
Midrange servers
Mainframe computers
Supercomputers

4
4
Whatare the two most popular series of personal
computers?
 PC and compatibles  Apple Macintosh
use the Windows uses the Macintosh
operating system operating system
(Mac OS)

4
5
What is a desktop computer?
 Designed so all of the components fit on or under
a desk or table

4
6
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 Small Office/ Mobile


Home Office (SOHO)

Large Business Power

5
1
 What software is available for a home user?

• Web access
• Entertainment
• Communications

• Personal finance management

5
2
What software is available for a small
office/home office (SOHO) user?

 Local area network (LAN)

 Productivity software

 Specialty software

 Web usage

 E-mail

5
3
Whatis available for Notebook
computers
a mobile user?
 Hardware

 Software
 Productivity
 Presentation Handheld computers
 Personal
information
manager

Web-enabled
cellular phones

5
4
 What are the needs of the large business
user?

 Web access
 Public kiosk
 Telecommuting
 Network
 Productivity software
 Scheduling

5
5
 What are the needs of a power user?

 Speed and large amounts of storage

 Types of power users


 Engineers
 Architects
 Desktop publishers
 Graphic artists

5
6
What are some examples
of computer applications
in society?
 Education
 Finance
 Government
 Healthcare
 Science
 Publishing
 Travel
 Industry

5
7
 What are information system elements ?
 People
 Procedures
 Data Step 1. Step 2.
 Software People People use software to
 Hardware develop enter data into
procedures computer (hardware)
for processing
data
Step 3.
Software processes
data and directs
hardware to store and
or output information
5
8
 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:
 can’t modify the data
 can’t 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) Partner’s C) Both D) Neither E) ???
Thought Experiment 2:
–You’re 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.
 Conceptual schema
View 1 View 2 View 3
defines logical
structure
Conceptual Schema
 Physical schema
describes the files Physical Schema
and indexes used.
DB
 Conceptual schema:
◦ Students(sid: string, name: string,
login: string, age: integer, gpa:real)
◦ Courses(cid: string, cname:string,
credits:integer) View 1 View 2 View 3
◦ Enrolled(sid:string, cid:string,
grade:string) Conceptual Schema
 External Schema (View):
◦ Course_info(cid:string, Physical Schema
enrollment:integer)
DB
These layers
must consider
concurrency
control and
 A typical DBMS has a recovery
layered architecture. Query Optimization
 Each database system and Execution
has its own variations. 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 science
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 it—this 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 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.cp myprog.obj myprog.exe
SOURCE OBJECT EXECUTABLE

written in
written in written in
machine
C++ machine
language
language

via compiler via linker

other code
from libraries,
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

Statement1
Condition ...
Stateme
nt Statement2
 WHILE Condition DO statement1

False
Condition ...

Statement
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 N Cond Y task1


Repetition

 While
While (cond) do

endwhile

 Do while /Repeat
Do

while (cond)
 Ordered sequence
◦ T1, T2, T3 T1

T2

T3

T1
◦ T1, repeat 5 times T2, T3
 same as T1, T2, T2, T2, T2, T2, T3
T2
5 times
T3
◦ T1, T2, “if C = true, go to second T2”, T3
 resulting sequence is
T1, T2, T2,...until C is true,T3

T1

T2

C
Y

T3
 What is the difference between:

S1 S1

Y
S2 C

C S2
Y

S3 S3
Computation of income tax
 Given a tax table as below, compute the tax, T, on
an income, X.
INCOME TAX
0 <= INC <=100000 0
100001 <= INC <=200000 0 + 0.10*(INC-100000)
200001 <= INC <=300000 10000 + 0.20*(INC-200000)
300001 <= INC 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: x1 = [(-b) + (b2 – 4ac)]/2a


x2 = [(-b) - (b2 – 4ac)]/2a
Algorithm:
input a, b, c;
d = b*b – 4*a*c;
if (d ≥ 0) then
{ e = sqrt(d);
r1 = (-b + e) / (2*a);
r2 = (-b - e) / (2*a);
i1=0; i2 =0
}
else
{ e = sqrt(-d);
r1 = (-b) / (2*a);
r2 = r1;
i1= e / (2*a); i2 = -e/(2*a);
}
output r1,r2,i1,i2
Formula: Execution
fact = n * n-1 * n-2 * …* 2 Let n = 4;
*1 i = 0; fact = 1;
Algorithm: while loop
input n; 0 < 4; i = i +1=1; fact =
i = 0; initialization 1 * 1;
fact = 1;
1 < 4; i = i +1=2; fact =
looping
1 * 2;
while (i < n)
{ i = i + 1;
2 < 4; i = i +1=3; fact =
fact = i * fact; 2 * 3;
} 3 < 4; i = i +1=4; fact
output fact =6*4
4 < 4 is false so
exit the while loop;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy