Data Structure QB

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

DATA STRUCTURES QUESTION BANK

UNIT-1
1. What do you mean by data structure? Explain the classification of data structure. Also
explain various operations of data structure.
2. Explain how does dynamic memory allocation will help you in managing data within
data structures.
3. Define pointer. How to declare and initialize pointers, explain with an example.
4. What is a structure? How it is different from array? Explain different types of structure
declaration with examples.
5. List out the dynamic memory allocation functions with its syntax and an example.
6. Explain primitive and non-primitive data structures in detail.
7. With suitable program explain self-referential structures.
8. Explain dynamic memory allocation using single and multidimensional arrays.
9. Explain different operations of data structures with suitable examples.
10. Define Data structure. Explain different operations of data structure with suitable
examples.
11. With a programming example briefly explain the dynamic allocation functions.
12. i. list and explain linear and nonlinear data structures with examples.
ii. with an example explain structures in detail.
iii. write a program to find the sum of array elements using dynamic memory allocation.
iv. what are arrays and give the memory representation of arrays.
v. write C functions to insert an element at the beginning, at the end and at the specific
position of an array
vi. explain with programming example: i) insertion and ii) deletion in an array.
UNIT-2
1. Write the postfix form for the following expression using stack.
a. (A+B^D)/(E-F)+G
b. A*(B+D)/E-F*(G+H/K)
2. With a simple programs for each of the operations and briefly explain the implementation
of stacks using arrays.
3. What is the advantage of circular queue over ordinary queue? Write a C program to
simulate the working of circular queue of integers using array. Provide the following
operations i)insert ii)delete iii)display
4. Write an algorithm to evaluate a postfix expression and apply the same for the given
postfix expression. ABD+_EFG/+*H|I+ and assume A=6, B=2,D=3, E=3, F=8, G=2,
H=2, I=3
5. Transform the following expression to postfix expression using stacks.
a. ( A + B ) * ( C / (D – E )+F)-G
b. ( A + B * C )* (( D + E - F ) / J )
c. ( A + B ) * ( C / (D – E )+F)^G + H / I / J
d. A + B * ( C – D / E $ F ) * ( G / H ) ^ I – J + K * ( L / M )

6. Define stack. Explain implementation of push , pop and display functions of stack with
suitable examples.
7. What is queue? With the help of dynamic memory concept implement queue.
8. Write the algorithm to Evaluate the postfix expression. Evaluate the below postfix
expression using the algorithm.
a. 6 2 3 + - 3 8 2 / + * 2 | 3 +
b. 10 2 8 * + 3 – 1 2 3 * + -
9. Define stack. Write a C program demonstrating the various stack operations, including
cases for overflow and underflow of STACKS.
10. Describe queue with its array representation. Write a c program to demonstrate circular
queue operations. Write a C functions for Enqueue and Dequeue.
11. What are the different forms of expressions? Convert the following expression into
postfix expression using stack.
a. A + ( B * C ) - ( ( D * E + F ) / G )
b. ((6 + (3-2) * 4 ^ 5+7)
12. Define recursion. Write recursive program for
i) factorial of a number
ii) tower of Hanoi.
UNIT-3
1. Write and explain how do you implement the operations of stack using Singly Linked
List(SLL) with the help of C-statements.
2. Implement addition and deletion of a NODE on a Doubly Linked List(DLL) with
required C-statements.
3. With the C-statements, explain how do you create a node, add and delete on Singly
Linked List(SLL) with proper message where each node is containing the details of
employee in the form of EmpId, EmpName, and Empsalary as data fields.
4. Write C functions for the following operations on linked list:
a. Insertion at the beginning
b. Insertion at the end
c. Deletion at the beginning
d. Deletion at the end
5. Write a program that uses function to perform the following operations on Doubly linked
list.
a. Display(traversal)
b. Insertion
c. Deletion
6. Write short notes on
a. Circular linked list
b. Doubly linked list
7. Write a program that uses function to perform the following operations on Singly linked
list.
a. Creation
b. Insertion
c. Deletion
8. Write a C functions to insert at the (linked list’s data) specified position and delete before
the specified position in singly linked list.
9. What is Linked list? write the following functions for singly linked list:
a. Reverse the list
b. Concatenate two lists
10. Write a c program to demonstrate the QUEUE operations using linked list. show queue
full and empty conditions.
11. Write a function for singly linked lists with integer data, to search an element in the list
that is unsorted and a list that is sorted.
12. Differentiate between singly linked list and doubly linked list. write functions insert_front
and delete_front using doubly linked list.
13. Given 2 singly linked lists. LIST-1 and LIST-2. Write an algorithm to form a new list
LIST-3 using concatenation of the lists LIST-1 and LIST-2. Give the C function for the
same.
14. Illustrate with examples how to insert a node at the beginning, INSERT a node at
intermediate position, DELETE a node with a given value, and DELETE a node at the
end.
15. Define linked list. briefly explain the classification of linked list with its memory and
program representation.
16. Demonstrate circular linked list operations with a C program.

UNIT-4
1. What is a Tree? Define the below with suitable examples.
a. Binary tree
b. Level of binary tree
c. Complete binary tree
d. Degree of the tree
e. Skewed binary tree
f. Strictly binary tree
g. Siblings
h. Leaf nodes
i. Level of a tree
j. Height of tree
k. Descendants
l. Ancestors
m. Almost complete binary tree
2. For the given data, draw the binary search tree and show the array and linked
representation of the same: 100,85,45,55,110,20,70,65
3. Represent the below tree in figure using
a. Linked list representation
b. Left child right sibling representation.

4. Write a C routines to traverse tree using:


a. Pre-order traversal
b. Post-order traversal
5. Define threaded binary tree. Draw the one way threading and two way threading of the
following Binary tree.

6. Write recursive C functions for in-order, pre-order, post-order traversal of the binary tree.
Also give the 3 traversals for the binary tree given below.

7. Define Binary Search tree. Construct two separate binary search trees for the following
a. 22,14,18,50,9,15,7,6,12,32,25
b. 14,5,6,2,18,20,16,-1,21
8. Given inorder sequence: DJGBHEAFKIC and postorder sequence :JGDHEBKIFCA.
Construct binary tree and give preorder, traversal. Write c functions for inorder, postorder
and preorder traversals.
9. Illustrate the function to search a key value in binary search tree. Construct a BST for the
given set of values. 14,15,4,9,7,18,3,5,16,20,17,9 and perform traverse on it.
10. Define an expression tree. For the given expression traverse the tree with preorder and
postorder traversals.
a. A / B + C * D + E
b. ( ( 6 + ( 3 – 2 ) * 5 ) ^ 2 + 3 )
11. Write a function to insert an element in a binary search tree.
NODE insert(int item, NODE root)
{
NODE temp,cur,prev;
Temp=(NODE *)malloc(sizeof(NODE));
Temp->info=item;
Temp->llink=temp->rlink=NULL;

12. Give the array and linked representation of binary tree. With separate functions illustrate
recursive search and iterative search of a binary search tree.
Recursive search Iterative search

13. Write functions to illustrate “copying of binary trees”, and “testing equality of binary
trees”.
Copying of binary trees: Testing equality of binary trees

NODE copy(NODE root) int equal(NODE r1,NODE r2)


{ {
NODE temp; if(r1==NULL && r2==NULL)
if(root==NULL) return 1;
return NULL; if(r1==NULL && r2!=NULL)
temp=(NODE *)malloc sizeof(NODE)); return 0;
temp->info=root->info; if(r1!=NULL && r2==NULL)
temp->lptr=copy(root->lptr); return 0;
temp->rptr=copy(root->rptr); if(r1->info!= r2->info)
return temp; return 0;
} if(r1->info==r2->info)
return 1;
return equal(r1->llink,r2-
>llink)&&equal(r1->rlink,r2->rlink);
}

UNIT-5
1. Define Graph. For the given graph, show the adjacency matrix and adjacency list
representation of the graph.

2. What are the methods used for traversing graph? Explain any one with example and write
the C function for the same.
3. Write a C function for the insertion sort. Sort the following list using insertion sort.
50,30,10,70,40,20,60
4. What is collision? What are the methods to resolve collision? Explain linear probing with
an example.
5. Explain different types of hash function with an example.
6. Explain any 5 file operations along with syntax with example.
7. What is a graph? Explain the following terminologies used in graph with examples:
a. Connected graph
b. Directed graph
c. Multi graph
d. Complete graph
e. Sub graph
f. path
8. Explain various types of hash function that are used to place the record in the hash table.
9. Insert the following elements into an empty Red-Black tree.
10,18,7,15,16,30,25,40,60,2,1,70
10. Explain in detail splay tree and red-black tree with example
11. Write a short note on static and dynamic hashing. Explain any 3 popular HASH
functions.
12. Discuss AVL Tree. Insert the following elements into an empty AVL Tree.
3,14,7,1,8,5,11,17,13,6,23,12,20,4,16,18,24,25,19
13. Explain different graph traversal methods with algorithms.
14. Write a short note on hash table organization. Explain any three popular HASH
functions.
15. Explain BFS and DFS in detail. Write an algorithm for the same.

You might also like