<< Chapter < Page Chapter >> Page >

A flowchart is a visual representation of an algorithm's control flow. That representation illustrates statements that need to execute, decisions that need to be made, logic flow (for iteration and other purposes), and terminals that indicate start and end points.

To present that visual representation, a flowchart uses various symbols, which Figure 3.5.shows.

Flowchart symbol for statements, decisions, logic flows, etc.

This review was essential because we will be using these building blocks quite often today.

3. In pseudocode

Pseudocode (derived from pseudo and code) is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of programming languages, but omits detailed subroutines, variable declarations or language-specific syntax. The programming language is augmented with natural language descriptions of the details, where convenient, or with compact mathematical notation.

Example

Present the algorithm of converting an integer from decimal to binary

a. By words

Step 1: Let x is the decimal integer you want to convert and let k=1

Step 2 : Divide x by 2, saving the quotient as Q, and the remainder (in binary) as R k

Step 3 : If Q is not zero, let X=Q, and go back to step 2. Otherwise go to step 4.

Step 4 : Assume step 1-3 were repeated n times. Arrange the remainders as string for digit R n R n 1 ... R 3 R 2 R 1 .

b. As a flowchart

Flowchart of the algorithm of converting an integer from decimal to binary

c. By pseudocode

BEGIN input x.y=”” remainder=0,while (x>0) beginquotient=x/2 remainder=x mod 2y=conc(remainder,y) x=quotientend print yEND.

Example

Bubble Sort

Bubble sort is a simple sorting algorithm. It works by repeatedly stepping through the list to be sorted, comparing two items at a time and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.

5 1 4 2 8 - unsorted array

1 4 2 5 8 - after one pass

1 2 4 5 8 - sorted array

The algorithm gets its name from the way smaller elements "bubble" to the top (i.e. the beginning) of the list via the swaps.Because it only uses comparisons to operate on elements, it is a comparison sort. This is the easiest comparison sort to implement.

Here are the presentations of bubble sort algorithm

a. By words

Step 1: Get the length of the list : N and the list: list[1],list[2],…,list[N]

Step 2: M ← N.

Step 3: If M<2 then print the list, stop.

Step 4: M ← M – 1, i ← 0.

Step 5: Increase i by 1

Step 6: If i>M then go to step 3.

Step 7: If list[i]>list[i+1] swap list[i]and list[i+1]

Step 8: Go to step 5.

b. As a flow chart

Flowchart of bubble sort algorithm

c. In pseudocode

A simple way to express bubble sort in pseudocode is as follows:

BEGIN get length (list) and list’s elements for each M in length(list) down to 2 do:for each i in 1 to M-1 do: if list[ i]>list[ i+1 ] thenswap( list[i+1], list[ i ]) end ifend for end forend procedure

Comparing the three methods,especially pseudocode and flowchart we realized :

Questions & Answers

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Introduction to computer science. OpenStax CNX. Jul 29, 2009 Download for free at http://cnx.org/content/col10776/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Introduction to computer science' conversation and receive update notifications?

Ask