Introduction to Data Structures Data structures are methods to store and organize data efficiently for access and modification.
Need for Data Structures They improve data handling, optimize memory usage, and make algorithms efficient.
Classification of Data Structures 1. Primitive: int, char, float, double 2. Non-Primitive: arrays, lists, stacks, queues, trees, graphs.
Primitive Data Types Basic types directly supported by programming languages.
Non-Primitive Data Types Formed using primitive types. Examples: arrays, stacks, queues, etc.
Pointers – Definition A pointer is a variable that stores the memory address of another variable. Code Example: #include <stdio.h> int main(){int a=10;int *p=&a;printf("Value=%d",*p);return 0;}
Pointer Concepts Pointers allow dynamic data access and manipulation through memory addresses.
Array of Pointers An array containing pointers to variables or strings. Code Example: #include <stdio.h> int main(){int a=10,b=20,c=30;int *arr[3]={&a,&b,&c};for(int i=0;i<3;i++)printf("%d\n",*arr[i]);return 0;}
Structure and Pointers Pointers to structures allow easy data access and updates. Code Example: #include <stdio.h> struct Student{int id;char name[20];};int main(){struct Student s={1,"Raj"};struct Student *p=&s;printf("%d %s",p->id,p->name);return 0;}
Conclusion Pointers and data structures form the backbone of memory and data management in C programming.