Algorithm
The term algorithm is often used to refer to the logic of a program It is a step-by step description of how to arrive at the solution of the given problem. It may be formally defined as a sequence of instructions, designed in a manner that, if the instructions are executed in the specified sequence, the desired results will be obtained. In order to qualify as an algorithm, a sequence of instructions must possess the following characteristics:

Sample Algorithms

50 Students in a class appeared in their final examination. Their mark sheets have been given to you. The division column of the mark sheet contain the division (FIRST, SECOND, THIRD or FAIL) obtained by the student. Write an algorithm to calculate and print the total number of students who passed in FIRST division.

Algorithm
Step 1: Initialize Total, First Division, Total _Mark sheets _Checked to zero. Step 2: Take the mark sheet of the next student.
Step 3: Check the division column of the mark sheet to see if it is FIRST. If no, go to Step 5. Step 4: Add 1 to Total First Division.
Step 5: Add I to Total_Marksheets_Checked
Step 6: Is Total_Marksheets_Checked = 50? ifno, go to Step 2. Step 7: Print TotaI First_Division.
Step 8: Stop.
There are 100 employees in an organization. The organization wants to distribute annual bonus to the employees based on their performance. The performance of the employees is recorded in their annual appraisal forms. Every employee's appraisal form contains his/her basic salary, and the grade for his/her performance during the year. The grade is of three categories - 'A' for outstanding, 'B' for good, and 'c' for average performance. It has been decided that the bonus of an employee will be 100% of the basic salary for outstanding performance, 70% of the basic salary for good performance, 40% of the basic. salary for average performance, and zero for all other cases. Write an algorithm to calculate and print the total bonus amount to be distributed...

...ALGORITHMS AND
FLOWCHARTSALGORITHMS AND FLOWCHARTS
A typical programming task can be divided into
two phases:
Problem solving phase
produce
an ordered sequence of steps that describe
solution of problem
this sequence of steps is called an algorithm
Implementation phase
implement
language
the program in some programming
Steps in Problem Solving
First produce a general algorithm (one can use
pseudocode)
Refine the algorithm successively to get step by
step detailed algorithm that is very close to a
computer language.
Pseudocode is an artificial and informal
language that helps programmers develop
algorithms. Pseudocode is very similar to
everyday English.
Pseudocode & Algorithm
Example 1: Write an algorithm to
determine a student’s final grade and
indicate whether it is passing or failing.
The final grade is calculated as the
average of four marks.
Pseudocode & Algorithm
Pseudocode:
Input a set of 4 marks
Calculate their average by summing and dividing
by 4
if average is below 50
Print “FAIL”
else
Print “PASS”
Pseudocode & Algorithm
Detailed Algorithm
Step 1:
Input M1,M2,M3,M4
Step 2:
GRADE (M1+M2+M3+M4)/4
Step 3:
if (GRADE < 50) then
Print “FAIL”...

...INFORMATION TECHNOLOGY ASSIGNMENT
ON ALGORITHM
Done by
Densil Hamilton
INTRODUCTION
This Assignment was done to show the methods of algorithm. It outlines the meaning of algorithm and steps to be carried out to complete a give problem. Examples were also shown for the methods of representing algorithm.
What is an Algorithm?
An algorithm consists of a set of explicit and unambiguous finite steps which, when carried out for a given set of initial conditions, produce the corresponding output and terminate in finite time. (How to Solve it by Computer, RG Dromey, Prentice Hall UK, 1982)
This is done by a series of steps:
1. Input: there are zero or more quantities which are externally supplied;
2. Output: at least one quantity is produced;
3. Definiteness: each instruction must be clear and unambiguous;
4. Finiteness: if we trace out the instructions of an algorithm, then for all cases the algorithm will terminate after a finite number of steps;
5. Effectiveness: every instruction must be sufficiently basic that a person using only pencil and paper can in principle carry it out. It is not enough that each operation is definite, but it must also be feasible.
WAYS OF REPRESENTING ALGORITHMS
Two ways of represent an algorithm are:
Flowcharts
Pseudo Code...

... Syed Haseeb Hashmi
Registration # FA11-BCS-075
Course Title Design and Analysis of Algorithm
Assignment # 1
Submitted To Sir Tanveer Ahmed Siddiqui
Due Date 19-03-2013
For Odd Role Number Group
Q1. How does a flowchart help a programmer in a program development?
Ans. Flowcharts provide the visual representation of a concept and make it clear. A flow chart serves as a blueprint of the program. Flowcharts helps a programmer organize his/her thoughts in a logical order and their presentation. Program development without graphics may be less effective. In big projects it gets difficult to keep things together. Flowcharts provide flexibility, so that you can make changes and restructure the project as you move further and, according to requirement. Flowcharts act as a guide during the analysis and program development phase. Moreover they are also helpful in debugging process.
Q2. Draw a flowchart of the logical steps needed to produce a printed listing of all students over the age of 20 in a class. The input records contain the name and age of the students. Assume a sentinel value of 99 for the age field of the trailer record.
Sol.
Q3. The first 20 records in a data set are to be read and printed. Draw a flowchart for the algorithm to...

...1
FLOWCHARTS
PREPARED BY: ANUSHKA
NANCOO
2
WHAT IS A FLOWCHART?
Maps or graphical representations of a process
Illustrates the sequence of operations to be performed to get to the
solution of a problem
Useful tool for communication
3
USES OF A FLOWCHART
To see whether the steps of a process are logical
To record the sequence of tasks in a process
To uncover problems/miscommunication
To define the boundaries of a process
Aids in developing a common base knowledge about a process
BASIC FLOWCHART SYMBOLS
Connector
Decision
Input/O
utput
Flow line
Process
Terminator
Delay
4
GUIDELINES FOR DRAWING A
FLOWCHART
1.
Identify tasks
2.
Organize and document tasks
3.
Test the flowchart
4.
Challenge the flowchart
5
EXAMPLE OF A FLOWCHART
Start
Alarm rings
Delay
No
Ready
to get
up?
Hit Snooze
Button
Yes
Climb out of
bed
End
Set for 5
mins.
Average
3 times
6
7
HERE’S A QUESTION FOR YOU TO TRY..
Draw a flowchart for having a bath. Below are the steps in taking a
bath.
(1) Turn on the hot and cold taps.
(2) Is it too hot or cold? If it is, go to step 3, otherwise go to step 4.
(3) Adjust the hot and cold taps and go back to step 2.
(4) Wait for 2 minutes.
(5) Is the bath full? If it is, go to step 7, otherwise go to step 6.
(6) Go back to step 4.
(7) Turn off the hot and cold taps.
8...

...Algorithm
is a list of instructions for carrying out some process step by step
Flowchart
is a diagram representing the logical sequence in which a combination of steps or operations is to be performed
Types of Flowcharts
Program Flowchart – describes graphically in detail the logical operations and steps within a program and sequence in which these steps are to be executed for the transformation of data to produce the needed output
System Flowchart – is a graphic representation of the procedures involved in converting data on input media to data in output form
Flowcharting Symbols
[pic]
Basic Control Structure
SEQUENCE – process is executed from one to another in a straight forward manner
SELECTION – a choice is provided between two alternatives based on conditions outcome as either TRUE or FALSE
ITERATION – or loop, enables certain operations/tasks/instructions to repeat. These tasks are repeated based on conditions outcome as either TRUE or FALSE
Sequence
[pic]
Examples
The length of a rectangle is equal to 5cm and its width is equals to 3cm. Create a flowchart that will display the area and perimeter of the rectangle.
Given three numbers A=3, B=6, C=9, and D=5. Draw a flowchart to compute and print out the sum, average, and product of the given values.
Selection
[pic]
Examples
Create a flowchart for a program that...

...ISE105: Computer Fundamentals
Lecture 7
Samin Khaliq
Today’s Lecture
• Programming Languages • History of C • Problem Solving
– Flowcharts – Algorithms – Programs
• C Program • Comments
Types of Programming Languages
Low Level Languages
1. Machine language (1GL)
• • Strings of numbers giving machine specific instructions Example: Calculates nth Fibonacci number
8B542408 FA027706 B9010000 C84AEBF1 83FA0077 06B80000 0000C383 B8010000 00C353BB 01000000 008D0419 83FA0376 078BD98B 5BC3
2. Assembly language (2GL)
• • English-like abbreviations representing elementary computer operations (translated via assemblers) Example: fib:
mov edx, [esp+8] cmp edx, 0 ja @f mov eax, 0 ret …
3
Types of Languages
3. High-level languages (3GL)
• Codes similar to everyday English • Use mathematical notations (translated via compilers) • Example:
grossPay = basePay + overTimePay
• Languages:
– C, C++, Java, FORTRAN, COBOL, Pascal
4
Development of programming languages
Development of Programming Languages
• 2000 C# . . • 2001 Visual Basic .NET . . . . • 2009 Go by Google Inc. (Similar to C)
A brief history of C
• Developed Dennis M. Ritchie at AT&T Bell Labs between 1969–1973 for UNIX • Descendant of Ken Thompson’s language “B” • First published specification standard:
– Ritchie and Brian Kernighan “The C Programming Language” in 1978
– C-dialect now known as K&R-Style
• Ease of portability ⇒ language...

...Algorithms Homework – Fall 2000
8.1-1 Using Figure 8.1 as a model, illustrate the operation of PARTITION on the array A =
13 19 9 5 12 8 7 4 11 2 6 21
i j j
6 19 9 5 12 8 7 4 11 2 13 21
i i j j
6 2 9 5 12 8 7 4 11 19 13 21
i ………………………… j
return 11, SPLIT = and
8.1-2 What value of q does PARTITION return when all elements in the array A[p…r] have the same value?
q = (p+r)/2, where p = index 0, and r = highest index
8.1-3 Give a brief argument that the running time of PARTITION on a subarray of size n is (n).
In the worst case, PARTITION must move the j pointer by one element (to the 2nd to last element), and the i pointer all the way to j, making a comparison at each element along the way. Since there are n comparisons made, the running time is (n)
In the average (and best) case, PARTITION must move the j pointer to an element at or near the half-way point in the array and the i pointer all the way to j, making a comparison at each element along the way. Once again there are n comparisons made and the running time is (n)
8.2-1 Show that the running time of QUICKSORT is (n lg n) when all elements of array A have the same value.
T(n) =...

...In computer science, the analysis of algorithms is the determination of the amount of resources (such as time and storage) necessary to execute them. Most algorithms are designed to work with inputs of arbitrary length. Usually, the efficiency or running time of an algorithm is stated as a function relating the input length to the number of steps (time complexity) or storage locations (space complexity).
Algorithm analysis is an important part of a broader computational complexity theory, which provides theoretical estimates for the resources needed by any algorithm which solves a given computational problem. These estimates provide an insight into reasonable directions of search for efficient algorithms.
In theoretical analysis of algorithms it is common to estimate their complexity in the asymptotic sense, i.e., to estimate the complexity function for arbitrarily large input. Big O notation, Big-omega notation and Big-theta notation are used to this end. For instance, binary search is said to run in a number of steps proportional to the logarithm of the length of the list being searched, or in O(log(n)), colloquially "in logarithmic time". Usually asymptotic estimates are used because different implementations of the same algorithm may differ in efficiency. However the efficiencies of any two "reasonable" implementations of a given algorithm...