DS_Module-1 (1)
DS_Module-1 (1)
A data item that does not have subordinate data items is categorized as
an elementary item, the one that is composed of one or more
subordinate data items is called a group item.
• In contrast to static arrays, a programmer need not worry about how many
Every node in the list points to the next node in the list
Every node contains the following two types of data:
The value of the node or any other data that corresponds to that node
The last node in the list contains a NULL pointer to indicate that it is the end or
tail of the list.
Since the memory for a node is dynamically allocated when it is added to the
list
The total number of nodes that may be added to a list is limited only by the
amount of memory available.
Advantage: Easier to insert or delete data elements
There is another variable MAX, which is used to store the maximum number of
elements that the stack can store.
If top = NULL, then it indicates that the stack is empty and if top = MAX–1, then
the stack is full.
stack supports three basic operations:
The pop operation removes the element from the top of the
stack.
The elements in a queue are added at one end called the rear
and removed from the other end called the front.
Inserting It is used to add new data items to the given list of data
items.
Example: to add the details of a new student who has recently joined
the course.
Deleting It means to remove (delete) a particular data item from the
given collection of data items.
Example: to delete the name of a student who has left the course.
Data type : Data type of a variable is the set of values that the variable can take.
data types in C include int, char, float, and double.
•ADT are like user defined data type which define operations on values using
Functions without specifying what is there inside the functions and how operations
are performed
#include<stdio.h>
#include <conio.h>
int main()
{
int i, n, num, pos, arr[10];
clrscr();
printf("\n Enter the number of elements in the array : ");
scanf("%d", &n);
for(i=0;i=pos;i––)
arr[i+1] = arr[i];
arr[pos] = num;
n = n+1;
printf("\n The array after insertion of %d is : ", num);
for(i=0;i<n;i++)
Printf(“\n arr[%d]=%d", i, arr[i]);
getch();
return 0;
}
Write a program to delete a number from a given location in an array