Static Data Structure
Static Data Structure
STRUCTURE
Definitions
Or
a) It makes it easy for users to access and work with the data they
need in the appropriate ways
b) It frames informaiton organisation so that machines and humans can
better understand it
c) It offers the means to manage well a considerable quantity of data
d) It provides a diverse level of data organisation
e) It provides operations on a data group such as, adding an item and
looking for the highest precedence item
f) It tells how data can be stored and accessed at its fundamental level
Limitations of Data Structures
Stacks & Queues: Limited access points; fixed size (if array-based).
Trees: Complex to balance; slow for certain searches; inefficient for sparse
data.
Graphs: High memory needs; complex algorithms; hard to visualize when large.
Foundation for Advanced Topics: Essential for fields like AI, machine learning, and big
data.
Career Preparation: Key for technical interviews and landing tech jobs.
System Design Understanding: Improves insight into how software and hardware
work together.
Data Scientist: Analyzes data using algorithms for insights and predictions.
Fixed Size: The size of a static data structure is determined at compile time and cannot be changed during runtime.
This means the amount of memory allocated is fixed.
Memory Allocation: Memory for static data structures is allocated in a contiguous block, usually on the stack, which
can lead to faster access times.
Speed: Accessing elements in static data structures is typically faster than in dynamic ones, as there’s no overhead
associated with dynamic memory allocation.
Simplicity: They are easier to implement and manage since they don't involve complex memory management or
resizing logic.
Predictable Performance: Performance (in terms of time complexity) is predictable, as the size and structure do not
change during execution.
Limited Flexibility: The inability to resize can lead to wasted space (if the allocated size is too large) or insufficient
space (if the allocated size is too small).
Examples: Common examples include arrays, static linked lists, and fixed-size records.
Advantages of static data structures over
dynamic
● Pointers
Pointer refers to a variable whose value is the address of another
variable, that is , the direct address of the memory location
Syntax for pointer is
● Applying pointers in C++
● Arrays
This mostly refers to a contiguous chunk of memory locations where each
memory location holds one fixed-length data item. Thus an Array is a physical
data structure. However, the array can also mean a logical data ttype composed
of a typically homogeneous collection of data items, each identified by an index
number
● Types of arrays
One dimensional array: this has one row which is stored in ascending storage
location
Multidimensional array: this includes as many indices For example: Two-
dimensional arrays or matrix arrays and also three dimensional arrays
Example of one dimensional array structure
Example of a two dimensional array and it’s
implementation in C++
User Defined Data Structures
● Class: This holds data members and functions whose access can be specified
as private, public or protected. It uses the ‘class’ keyword for defining the
data structure
● Structure: this groups data items of different types into a single type. For
example, a structure can be an address, which contains information such as
block number, plot number, building name, street, city, country and pin code.
The keyword “struct” is used to define this
● Union: The Union is a type of data structure where all the members of that
Union share the same memory location. If any changes are made in the union
they will also be visible to others. The ‘union’ keyword is used to define this
user-defined data type
● Enumeration: It helps to assign names to integer constants in the
program. The keyword ‘enum’ is used.
● Typedef: This defines a new name for an existing data type. It
does not create a new data class. It makes code readability easy
and gives more clarity to the user