Updated:13/08/2023 by Computer Hope
Go BackDynamic data structures allocate blocks of memory from the heap as required to program in dataStuctutreDynamic block are link those blocks together into some kind of data structure using pointers. When the data structure no longer use of a block of memory, it will free the block to the heap for reuse. This recycling makes very optimise use of memory.
//WAP TO CREATE DYNAMIC STRUCTURE
#include<stdio.h>
#include<alloc.h>
struct student
{
int sno,m;
char sname[20];
float per;
};
void main()
{
struct student *p;
p = ( struct student * ) malloc (sizeof ( struct student ));
printf("\n enter sno,m,sname of student");
scanf("%d%d%s" , &p->sno , &p->m , p->sname );
p->per=p->m/3.0;
printf("\n %d %d %s" , p->sno , p->m , p->sname , p->per );
free(p);
}
In this article ,Dynamic data structures are those in which the size of the structure can be changed at runtime. Examples of dynamic data structures in Java include linked lists, stacks, queues, and trees. Since these data structures can grow or shrink as needed, they are often used for more complex and larger data sets.