A data structure is anything in which we can save the data in an organized form that can be retrieved efficiently and effectively. We can refer integer, float, char, rather all data types as data structures. These are basically known as primitive data structures which are already defined or built in.
There are also some complex data structures that include the following:
- Linked List
- Stack, Queue
These data structures the complex ones and are used to store large data. We can perform different set of operation on data by using these data structures. The above mentioned complex data structures are called Abstract data structures.
The user defined data structures are arrays, lists and files. In the list data structure we further have linear lists and non linear lists. Stack and queue are the examples of linear lists and trees and graphs fall in the category of non linear lists. The built in data structures include integer, float, character and pointers etc.
An algorithm is considered as a step by step procedure to perform certain specific task. It is a set of instructions to perform a predefined function. An algorithm is not a code or a program rather an algorithm is only the instructions to solve a particular problem. Through an algorithm a program is implemented. An algorithm can be expressed as a pseudocode or it can be expressed in pictorial form. The pictorial form of an algorithm is known as flowchart.
An algorithm will be more efficient when it will take less time and memory space to perform certain specific task. We can measure the performance of an algorithm on the basis of two aspects that is time and space. The algorithm should take less time to solve the problem and should also consume less memory space.
Space complexity is the memory that will be required to store the algorithm during the execution. Space complexity should be taken seriously when we have a limited amount of memory. There are three components for which an algorithm requires space:
Instruction space is the space that is required to store the executable part of the program, the instruction space is basically fixed but it can vary as the number of lines of the code or program varies.
Data space is the space in which all the variables and constants of the program are stored.
Environment space is used to store the information of the environment that is needed to continue the functionality.
Through time complexity we represent the time that is needed to run a program to solve a particular problem.