What is Data Structure ?
As the name suggests it is the Structure of data or in other
words structure of organizing the data in memory. Data Structure is not a
programming language rather it is a set of algorithms to structure the data in
memory.
Types of Data Structure:
1) Primitive
2) Non-Primitive
a) Linear
b) Non-Linear
Primitive: Primitive data structures are pre-defined
within the compiler library. Users can use those to hold a single value.
Examples are int, char, float, double etc.
Non-Primitive: Non primitive data structures
are defined by the users like Linked List, Graphs, Trees, Stack, Queue etc.
Linear: The arrangement
of data is in sequential manner or linear form. Arrays, Linked-list, Stack, Queues
uses this type of data structure.
Non-Linear: Here the arrangement of
data doesn’t maintain any order. Data Structure like Graphs, Trees, Heap are
this type only.
Advantages of Data structures
The following are the advantages of a data structure:
- 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.
- Reusability: The
data structures provide reusability means that multiple client programs
can use the data structure.
- 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.
Major Operations
· Traversing: We can iterate through all elements in the data structure.
· Searching: We can search for any element in a data structure.
· Sorting: We can sort the elements of a data structure either in an ascending or descending order.
· Insertion: We can also insert the new element in a data structure.
· Updation: We can also update the element, i.e., we can replace the element with another element.
· Deletion: We can also perform the delete operation to remove the element from the data structure.
What is an Algorithm?
The formal definition of an algorithm is that it contains
the finite set of instructions which are being carried in a specific order to
perform the specific task. It is represented using pseudo code or flowchart.
What are the characteristics of an Algorithm?
- Input: An algorithm must
have some inputs.
- Output: We will get 1 or
more output at the end of an algorithm.
- Unambiguity: An algorithm should
be unambiguous which means that the instructions in an algorithm should be
clear and simple.
- Finiteness: An algorithm should
have finiteness. Here, finiteness means that the algorithm should contain
a limited number of instructions, i.e., the instructions should be
countable.
- Effectiveness: An algorithm should
be effective as each instruction in an algorithm affects the overall
process.
- Language independent: An
algorithm must be language-independent so that the instructions in an
algorithm can be implemented in any of the languages with the same output.
Example : Pseudocode for checking greatest number among 3
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a > b
If a > c
Display
a is the largest number.
Else
Display
c is the largest number.
Else
If b > c
Display
b is the largest number.
Else
Display
c is the greatest number.
Step 5: Stop

Comments
Post a Comment