Data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. A data structure is a special format for organizing and storing data. General data structure types include arrays, files, linked lists, stacks, queues, trees, graphs, and so on.
Depending on the organization of the elements, data structures are classified into types:
- Linear data structures: Elements are accessed in a sequential order but it is not compulsory to store all elements sequentially. Examples: linked lists, stacks, queues.
- Non-linear data structures: Elements of this data structure are stored/accessed in a non-linear order. Examples: Trees and graphs.
An algorithm is the step-by-step unambiguous instructions to solve a given problem.
- In the traditional study of algorithms, there are two main criteria for judging the merits of algorithms:
- Correctness (does the algorithm give a solution to the problem in a finite number of steps?)
- Efficiency (how much resources (in terms of memory and time) does it take to execute.)