Explain Abstract data types with its characteristics.
Whenever a programmer has been told to write any program first thing with which he is encountered is
the “problem “in writing a program. Therefore to overcome this problem first thing to be done is too get
to know about the problem and separate the necessary and unnecessary details from it so that the
programmed could have a clear view of the problem to solve or you can say to have a view of his own
on the problem, This is called Abstraction therefore with the help of abstraction it is easier for the
programmer to think about the problem to be solved.
Defined as structuring of problem into well-defined entities by defining their data and operations.
Characteristics of Abstract data types:
1. It exports a type
2. It exports set of operations
3. Operation of interface are the one and only access mechanism to the type’s data structure.
4. Axioms and preconditions define the application domain of the type.
Let us say your Learning Centre decides to store all the three types of student data:
In a single data type, which is the most suitable data type? Give its syntax
The most suitable data type in the list is the Register Number. This is because every individual upon
registration in offered a number for his name. With a simple search using the Register Number, all your
registration details will be displayed.
Further structure is the best suitable data type to store data in single data type.
For the following Graph, Write its equivalent Adjacency list and Adjacency Matrix
NODES ADJACENCY LIST
a b d e f
a 0 1 0 0 0
b 1 0 1 0 0
d 0 1 0 1 1
e 0 0 1 0 0
f 0 0 1 0 0
Explain quick sort and tree sort.
It is also known as partition sort and it is the most widely used internal sorting algo also it is one of the
fastest algo but it is also complex one to code.
The basis of quick sort is divide and conquer i.e. divide the list to be sorted into sub lists until sub lists
are sorted. Quick sort begins by picking an element to be the pivot value. Then when the pivot value is
selected the array is divided into three parts: all value less the pivot value, the pivot value, and value
greater than the pivot value .when this is finished then the pivot value is in the proper position in the
sorted array. Then quick sort recursively applies the same process to first partition, containing low
values and to the second partition which contains the high value. Each time one pivot find its final place
in the array and partition gets smaller until the complete array is sorted.
Tree sort requires additional space for a tree to be constructed. a tree sort begins by visiting each
element of the array and adding it to an ordinary tree . When all the elements of the array have been
added to the trees, we walk the tree and repopulate the array in sorted order.
In the worst case, the original tree is already in the sorted order. If this happens, then for each element
of the array we will end up adding that element as a leaf on a tree that is a linked list
Write a C-program to implement stack using array data structure and perform the following stack
operations (a) POP (b) PUSH
void push(int token)
printf("nEnter the token to be inserted:");
printf("do you want to continue insertion Y/N");
printf("nThe Stack elements are:");
char ch , a='y';
int choice, token;
printf("n3.show or display");
printf("nEnter your choice for the operation: ");
printf("nThe token deleted is %d",token);
printf("nDo you want to continue(y/n):");
Write a C program to demonstrate linked list implementation of stack
struct node *link;
} *top = NULL;
printf("nn1. Pushn2. Popn3. Displayn4. Exitn");
printf("nEnter your choice: ");
struct node *ptr;
if (top == NULL)
printf("nnStack is emptyn");
ptr = top;
while(ptr != NULL)
ptr = ptr->link;