DSA Introduction Notes
What is Data Structure?
A data structure is a way of organizing data in main memory so programs can use it
efficiently. Library analogy: A library has sections (CS, Law, Commerce). Each section
has racks, each rack has shelves, and each shelf contains related books. Data = books,
Structure = sections+racks+shelves. Because everything is organized, you quickly go
to the correct section instead of searching the whole library.
Programs, Data and Data Structures
A program is a set of instructions. Data is usually stored permanently on the hard
drive/SSD. When a program runs, the required data is loaded into RAM (main memory).
Data structures organize this data in RAM so the CPU can access it efficiently.
Why Organize Data?
Faster searching, sorting and retrieval; easier insertion, deletion and updates; better
memory usage; improved readability and maintenance.
Algorithm
An algorithm is a finite step-by-step procedure to solve a problem. Example: Tea recipe
or Google Maps directions.
Properties of Algorithm
Finiteness, Definiteness, Input, Output, Effectiveness, Generality.
Importance of DSA
1. Faster programs. 2. Better memory usage. 3. Solves complex problems. 4. Required
for coding interviews. 5. Helps build scalable software.
Impact of Efficient Algorithms
Less execution time, lower CPU/RAM usage, better user experience.
Real-world Applications
Social networks use graphs; search engines use hashing; databases use trees; GPS
uses graphs; browser back button uses stack; printer queue uses queue.