Data Structures Notes

INTRODUCTION TO DATA STRUCTURES

  • Definition: A data structure is a way of organizing and storing data in a computer so that it can be accessed and modified efficiently.
  • Need for Data Structures:
    • Modification of data is straightforward and quick.
    • Helps in saving storage memory space.
    • Facilitates easy data representation and access to large databases.

CLASSIFICATION OF DATA STRUCTURES

  • Types:
    • Linear Data Structures:
    • Data arranged in a sequential manner.
    • Examples include: Array, Stack, Queue, Linked List.
    • Easier to implement but time complexity changes with data size.
    • Non-Linear Data Structures:
    • Data is stored in a hierarchical or interconnected manner.
    • Examples include: Tree, Graph.
    • Implementation is more complex, but time complexity remains consistent.

NON-PRIMITIVE DATA STRUCTURES

  • Examples:
    • Arrays
    • Linked Lists
    • Stacks
    • Queues
    • Trees
    • Graphs
    • Hash Tables

ARRAYS

  • Description: Index-based structure for storing multiple values of the same type.
  • Characteristics:
    • Initialization, Accessing elements, Searching, Sorting, Inserting, Deleting, Updating, Traversing elements.
  • Operations & Applications:
    • Used in mathematical computations, image processing, record management.
    • Real-life examples include book pages and ordered boxes.

LINKED LISTS

  • Structure: Uses pointers to connect nodes; flexibility in size.
  • Characteristics:
    • Must contain at least two fields: data and next node address.
  • Applications: Used in music players, web browsers, and applications with forward/backward navigation.

STACK

  • Definition: A Last In First Out (LIFO) data structure.
  • Characteristics & Operations:
    • Push, Pop, Peek, Isempty, Size.
  • Real-life Applications:
    • Used in recursive algorithms, call logs, and browser history.

QUEUE

  • Definition: A First In First Out (FIFO) structure.
  • Characteristics & Operations:
    • Enqueue, Dequeue, Peek, Isempty, Size.
  • Real-life Applications: Queues found in ticketing systems, stores, and one-lane roads.

TREES

  • Description: Non-linear structure resembling a hierarchy.
  • Characteristics:
    • Insertion, Deletion, Searching, Traversal, Height, Depth.
  • Applications: Used extensively in game development, databases indexing, and decision-making models.

GRAPHS

  • Definition: Composed of vertices (nodes) and edges.
  • Characteristics & Operations:
    • Add/Remove Vertex, Add/Remove Edge, Depth-First Search (DFS), Breadth-First Search (BFS).
  • Real-life Applications: Finding paths in navigation systems, representing social networks.

HASHING

  • Definition: Converts input of variable size into fixed-size output using hash functions.
  • Characteristics & Operations:
    • Searching, Deletion, Insertion.
  • Real-life Applications: Used for password verification and quick data access in databases.

OPERATIONS AND COMPLEXITY ANALYSIS

  • Complexity Analysis: Evaluates time and space resource requirements for algorithms.
    • Measuring time complexity (as a function of input size) and space complexity (memory required).

CONCLUSION

  • Advantages:
    • Improved data organization and efficiency in storage.
    • Facilitation of faster data retrieval and manipulation.
  • Disadvantages:
    • Possible increased memory and computational overheads.
    • Complexity in designing, debugging, and scaling data structures.
  • Each data structure has its specific strengths and weaknesses, and choosing the appropriate one is crucial for program efficiency.