Data structure
- is a representation of data and the operations allowed on that data.
-A data structure is a way to store and organize data.
-the method of representing of logical relationships.
Basic Data Structure
Linear Data Structures
Arrays
Linked Lists
Stacks
Queues
Non-Linear Data Structures
Trees
Graphs
Hash Tables
Linear: In Linear data structure, values are arrange in linear fashion.
Array: Fixed-size
Linked-list: Variable-size
Stack: Add to top and remove from top
Queue: Add to back and remove from front
Priority queue: Add anywhere, remove the highest priority
Non-Linear: The data values in this structure are not arranged in order.
Hash tables: Unordered lists which use a ‘hash function’ to insert and search
Tree: Data is organized in branches.
Graph: A more general branching structure, with less strict connection conditions than
for a tree.
Homogenous: In this type of data structures, values of the same types of data are stored.
Array
Non-Homogenous: In this type of data structures, data values of different types are grouped and stored.
Structures
Classes
Abstract Data Types (ADTs)
-stores data and allow various operations on the data to access and change it.
-A mathematical model, together with various operations defined on the model.
Data Structures
-physical implementation of an ADT.
Two Types of Abstract Data Types (ADTs)
Public Function
Private Function
Abstraction- is the structuring of a problem into well-defined entities.
Encapsulation- Hiding data.
Some of the key features of ADTs
Abstraction: The user does not need to know the implementation of the data structure only essentials
are provided.
Better Conceptualization: ADT gives us a better conceptualization of the real world.
Robust: The program is robust and has the ability to catch errors.
Encapsulation: ADTs hide the internal details of the data and provide a public interface for users to
interact with the data.
Data Abstraction: ADTs provide a level of abstraction from the implementation details of the data.
Data Structure Independence: ADTs can be implemented using different data structures.
Information Hiding: ADTs can protect the integrity of the data by allowing access only to authorized
users.
Modularity: ADTs can be combined with other ADTs to form larger, more complex data structures.
Disadvantages:
Overhead: Implementing ADTs can add overhead in terms of memory and processing, which can
affect performance.
Complexity: ADTs can be complex to implement, especially for large and complex data
structures.
Learning Curve: Using ADTs requires knowledge of their implementation and usage, which can
take time and effort to learn.
Limited Flexibility: Some ADTs may be limited in their functionality or may not be suitable for all
types of data structures.
Cost: Implementing ADTs may require additional resources and investment, which can increase
the cost of development.
Stacks- Collection with access only to the last element inserted.
Queues
-Collection with access only to the item that has been present the longest.
-Last in last out or first in first out.
List- A Flexible structure, because can grow and shrink on demand.
Inserted
Accessed
Deleted
Tree - is a collection of elements called nodes.