0% found this document useful (0 votes)
3 views

Static Data Structure

Uploaded by

marikimeshack39
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Static Data Structure

Uploaded by

marikimeshack39
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

STATIC DATA

STRUCTURE
Definitions

Is the group of data elements which provides an efficient way of


storing and organizing data in the computer for easy access and
modification

Or

A data structure is a specialized format for organizing, processing,


retrieving and storing data
Importance and Benefits of Data Structures

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

Arrays: Fixed size; slow insertion/deletion.

Linked Lists: High memory use; no quick access; slow search.

Stacks & Queues: Limited access points; fixed size (if array-based).

Trees: Complex to balance; slow for certain searches; inefficient for sparse
data.

Hash Tables: Collision issues; unordered; can waste space.

Graphs: High memory needs; complex algorithms; hard to visualize when large.

Heaps: Slow search; extra space for tree structure


Types of Data Structures
PRIMITIVE DATA TYPES
1. nteger (int): Whole numbers, positive or negative, without decimals. Used for
counting.
2. Float/Double: Numbers with decimals. Floats have less precision; doubles
have more.
3. BOolean (bool): Represents `true` or `false`. Used in logical operations.
4. Character (char): Single character, like a letter or symbol. Often uses single
quotes (e.g., `'A'`).
5. String (sometimes primitive, sometimes not): Sequence of characters. Used
for text, like `"Hello"`.
NON PRIMITIVE DATA TYPES

A) LINEAR DATA STRUCTURES

Here’s a summarized version of the text:


- Linear Data Structures: These are Data structures where elements are stored sequentially, each having a
predecessor and successor (except the first and last).
- Array: A collection of similar data types (e.g., `int`, `char`, `float`), stored with the same variable name
but accessed via unique indexes. Arrays can be one-dimensional or multi-dimensional.
- Linked List: A list of nodes where each node points to the next, stored in non-contiguous memory
locations, allowing for dynamic resizing.
- Stack: A list where elements are added or removed from one end, called the "top," following a Last-In-
First-Out (LIFO) order, like stacking plates.
- Queue: A list where elements are added at the "rear" and removed from the "front," following a First-In-
First-Out (FIFO) order, like a line of people waiting.
Efficient Problem-Solving: Teaches structured, logical approaches for finding effective
solutions.

Optimized Performance: Helps create faster and memory-efficient code.

Foundation for Advanced Topics: Essential for fields like AI, machine learning, and big
data.

Better Coding Skills: Leads to cleaner, more organized code.

Career Preparation: Key for technical interviews and landing tech jobs.

System Design Understanding: Improves insight into how software and hardware
work together.

Adaptability: Makes it easier to learn new technologies and programming languages.


CAREER PATHS IN DSA

Software Engineer: Develops and maintains applications, focusing on performance.

Data Scientist: Analyzes data using algorithms for insights and predictions.

Machine Learning Engineer: Implements algorithms for model training and


optimization.

Systems Architect: Designs efficient system architectures.

DevOps Engineer: Automates processes and optimizes deployment pipelines.

Game Developer: Creates games with efficient rendering and AI algorithms.

Embedded Systems Engineer: Programs for resource-constrained environments.


INTRODUCTION TO STATIC DATA STRUCTURES

The Static Data Strucutres is a method of storing data where the


amount of data stored and the memory used to hold it are fixed. In a
static data structure, the content of the data structure can be modified
without changing the memory space allocated to it. The size of the
structure is fixed and permanent at compile time
Characteristics of static data structures

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

● Easier to comprehend: It is easier to define and use a static


data structure than a dynamic one
● Size: It has a fixed size unlike dynamic data strucutres
● Faster: The memory for static data is assigned during the
compilation time, making the program exeecuter more uiqckly
than when it has to stop and allocate the required memory each
time, An array index can randomly access any element of an array
● Not ordinary: More suitable algorithms can be implemented
dynamically rather than statically
Disadvantages of static data
structures

● Memory wastage: Declaring an array with a large size is a memory


wastage. For example, if you declare an array of 10 and only a tiny
portion less than the declared is used, the rest of the memory will be
wasted. Therefore, it can waste a lot of space if the estimation is too high
● Insufficient memory space: Declaring an array with a fixed size leads
to a situation where the size of the array is less than what you intended
to use. In other words, there is insufficient memory for the program to
run with all data required. In nother situation, requesting a consecutive
large block may not be granted, for example, int y[6]; it has 6 elements,
but the program needs 10 memory
● Slow: Some algorithms are slower than when done dynamically.
How would you merge the two lists? The Solution with static arrays
is to define a more extensive array and copy the two arrays into a
more considerable array
Pointers, Arrays and User Defined Data
Structures

● 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

You might also like