Data Structure & Algorithm Data Structure: Afrah Ahamed Musthafa Iii BSC It
Data Structure & Algorithm Data Structure: Afrah Ahamed Musthafa Iii BSC It
DATA STRUCTURE
DEFINITION
DEFINITION
• How data is stored: Whether data is stored in contiguous memory locations (like in an array) or as linked
objects (like in linked lists).
• How data can be accessed: Some data structures are designed to allow fast access to any data element
(random access), while others only allow sequential access.
• How data is modified: Operations such as insertion, deletion, and searching must be supported by the data
structure, and the efficiency of these operations can vary depending on the data structure used.
Data Structure and Algo 4
rithm
•These types have a predefined size and structure that the computer
can interpret directly. Examples include:
•int
•float
•char
•boolean
Data Structure and
5
Algorithm
STRUCTURES
b. Non-Primitive Data Structures
Linear means that elements are arranged in a sequence, one after the other.
Examples include:
Non-linear data structures don’t store data elements in a linear sequence. Instead, they organize data
in a hierarchical manner.
1. Trees: A tree is a hierarchical structure consisting of nodes, where each node has a value and
pointers to child nodes.
2. Graphs: A graph is a set of nodes connected by edges, which can be directed or undirected.
3. Heaps: A type of tree-based structure that satisfies the heap property (either max-heap or min-
heap).
4. Hash Tables: A data structure that maps keys to values using a hash function for efficient access.
Data Structure and Algo 8
rithm
OPERATIONS ON DATA
STRUCTURES
The functionality of data structures comes from the operations that can
be performed on them. These include:
•Searching: Finding the location of a particular element within the data structure.