Data Structure
Data Structure
Characteristics of an Algorithm
● Clear and Unambiguous: The algorithm should be clear and unambiguous. Each of its steps
should be clear in all aspects and must lead to only one meaning.
● Well-Defined Inputs: If an algorithm says to take inputs, it should be well-defined inputs.
● Well-Defined Outputs: The algorithm must clearly define what output will be yielded and it
should be well-defined as well.
● Finite-ness: The algorithm must be finite, i.e. it should terminate after a finite time.
● Feasible: The algorithm must be simple,easy and practical, such that it can be executed with the
available resources. It must not contain some future technology or anything.
● Language Independent: The Algorithm designed must be language-independent, i.e. it must be
just plain instructions that can be implemented in any language, and yet the output will be the
same, as expected
Advantages of Algorithms:
● It is easy to understand.
Disadvantages of Algorithms:
● Writing an algorithm takes a long time so it is time-consuming.
Analysis of algorithm
Analysis of algorithm provides theoretical estimation for the required resources of an algorithm
to solve a specific computational problem. Analysis of algorithms is the determination of the
amount of time and space resources required to execute it.
Time complexity is a type of computational complexity that describes the time required to execute an
algorithm. The time complexity of an algorithm is the amount of time it takes for each statement to
complete. As a result, it is highly dependent on the size of the processed data. It also aids in defining an
algorithm's effectiveness and evaluating its performance.
Flowchart
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”.
Basic Symbols used in Flowchart Designs
1. Terminal: 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. Terminal is the first and last
symbols in the flowchart.
● Decision Diamond symbol represents a decision point. Decision based operations such as yes/no
question or true/false are indicated by diamond in flowchart.
● Connectors: 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.
● Flow lines: Flow lines indicate the exact sequence in which instructions are executed. Arrows
represent the direction of flow of control and relationship among different symbols of
flowchart.
Advantages of Flowchart:
● Flowcharts are a better way of communicating the logic of the system.
● Easy to understand.
● The flowchart can be reused for inconvenience in the future.
Disadvantages of Flowchart:
● It is difficult to draw flowcharts for large and complex programs.
Example : Draw a flowchart to input two numbers from the user and display the largest of two
numbers
The data structure name indicates itself by organizing the data in memory. We can say that Data
Structure is a way to store and organize data so that it can be used efficiently. The data structure is not
any programming language like C, C++, java, etc. It is a set of algorithms that we can use in any
programming language to structure the data in the memory.To structure the data in memory, 'n'
number of algorithms were proposed, and all these algorithms are known as Abstract data types. These
abstract data types are the set of rules.
For example, we can store a list of items having the same data-type using the array data structure.
There are many ways of organizing the data in the memory but one of the data structures, i.e., array in C
language.
o Efficiency: If the choice of a data structure for implementing a particular ADT is proper, it makes
the program very efficient in terms of time and space.
o Reusability: The data structure provides reusability means that multiple client programs can use
the data structure.
o Abstraction: The data structure specified by an ADT also provides the level of abstraction. The
client cannot see the internal working of the data structure, so it does not have to worry about
the implementation part. The client can only see the interface.
However, when the complexity of the program increases, the linear data structures might
not be the best choice because of operational complexities.
Non-linear data structures are further divided into graph and tree based data structures .
Non-linear data structures are further divided into graph and tree based data
structures.
1. Graph Data Structure
In graph data structure, each node is called vertex and each vertex is connected to
other vertices through edges.
To learn more, visit Graph Data Structure.
2. Trees Data Structure
Similar to a graph, a tree is also a collection of vertices and edges. However, in tree
data structure, there can only be one edge between two vertices.