Introduction to Data Structures and Algorithms
Joan
Posted on June 20, 2022
Data Structures
Denotes a certain way of organizing, storing and managing data flow to increase efficiency (with respect to time and memory) of a program in a computer.Algorithms
A set of instructions to be executed in a certain way
to get the desired output.
Classification of Data Structures
Primitive Data Structures: these are numbers and characters built in a program meaning they can be manipulated by machine level instructions. Ex. integers, characters, Booleans..
Non-Primitive Data Structures: they are derived from primitive data structures thus can not be manipulated by machine level instructions. They form a set of data elements either in homogenous(same data types) or heterogenous(different data types).
Next,
Non-Primitive Data Structures are further divided into:
- Linear data structures
Elements in a linear data structure maintain a linear relationship among them and although data is arranged in a linear form, arrangement in memory may not be a sequential.
Ex. Arrays,
- Non-Linear data structures
This kind of data structure data elements form a hierarchical relationship among them.
Ex. Trees and graphs
Classification of Data Structure
Data Structures can be of two types:
- Static Data Structures:
The size of this type of structure is fixed meaning data elements can be modified without changing the memory space allocated to it.
e.g. Arrays
- Dynamic Data Structures:
This data structure allows changing the size of the memory allocated and contents of the structure can be modified during the operations performed to it or at runtime. e.g. Linked Lists
Comparison between Static vs Dynamic Data Structures
Static Data Structures | Dynamic Data Structures |
---|---|
Fixed memory size | size can be randomly updated during run time |
Memory allocation done prior to program execution | Memory allocation done during program execution |
Overflow is not possible to occur since memory allocation is fixed | Has possibilities Overflow or underflow since memory allocation is dynamic |
Posted on June 20, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.