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...

...
Notes on Algorithms, Pseudocode, and Flowcharts
Introduction
Do you like hot sauce? Here is an ‘algorithm’ for how to make a good one:
Volcanic Hot Sauce
10-12 scotch bonnets or Habanero, serrano, jalapeno
6 cloves Garlic, peeled and chopped
1/3 c Fresh lime juice
1/3 c Distilled white vinegar
2 tbl Dijon style mustard
2 tbl Olive oil
1 tsp Molasses
1/2 tsp Turmeric
1 tbl Salt or to taste
1. Combine the pepper, garlic, lime juice, vinegar, mustard, oil, molasses, turmeric, and
salt in a blender and puree until smooth. Correct the seasoning, adding more salt or
molasses to taste.
2. Transfer the sauce to a clean bottle. You can use it right away, but the flavor will improve
if you let it age for a few days. Volcanic Hot Sauce will keep almost indefinitely,
refrigerated or at room temperature. Just give it a good shake before using.
As you can see, this ‘algorithm’ is a really a recipe, that is, a set of step-by-step instructions that
takes raw ingredients and produces a tasty result. In general, an algorithm can be described as a
procedure to solve a problem.
In the context of computer programming, an algorithm, is defined as a:
“well-ordered collection of unambiguous and effectively computable operations, that
when executed, produces a result and halts in a finite amount of time.” 1
Characteristics of an Algorithm
à
Well-ordered: the steps are in a...

...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) =...

1449 Words |
6 Pages

Share this Document

{"hostname":"studymode.com","essaysImgCdnUrl":"\/\/images-study.netdna-ssl.com\/pi\/","useDefaultThumbs":true,"defaultThumbImgs":["\/\/stm-study.netdna-ssl.com\/stm\/images\/placeholders\/default_paper_1.png","\/\/stm-study.netdna-ssl.com\/stm\/images\/placeholders\/default_paper_2.png","\/\/stm-study.netdna-ssl.com\/stm\/images\/placeholders\/default_paper_3.png","\/\/stm-study.netdna-ssl.com\/stm\/images\/placeholders\/default_paper_4.png","\/\/stm-study.netdna-ssl.com\/stm\/images\/placeholders\/default_paper_5.png"],"thumb_default_size":"160x220","thumb_ac_size":"80x110","isPayOrJoin":false,"essayUpload":false,"site_id":1,"autoComplete":false,"isPremiumCountry":false,"userCountryCode":"US","logPixelPath":"\/\/www.smhpix.com\/pixel.gif","tracking_url":"\/\/www.smhpix.com\/pixel.gif","cookies":{"unlimitedBanner":"off"},"essay":{"essayId":36240316,"categoryName":"Fiction","categoryParentId":"17","currentPage":1,"format":"text","pageMeta":{"text":{"startPage":1,"endPage":3,"pageRange":"1-3","totalPages":3}},"access":"premium","title":"Algorithm and Flowchart","additionalIds":[7,93,2,44],"additional":["Education","Education\/Greek System","Awards \u0026 Events","Awards \u0026 Events\/Awards"],"loadedPages":{"html":[],"text":[1,2,3]}},"user":null,"canonicalUrl":"http:\/\/www.studymode.com\/essays\/Algorithm-And-Flowchart-1155496.html","pagesPerLoad":50,"userType":"member_guest","ct":10,"ndocs":"1,500,000","pdocs":"6,000","cc":"10_PERCENT_1MO_AND_6MO","signUpUrl":"https:\/\/www.studymode.com\/signup\/","joinUrl":"https:\/\/www.studymode.com\/join","payPlanUrl":"\/checkout\/pay","upgradeUrl":"\/checkout\/upgrade","freeTrialUrl":"https:\/\/www.studymode.com\/signup\/?redirectUrl=https%3A%2F%2Fwww.studymode.com%2Fcheckout%2Fpay%2Ffree-trial\u0026bypassPaymentPage=1","showModal":"get-access","showModalUrl":"https:\/\/www.studymode.com\/signup\/?redirectUrl=https%3A%2F%2Fwww.studymode.com%2Fjoin","joinFreeUrl":"\/essays\/?newuser=1","siteId":1,"facebook":{"clientId":"306058689489023","version":"v2.8","language":"en_US"}}