Monday, November 25, 2019

Flowcharts, Algorithms, and Pseudocodes


Flowcharts, Algorithms, and Pseudocodes
A computer works by performing a list of instructions called computer programs. These are written by programmers using a programming language. Programs are stored as a file on the hard drive when run read by the computer, and the processor reads the data in the file as a list of instructions. Everything a computer does is done by using a computer program. It is very important for beginning computer programmers to understand the basic principles of computer programming by learning flowcharts, algorithms, and pseudocodes, which provides a step-by-step process in solving any programming problems. Flowcharts, algorithms, and pseudocodes make your program understandable and it helps you write your program. But if you already understood, experienced, and good in computer programming, it is not essential to write flowcharts, algorithms, and pseudocodes for every program you are writing.

Algorithm




An algorithm is an English-like way of writing and expressing a solution to a problem. It is a step-by-step list of instructions. The algorithm or pseudocode is like a flowchart. It helps us to construct the actual program easily and clearly. As a matter of fact, a flowchart is a visual or graphical representation of an algorithm. It is also like a blueprint of a program since it served as an effective guide to our programming tasks. The creator of the algorithm is Muhammad ibn Musa al-Khwarizmi 

 Algorithm has the following characteristics:

Input. An algorithm may or may not require an input.
Output. Each algorithm is expected to produce at least one result.
Definiteness. Each instruction must be clear and unambiguous.
Finiteness. If the instructions of an algorithm are executed, the algorithm should terminate after finite number of steps.

The algorithm and flowchart include following three types of control structures.

1. Sequence. In the sequence structure, statements are placed one after the other and the execution takes place starting from up to down.
2. Branching (Selection). In branch control, there is a condition and according to a condition, a decision of either TRUE or FALSE is achieved. In the case of TRUE, one of the two branches is explored; but in the case of FALSE condition, the other alternative is taken. Generally, the ‘IF-THEN’ is used to represent branch control.
3. Loop (Repetition). The loop or repetition allows a statement(s) to be executed repeatedly based on certain loop condition (e. g. WHILE, FOR loops).

Advantages of Algorithm
• It is a step-wise representation of a solution to a given problem, which makes it easy to understand.
• An algorithm uses a definite procedure.
• It is not dependent on any programming language, so it is easy to understand for anyone even without programming knowledge.
• Every step in an algorithm has its own logical sequence so it is easy to debug.

Disadvantages of Algorithm
One disadvantage of algorithms is that they always terminate, which means there are some computational procedures - occasionally even useful ones - which are not algorithms. Furthermore, all computational procedures, whether they terminate or not, can only give computable results, so you cannot, for example, design a program, which determines a busy beaver number more quickly than could be done by actually running the associated types of turing machines.

How to write an Algorithm?

Step 1: Define your algorithms input. Many algorithms take in data to be processed, e. g. to calculate the area of rectangle input may be the rectangle height and rectangle width.
Step 2: Define the variables. Algorithm's variables allow you to use it for more than one place. We can define two variables for the rectangle’s height and rectangle’s width as HEIGHT and WIDTH (or H & W). We should use meaningful variable name e. g. instead of using H & W, use HEIGHT and WIDTH as variable name.
Step 3: Outline the algorithm's operations. Use input variable for computation purpose, e. g. to find the area of a rectangle, multiply the HEIGHT and WIDTH variable and store the value in new variable (say) AREA.  An algorithm's operations can take the form of multiple steps and even branch, depending on the value of the input variables.
Step 4: Output the results of your algorithm's operations. In case of the area of a rectangle, output will be the value stored in the variable AREA. If input variables described a rectangle with a HEIGHT of 3 and a WIDTH of 4, the algorithm would output the value of 12.

Pseudocode
            Pseudocode is a version of instructions describing each step the computer must follow. It is written in an abbreviated form of spoken language and these lie somewhere in commands written in ordinary English and those in a computer language.

Advantages of Pseudocode
·         can be done easily in a word processor

·         can be easily modified compared to flowchart

·         implements structured concepts well

·         clarifies algorithms in many cases

·         imposes increased discipline on the process of documenting detailed design

·         provides additional level at which inspection can be  performed

·         helps to trap defects before they become code

·         increases product reliability

·         may decrease the overall costs

·         Its implementation is very useful in structured design elements.

·         It can be written easily.

·         It can be read and understood easily.

·         Converting a pseudocode to programming language is very easy compared in converting a flowchart to  programming language


 Disadvantages of Pseudocode
·         It is not visual.
·         creates an additional level of documentation to maintain
·         introduces error possibilities in translating to code
·         may require tool to extract pseudocode and facilitate drawing flowcharts
·         There is no accepted standard, so it varies widely from company to company.
·         We do not get a picture of the design.
·         There is no standardized style or format, so one  pseudocode may be different from the other.
·         For a beginner, it is more difficult to follow the logic or write pseudocode as compared to the flowchart.
   
Flowchart


flowchart is a graphical representation of a program. It shows the logical sequence of instruction, which a computer has to follow. The first design of the flowchart goes back to 1945 which was designed by Dr. John Von Neumann (see Figure 2). The individual instructions in the flowchart are connected by arrow lines. These lines indicate the order on how instructions are followed or executed by the computer. The major uses of the flowchart are in the program documentation and program presentation.
The flowchart can help us view the relationships between two or more parts and subparts of the program. Moreover, it improves the clarity of our logical thoughts, since we had seen its relationships with each other in graphical form. The computer program involves three basic main operations:

Input (to enter data)
Process (to calculate or make choices)
Output (to produce a result or report)


Symbol
Name
Meaning and Usage

Oval
Terminal symbol
signifies the start or end of a program

Parallelogram
Input/Output symbol
indicates where the data are to be entered or results to be displayed

Rectangle
Process symbol
specifies processing procedures that usually involve calculations

Diamond
Decision symbol
denotes a choice or decision to be made by the computer


Arrow Heads
Flow lines
specifies the sequence or order of instruction

Connector
Flow connector
(On-Page connector)
connects various sub-parts of a flowchart. The circle may contain a number or a letter.

Hexagon
Initialization symbol
initializes or stores the first values of the variables.


Pentagon

Off-Page connector
connects the flowchart to the next page if it would not fit in one page

  
Flowchart and Algorithm: Elements and Its Structure
Since the algorithm and flowchart are guides and blueprints in order for us to design and develop computer programs successfully, then the following structures and elements are also applicable or “ready-to-apply” in the actual coding of our programs.

A. Constants - are literal values that do not change during program execution. It can be of the numeric or string data type.
Numeric Constant. This may be an integer (whole number) or a real number (with a decimal point). It may be preceded by a positive (+) or a negative (-) sign.
String Constant. This is a character or group of characters enclosed in double quotation marks (“) or in some cases, in a single quote (‘). Numbers 0 to 9, letters of the alphabet from A to Z and all special characters, such as space, *, %, $, _, &, and many others are also considered as string constants if they are enclosed by a pair of quotes.
B. Variables - is a portion of the computer’s main memory used to store a numeric or string constant. The value stored in the variable must be given a unique variable name, and it can only hold one value at a given time.

Variable names must conform to the following requirements:
• must contain only letters, numbers, or an underscore
• must begin with a letter
• must end either with a letter or a number
• must be unique that is, not the name of another variable
• must not be any of the programming languages keywords, such as for, while, do, case, switch, if, else, default, break, try, catch, finally, and many others.

Operators or Notations Used In Flowcharting
These logical operators were originated and patterned from the formulas used to invent the computer itself.




Two Types of Computer Programming Paradigm



Two Types of Computer Programming Paradigm

1.    Structured Programming 
programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of subroutines, block structures, and for and while loops - in contrast to using simple tests and jumps, such as the goto statement, which could lead to "spaghetti code", which is difficult both to follow and to maintain.
       It is also known as procedural programming that uses the principles of the Top-Down Design Principle, which was first created by Dr. Edsger W. Dijktstra in the 1960s. It uses the following control structures:
a. Sequence - ordered statements or subroutines executed in sequence
b. Selection/Condition - one or a number of statements that are executed depending on the state of the program; This is usually expressed with keywords, such as if-then-else and switch-case statements.
c. Iteration/Loops - a statement or block is executed until the program reaches a certain state, or operations have been applied to every element of a collection. This is usually expressed with keywords, such as while, do-while, repeat-until, for. Often it is recommended that each loop should only have one entry point (and in the original structural programming, also only one exit point, and a few languages enforce this).
Examples of structure programming language are as follows: COBOL, ALGOL, FORTRAN, SNOBOL, LOGO, Pascal, BASIC, Modula-2, C, Perl, and PL/I.
2.    Object Oriented Programming
A  programming a paradigm based on the concept of "objects", which are data structures that contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. A distinguishing feature of objects is that an object's procedures can access and often modify the data fields of the object with which they are associated (objects have a notion of "this"). In OO programming, computer programs are designed by making them out of objects that interact with one another. There is significant diversity in object-oriented programming, but most popular languages are class-based, meaning that objects are instances of classes, which typically also determines their type.
This object-oriented programming concept was first introduced in the 1960s in a programming language called Simula 67, which is created by Ole-Johan Dahl and Kristen Nygaard at the Norwegian Computing Center in Oslo, Norway.
There are three (3) major features in object-oriented programming: encapsulation, inheritance, and polymorphism.
Encapsulation is the inclusion within a program object of all the resources need for the object to function. Basically, the methods and the data.
Inheritance is a mechanism where you can derive a class from another class for a hierarchy of classes that share a set of attributes and methods.
Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The instances depend upon the type of data used in the operation. The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. Real-life examples of polymorphism, a person at the same time can have the same characteristic.
Examples of an object-oriented programming language areas follows Java, C++, C#, Python, PHP, JavaScript, Ruby, Perl, Object Pascal, Objective-C, Dart, Swift, Scala, Common Lisp, and Smalltalk.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My Facebook address is https://www.facebook.com/profile.php?...

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.



Thank you very much for your help and support.