Introduction to Data Structures

Jul 13, 2024

Introduction to Data Structures

What is Data?

  • Dictionary Definition: Quantities, characters, or symbols on which operations are performed by a computer, stored and transmitted in the form of electrical signals.
  • Example: Performing operations on data implies they can be stored and transmitted.

Data vs. Information

  • Data: Collection of characters or symbols without inherent meaning.
  • Information: Processed data that has meaning (e.g., reversing a string to make it readable).
  • Key Insight: Data needs to be managed systematically to produce meaningful information.

Importance of Data Structures

  • Purpose: A systematic way to organize data for efficient usage (both in terms of time and space).
  • Example: Arrays as a classical data structure to store sequences of elements (e.g., integers, characters).

Example of Array

  • Instead of multiple variables for similar data, use arrays.
  • Example: Storing 100 integers in a single array vs. 100 variables.
  • Strings as sequences of characters can also be stored in arrays.

Real-Life Examples of Data Structures

1. Stack Data Structure

  • Use Case: Implementing redo and undo features.
  • Application: Google Docs, PowerPoint, Microsoft Word.
  • Mechanism:
    • Undo: Pops top element from the undo stack, places in redo stack.
    • Redo: Pops top element from redo stack, places back in undo stack.

2. Bitmap Images

  • Data Structure Used: Array
  • Mechanism:
    • Bitmap images are stored as tiny dots called pixels.
    • Pixels stored in a two-dimensional array to form an image.
  • Example: A 37x40 2D array to store a Pikachu image.

3. Social Networking (Friendship Information)

  • Data Structure Used: Graph
  • Mechanism:
    • Nodes represent individuals, edges represent friendships.
    • Example: Storing friends' relationships on Facebook.

Summary

  • Data structures provide efficient ways to manage and utilize data.
  • Essential for extracting meaningful information.
  • Widely used in various applications (e.g., undo/redo, image storage, social networking).