Data structure refers to how data is organized within memory (RAM). Data stored in secondary memory, like hard drives, is managed by Database Management Systems (DBMS) or Relational Database Management Systems (RDBMS), and is typically organized using SQL in a tabular form. However, structured data in software is stored in RAM for efficient access.
How Software Works with Data
Software is essentially code stored in devices like mobile phones or computers. When we run software, it is loaded into RAM, and the processing begins.
The purpose of software code is to manipulate and operate on data. Without data, there is no software.
Local Data Storage
Files like images, videos, and documents are stored on hard drives (HDD or SSD). However, the CPU doesn’t directly process data from storage; when you open a file, it is moved to RAM, where it is processed.
Why Do We Need Data Structures?
Imagine you have a bookshelf with scattered books. Searching for a specific book takes time. However, if the books are organized by category, you can easily find the book you need. Data structures function similarly in computer programs, organizing data efficiently for quick access and manipulation.
Example: Finding the Largest Number
If you have numbers like 43, 28, 290, 555, 501, finding the largest number using traditional code would require many if-else conditions.
However, using a data structure like a list, this can be solved in just two lines of code:
This approach saves time and makes the code much more efficient.