You are on page 1of 6

Data Structures & Algorithm (PCC-CS301)

CSE 2nd Year


Chapter wise questions
(Introduction to Data Structure, Queue, Tree, Searchin,
Sorting Hashing)

INTRODUCTION TO DATA STRUCTURES:


1. What is an abstract data type? What do you mean by dynamic data structure?
2. T(n) =4n2 +3n logn ,express T(n) in Big-O notation.
3. Define time & space complexity of an algorithm?
4. What are the basic properties of an algorithm?
5. What do you mean by best, average & worst case time complexity of an algorithm?
6. Give the examples of linear and non-linear data structures.
7. Define the term data structure.
8. Define Big-O, Ω, θ notations. Prove that 10n2+4n+2 = θ (n4).
9. Each element of an array A[20][20] requires 4 bytes of storage. Base address of A is
2000, determine the location of A[10][10] when the array is stored as a) Row major b)
column major.
10. What is an array? What do you meant by the terms “row major order” & “column major
order”, explain with suitable examples.
11. A two dimensional array TABLE [6] [8] is stored in row major order with base address
351. What is the address of TABLE [3] [4]?
12. Explain the method to calculate the address of an element in an array. A 25*4 matrix
array DATA is stored in memory in ‘row-major order’. If base address is 200 and 4
words per memory cell. Calculate the address of DATA [12, 3]
13. Write a program for insertion of an element in an array and deletion of an element from
an array.
14. What is the difference between static and dynamic memory allocation?Explain with
example.
15. What are the advantages and disadvantages of linked list over array?
16. Write an algorithm for deleting an element from k-th position of an array
17. With a suitable example, distinguish between the representation of a two dimensional
array in row major order and in column major order.
18. Suppose a 2D array is initialized as intA[10][12], Base address is 5000.Find the location
of the element A[2][4] in row major and column major form.
19. What is the addressing formula for an element A[i][j] in roj major order and column
major order.If i and j are bounded by the lower and upper limits as l1≤i≤u1 and l2≤i≤u2
[Assume that the base address is L and w is the number of bytes allocated to each
element].
QUEUE:
1. What is Queue? Why the Queue data structure is called FIFO?
2. What are the disadvantages of linear queue? How can we overcome these
disadvantages in case of circular queue? Explain with an example?
3. List the advantages of array representation of a queue?
4. List the applications of a queue?
5. Give the difference between input restricted dequeue and output restricted
dequeue?
6. Write an algorithm to insert an element in a queue?
7. Construct the following queue of characters where QUEUE is a circular array
which is allocated six memory cells
FRONT = 2 REAR = 4 QUEUE: _ , A, C, D, _ , _
Describes the queue as following operations take place :
a) F is added to the queue.
b) Two letters are deleted from the queue.
c) K,L,M are added to the queue.
d) Two letters are deleted from the queue.
e) R is added the queue.
f) One letter is deleted from the queue.
8. Is Circular queue a non-linear data structure? Justify your answer.
9. Write an algorithm to insert an element in circular queue.
10. What are circular queues? Write down routines for inserting and deleting
elements from a circular queue implemented using arrays.
10. Implement a Queue using a singly linked list L.
11. Suppose a queue is housed in an array in circular fashion. It is desired to add new
items to the queue. Write down a procedure ENQ to achieve this also checking
whether the queue is full. Write another procedure DQ to delete an element after
checking queue empty status.
12. Using array to implement the queue structure, write an algorithm/program to
(i) Insert an element in the queue.
(ii) Delete an element from the queue.
13. Devise a representation for a list where insertions and deletions can be made at
either end. Such a structure is called a dequeue (Double ended queue). Write
functions for inserting and deleting at either end.
14. Suppose a queue is maintained by a circular array QUEUE with N = 12 memory
cells. Find the number of elements in QUEUE if
(i) Front = 4, Rear =8.
(ii) Front = 10, Rear = 3.
(iii) Front = 5, Rear = 6 and then two elements are deleted.
15.What is dequeue?

TREE:
1. Define Tree. Explain with example.
2. What is binary tree? Prove that the maximum no of nodes in a binary tree of height
h is 2 h+1 -1.
3. What is a full binary tree and a complete binary tree? Prove that a full binary tree
with n leaves contains (2n -1 ) nodes.
4. How do we represent a binary tree in memory?
5. Write a C function to insert a node in binary search tree.
6. Write function to delete a node from a binary search tree.
7. Write recursive function for in-order, preorder and post order traversal of a binary
tree.
8. Write non recursive algorithm for pre-order traversal of a binary tree.
9. Write non recursive algorithm for in-order traversal of a binary tree.
10. Write non recursive algorithm for post-order traversal of a binary tree.
11. What is binary search tree? If we delete a node from a BST and then insert the
node again in the BST, is the resulting BST necessarily the same as before? Justify
your answer with a suitable example.
12. What is threaded binary tree?
13. Given the pre-order and in-order traversal of a binary tree, draw the tree and write
its post-order traversal:
Pre-order: A B D E F C G H J L K
In-order: D B F E A G C L J H K
14. Construct an expression tree for the expression E= (2x + y )* (5a - b) 3
15. Insert the following key into a B-Tree of order 3
p, q, r, d, h,m,l,s,k,n
16. What are AVL trees? Illustrate with a suitable example.
17. The following keys are to be inserted in the order shown below into an AVL tree,
5, 45, 50, 65, 75, 85.
18. Insert the following keys in the order given below to build an AVL tree
g, h, s, l, e, m, t,u
Clearly mention different rotations used and balance factor of each node.
19.i) Draw the AVL tree after performing each of the following operations
consecutively on an initially empty binary search tree :
a) Insert 8.
b) Insert 6
c) Insert 12
d) Insert 3
e) Insert 10
f) Insert 9
g) Delete 12
h) Delete 8
i) Insert 7
j) Insert 8
ii) If you delete an item from an AVL tree and then insert it back into the tree, will
you always get back the original tree? Justify your answer.
20. Create B-Tree of order 5 from the following lists of data items:
16, 20, 22, 42, 12, 30, 32, 18, 10, 34, 36, 38, 14, 24, 28, 40,26.
21. How an AVL tree differs from a binary search tree?
22. What do you mean by B-tree and what are the uses of such a tree in data
structure?
23. Show how the following numbers can be inserted in an empty Binary search tree
in the order they are given :
50, 30, 10, 90, 100, 40, 60, 20, 110, 5
23. Discuss how to insert an element in an AVL tree.
24. Construct a binary search tree with the help of following inorder and post order
traversal:
Post-order : B, C, A, P, N, T, L, K, G, F, P
In-order : A, B, C,D,F, G, K,L, N,P,T
25. Prove that, for any non empty binary tree T, if p be the no of leaves and q be the
no of nodes of degree 2 ,then p = q +1.
26. What is 2-way threading?
27. Is it possible to represent a binary tree using array ? if yes, how?
28. What are expression trees? Represent the following expression using a tree.
Comment on the result that you get when this tree is traversed in Preorder,
In-order and post-order. (a-b) / ((c*d)+e)
29. Draw the expression tree of the following infix expression. Convert it in to
Prefix and Postfix expressions.
a+b*c – d/e
30. Create a heap with following list of keys:
8, 20, 9, 4, 15, 10, 7, 22, 3, 12
31. What is a Binary Tree? What is the maximum number of nodes possible in a
Binary Tree of depth d. Explain the following terms with respect to Binary
trees
(i) Strictly Binary Tree (ii) Complete Binary Tree (iii) Almost
Complete Binary Tree
32. What are B-trees? Draw a B-tree of order 3 for the following sequence of
keys. 3,5,11,10,9,8,2,6,12
33. Sort the following list using Heap Sort technique, displaying each step.
20, 12, 25 6, 10, 15, 13
34. What are the two phases in heap sort algorithm? Sort the following data
using heap sort and show all the intermediate steps.
88, 12, 91, 23, 10, 36, 45, 55, 15, 39, 81
35. What are the properties of a heap? Distinguish between a max heap and a min
heap.
36. Transform the array 2 8 6 1 10 15 3 12 11 into a heap with a bottom up method
37. Show the result of inserting the keys 4,19, 17, 11, 3, 12, 8, 20, 22, 23, 13, 18, 14,
16, 1, 2, 24, 25, 26, 5 in order in to an empty B-Tree of degree 3. Only draw the
configurations of the tree just before some node must split, and also draw the final
configuration.
37. Show a tree (of more than one node) for which the preorder and inorder traversals
generate the same sequence. Is this possible for preorder and post order traversals? If
it is, show an example.
38. Construct an expression tree for the expression A+(B-C)*D+(E*F)
39. Write a program in C to create an empty binary search tree & search for an
Element X in it.
40. Define M-way trees. Build a B-tree of order 4 by inserting data in the sequence
given below: 92, 24, 6, 7, 11, 8, 22, 4, 5, 16, 19, 20, 78
41. Create a binary search tree for the following numbers start from an empty binary
search tree. 45,26,10,60,70,30,40 Delete keys 10,60 and 45 one after the other and
show the trees at each stage.
42. How to insert and delete an element into a binary search tree and write down the
code for the insertion routine with an example.
43.What are threaded binary tree? Write an algorithm for inserting a node in a
threaded binary tree

SEARCHING , SORTING ,HASHING:


1. Write an algorithm to sort an array using Insertion sort and analyze it’s time complexity.
2. Explain the operation of selection sort and also analyze its time complexity.
3. Explain the working principle of merge sort algorithm with a suitable example.
4. Write down the working principle of quick sort.
5. Write down the difference between linear search & binary search.
6. Sort the following list using Heap Sort technique, displaying each step.
20, 12, 25 6, 10, 15, 13
Write the heap sort algorithm.
7. Write the algorithm for bubble-sort. For the following sequence of elements perform
bubble-sort.
70,66,40,88,22
Write the bubble sort algorithm.
8. Write the program for insertion-sort. For the following sequence of elements perform
insertion-sort. 25, 17, 31, 13, 2
9. Write the algorithm for quick-sort. Given the following sequence of elements, place the
first element at its correct position, using quick-sort:
44, 33, 11, 55, 77, 90, 40, 60, 99, 22, 88, 66
10. Write the program for performing binary search.
11. Compare the complexity of insertion sort & selection sort.
12. Explain the advantages of binary search over sequential search.
13. What do you mean by external sorting ? How does it differ from internal sorting?
14. Write an algorithm to sort a sequence in ascending order using selection sort method.
15. What is the pre-condition of performing binary search in an array? Write the binary
search algorithm.
16. Explain radix sort technique for the following list :
189,205,986,421,97,192,535,839,562,674
Write the radix sort algorithm.
17. Explain with suitable example the principal operation of Heap Sort.
18. Illustrate the operation of merge sort for the following sequence
20, 12, 25 6, 10, 15, 13
Write the merge sort algorithm.
19. What is hashing? Describe any three methods for defining hashing function?
20. Discuss different collision resolution techniques.
21. Explain hashing, hash table and hash function. Explain with a example.
22. What do you mean by internal and external sorting?
23. What is the meaning of collision in hashing? Explain collision resolution
techniques in context of hashing.
24. Using modulo-division and linear probing method, store the keys given below in
an array of 13 elements. How many collisions occurred and what is the density of
the list after the keys are inserted. 28, 7, 846, 786, 431, 870, 612, 675, 876, 546,
34, 12

You might also like