Data Structures
- Data structures are fundamental concepts in computer science, utilised to organise and store data on a computer.
- The three basic types of data structures are Primitive, Linear, and Non-linear.
- Primitive data structures are the simplest kind; these include integers, floats, characters, and booleans.
- Linear data structures are collections of items where data elements are arranged sequentially. Common examples are arrays, linked lists, stacks, and queues.
- Non-linear data structures are those where data elements are not arranged in a sequential manner. These include trees and graphs.
- Array is a type of linear data structure consisting of a collection of elements, identified by array index or key. Each item is stored in a contiguous memory location.
- A linked list is another linear data structure where data elements are stored at non-contiguous memory locations, and each element points to the next one. They allow for efficient insertion or deletion of elements from the list.
- A stack operates on the principle of ‘last-in, first-out’ (LIFO). Items added last are the first to be removed and vice versa.
- Queues operate on the principle of ‘first-in, first-out’ (FIFO). Items that are added first are the first to be removed.
- Trees are hierarchical data structures with a set of linked nodes where each node is connected to subsequent lower hierarchies. It has specific structure comprising root, nodes and leaves.
- Graphs are an example of a complex, non-linear data structure that can reflect networks of many-to-many associations among items.
- The efficient use of data structures can significantly improve the speed of a programme or algorithm.
- Selecting the right data structure depends on the nature of the application and the operations required to be performed.