You are on page 1of 13

Introduction to Computing

Introduction to Computing

Chapter 7
Flowcharts & Data Structure

Ramy Francis Page 1 of 13


Introduction to Computing

Flowcharts

What is a Flowchart?
A flowchart is a blueprint that pictorially represents the algorithm and its steps. The steps of a flowchart
do not have a specific size and shape rather it is designed in different shapes and sizes.

Flowchart is a graphical representation of an algorithm. Programmers often use it as a program-


planning tool to solve a problem. It makes use of symbols which are connected among them to
indicate the flow of information and processing. The process of drawing a flowchart for an algorithm
is known as “flowcharting”.

A flowchart is a graphical representations of steps. It was originated from computer science as a tool
for representing algorithms and programming logic but had extended to use in all other kinds of
processes. Nowadays, flowcharts play an extremely important role in displaying information and
assisting reasoning. They help us visualize complex processes, or make explicit the structure of
problems and tasks. A flowchart can also be used to define a process or project to be implemented.

Benefits of Flowchart
Simplify the Logic: As it provides the pictorial\visual representation of the steps; therefore, it
simplifies the logic and subsequent steps. It helps to clarify complex processes.

Makes Communication Better: Because of having easily understandable pictorial logic and steps,
it is a better and simple way of representation. It helps team members gain a shared understanding
of the process and use this knowledge to collect data, identify problems, focus discussions, and
identify resources.

Ramy Francis Page 2 of 13


Introduction to Computing

Effective Analysis: Once the flow-chart is prepared, it becomes very simple to analyze the problem
in an effective way. It identifies steps that do not add value to the internal or external customer,
including delays; needless storage and transportation; unnecessary work, duplication, and added
expense; breakdowns in communication.

Useful in Coding: The flow-chart also helps in coding process efficiently, as it gives directions on
what to do, when to do, and where to do. It makes the work easier. It serves as a basis for designing
new processes.

Proper Testing: Further, flowchart also helps in finding the error (if any) in program.

Applicable Documentation: Last but not the least, a flowchart also helps in preparing the proper
document (once the codes are written).

Flowchart Symbols
Different flowchart shapes have different conventional meanings. The meanings of some of the more
common shapes are as follows:

1. Terminator
The terminator symbol represents the starting or ending point of the system. The oval symbol
indicates Start, Stop and Halt in a program’s logic flow. A pause/halt is generally used in a
program logic under some error conditions. Also known as Terminal (Terminator) is the first and
last symbols in the flowchart.

2. Process \ Processing
A box indicates some particular operation. A box represents arithmetic instructions. All arithmetic
processes such as adding, subtracting, multiplication and division are indicated by action or
process symbol.

3. Input/Output:
The A parallelogram denotes any function of input/output type. It represents information entering
or leaving the system. An input might be an order from a customer. Output can be a product to
be delivered. Program instructions that take input from input devices and display output on output
devices are indicated with parallelogram in a flowchart.

Ramy Francis Page 3 of 13


Introduction to Computing

4. Decision
The A diamond represents a decision or branching point. Lines coming out from the diamond
indicates different possible situations, leading to different sub-processes. Decision based
operations such as yes/no question or true/false are indicated by diamond in flowchart.

5. Connectors (On-Page Reference)


Whenever flowchart becomes complex or it spreads over more than one page, it is useful to use
connectors to avoid any confusions. It is represented by a circle. This symbol would contain a
letter inside. It indicates that the flow continues on a matching symbol containing the same letter
somewhere else on the same page.

6. Connectors (Off-Page Reference)


This symbol would contain a letter inside. It indicates that the flow continues on a matching
symbol containing the same letter somewhere else on a different page.

7. Document
This represents a printout, such as a document or a report.

8. Storage
This represents a storage of data on a magnetic disk.

Ramy Francis Page 4 of 13


Introduction to Computing

Advantages of Flowchart:
 Flowcharts are better way of communicating the logic of system.
 Flowcharts act as a guide for blueprint during program designed.
 Flowcharts helps in debugging process.
 With the help of flowcharts programs can be easily analyzed.
 It provides better documentation.
 Flowcharts serve as a good proper documentation.

Disadvantages of Flowchart:
 It is difficult to draw flowchart for large and complex programs.
 In this there is no standard to determine the amount of detail.
 Difficult to reproduce the flowcharts.
 It is very difficult to modify the Flowchart.

Example: Draw a flowchart to input two numbers from user and display the
largest of two numbers

Ramy Francis Page 5 of 13


Introduction to Computing

Example: Draw a flowchart to find the sum of 2 numbers

Example: Draw a flowchart to calculate the profit and loss

Ramy Francis Page 6 of 13


Introduction to Computing

Data Structure

Introduction
Data Structure can be defined as the group of data elements which provides an efficient way of storing
and organizing data in the computer so that it can be used efficiently. Some examples of Data
Structures are arrays, Linked List, Stack, Queue, etc. Data Structures are widely used in almost every
aspect of Computer Science I.e. Operating System, Compiler Design, Artificial intelligence, Graphics
and many more.
Data Structures are the main part of many computer science algorithms as they enable the
programmers to handle the data in an efficient way. It plays a vital role in enhancing the performance
of a software or a program as the main function of the software is to store and retrieve the user's data
as fast as possible.
Data Structure is a way of collecting and organizing data in such a way that we can perform operations
on these data in an effective way. Data Structures is about rendering data elements in terms of some
relationship, for better organization and storage. For example, we have some data which has, player's
name "Salah" and age 26. Here "Salah" is of String data type and 26 is of integer data type.
We can organize this data as a record like Player record, which will have both player's name and age
in it. Now we can collect and store player's records in a file or database as a data structure. For
example: "Ronaldo" 30, "Benzema" 31, "Messi" 33.
If you are aware of Object Oriented programming concepts, then a class also does the same thing, it
collects different type of data under one single entity. The only difference being, data structures
provides for techniques to access and manipulate data efficiently.
In simple language, Data Structures are structures programmed to store ordered data, so that various
operations can be performed on it easily. It represents the knowledge of data to be organized in
memory. It should be designed and implemented in such a way that it reduces the complexity and
increases the efficiency.

Ramy Francis Page 7 of 13


Introduction to Computing

Basic Terminology
Data structures are the building blocks of any program or the software. Choosing the appropriate data
structure for a program is the most difficult task for a programmer. Following terminology is used as
far as data structures are concerned.
Data: Data can be defined as an elementary value or the collection of values, for example, student's
name and its id are the data about the student.
Group Items: Data items which have subordinate data items are called Group item, for example,
name of a student can have first name and the last name.
Record: Record can be defined as the collection of various data items, for example, if we talk about
the student entity, then its name, address, course and marks can be grouped together to form the
record for the student.
File: A File is a collection of various records of one type of entity, for example, if there are 60
employees in the class, then there will be 20 records in the related file where each record contains
the data about each employee.
Attribute and Entity: An entity represents the class of certain objects. it contains various attributes.
Each attribute represents the particular property of that entity.
Field: Field is a single elementary unit of information representing the attribute of an entity.

Need of Data Structures


As applications are getting complexed and amount of data is increasing day by day, there may arise
the following problems:

Processor speed: To handle very large amount of data, high speed processing is required, but as
the data is growing day by day to the billions of files per entity, processor may fail to deal with that
much amount of data.

Data Search: Consider an inventory size of 106 items in a store, if our application needs to search
for a particular item, it needs to traverse 106 items every time, results in slowing down the search
process.

Multiple requests: If thousands of users are searching the data simultaneously on a web server,
then there are the chances that a very large server can be failed during that process

In order to solve the above problems, data structures are used. Data is organized to form a data
structure in such a way that all items are not required to be searched and required data can be
searched instantly.

Advantages of Data Structures

Efficiency: Efficiency of a program depends upon the choice of data structures. For example:
suppose, we have some data and we need to perform the search for a particular record. In that case,

Ramy Francis Page 8 of 13


Introduction to Computing

if we organize our data in an array, we will have to search sequentially element by element. hence,
using array may not be very efficient here. There are better data structures which can make the
search process efficient like ordered array, binary search tree or hash tables.
Reusability: Data structures are reusable, i.e. once we have implemented a particular data structure,
we can use it at any other place. Implementation of data structures can be compiled into libraries
which can be used by different clients.
Abstraction: Data structure is specified by the ADT which provides a level of abstraction. The client
program uses the data structure through interface only, without getting into the implementation
details.

Major Operations on Data Structures


1. Traversing: Every data structure contains the set of data elements. Traversing the data
structure means visiting each element of the data structure in order to perform some specific
operation like searching or sorting. Example: If we need to calculate the average of the marks
obtained by a student in 6 different subject, we need to traverse the complete array of marks
and calculate the total sum, then we will devide that sum by the number of subjects i.e. 6, in
order to find the average.
2. Insertion: Insertion can be defined as the process of adding the elements to the data structure
at any location. If the size of data structure is n then we can only insert n-1 data elements into
it.
3. Deletion: The process of removing an element from the data structure is called Deletion. We
can delete an element from the data structure at any random location. If we try to delete an
element from an empty data structure then underflow occurs.
4. Searching: The process of finding the location of an element within the data structure is called
Searching. There are two algorithms to perform searching, Linear Search and Binary Search.
We will discuss each one of them later in this tutorial.
5. Sorting: The process of arranging the data structure in a specific order is known as Sorting.
There are many algorithms that can be used to perform sorting, for example, insertion sort,
selection sort, bubble sort, etc.
6. Merging: When two lists List A and List B of size M and N respectively, of similar type of
elements, clubbed or joined to produce the third list, List C of size (M+N), then this process is
called merging.

Ramy Francis Page 9 of 13


Introduction to Computing

Basic types of Data Structures


As we have discussed above, anything that can store data can be called as a data structure, hence
Integer, Float, Boolean, Char… etc., all are data structures. They are known as Primitive Data
Structures. Then we also have some complex Data Structures, which are used to store large and
connected data. Some example of Abstract Data Structure is; Linked List, Tree, Graph, Stack,
Queue… etc. All these data structures allow us to perform different operations on data. We select
these data structures based on which type of operation is required.

Primitive Data Structures (Built-in Data Structure)

Integer:

The integer data type contains the numeric values. It contains the whole numbers that can be either
negative or positive. When the range of integer data type is not large enough then in that case, we
can use long.

Float:

The float is a data type that can hold decimal values. When the precision of decimal value increases
then the Double data type is used.

Boolean:

It is a data type that can hold either a True or a False value. It is mainly used for checking the
condition.

Ramy Francis Page 10 of 13


Introduction to Computing

Character:

It is a data type that can hold a single character value both uppercase and lowercase such as 'A'
or 'a'. hold a single character value both uppercase and lowercase such as 'A' or 'a'.

Abstract Data Structures (User Defined Data Structure)

Arrays:

An array is a collection of similar type of data items and each data item is called an element of the
array. The data type of the element may be any valid data type like char, int, float or double. The
elements of array share the same variable name but each one carries a different index number
known as subscript. The array can be one dimensional, two dimensional or multidimensional. The
individual elements of the array age are: age[0], age[1], age[2], age[3],......... age[98], age[99].

Linked List:

Linked list is a linear data structure which is used to maintain a list in the memory. It can be seen
as the collection of nodes stored at non-contiguous memory locations. Each node of the list
contains a pointer to its adjacent node.

Ramy Francis Page 11 of 13


Introduction to Computing

Stack:

Stack is a linear list in which insertion and deletions are allowed only at one end, called top. A stack
is an abstract data type (ADT), can be implemented in most of the programming languages. It is
named as stack because it behaves like a real-world stack, for example: - piles of plates or deck of
cards etc.

Queue:

Queue is a linear list in which elements can be inserted only at one end called rear and deleted
only at the other end called front. It is an abstract data structure, similar to stack. Queue is opened
at both end therefore it follows First-In-First-Out (FIFO) methodology for storing the data items.

Trees:

Trees are multilevel data structures with a hierarchical relationship among its elements known as
nodes. The bottommost nodes in the herierchy are called leaf node while the topmost node is called
root node. Each node contains pointers to point adjacent nodes. Tree data structure is based on
the parent-child relationship among the nodes. Each node in the tree can have more than one

Ramy Francis Page 12 of 13


Introduction to Computing

children except the leaf nodes whereas each node can have atmost one parent except the root
node.

Graphs:

Graphs can be defined as the pictorial representation of the set of elements (represented by
vertices) connected by the links known as edges. A graph is different from tree in the sense that a
graph can have cycle while the tree can not have the one. is a networked data structure that
connects a collection of nodes called vertices, by connections, called edges. An edge can be seen
as a path or communication link between two nodes. These edges can be either directed or
undirected. If a path is directed then you can move in one direction only, while in an undirected
path the movement is possible in both directions.

Real life application of DS

You can watch this video to get an idea of how data structures is used in real life applications
around you. (https://www.youtube.com/watch?v=d_XvFOkQz5k).

Ramy Francis Page 13 of 13

You might also like