PES Institute of Technology-BSC Faculty: Mrs. R.Bharathi CS35: Data Structures Using C QUESTION BANK UNIT I -BASIC CONCEPTS 1. What is an ADT? Briefly explain the categories that classify the functions of a data type.write an ADT for a natural number 2. What is time complexity? Determine the time complexity of an iterative and recursive functions that adds n elements of the array using tabular method 3. Define three asymptotic notations and give the asymptotic representation of function 3n+2 in all the three notations and prove the same from first principle method 4. Define Big Oh notation. Show that 3n+2 = O(n) is correct. 4 5. Explain performance analysis and performance measurement. Write recursive function to implement Binary search 7. Write an recursive function to sum a list of numbers and also show the total step 7 counts for the function. What is recursion? What are various types of recursion? 4 9. What is recursion? Explain types of recursion. Write a C program to search an element in a given array using recursive binary search.. What do you understand by dynamic memory allocation? Explain any three functions that support dynamic allocation? 11. What is an algorithm? Briefly explain the criteria that an algorithm must satisfy. 12. Define a pointer. Write a C function to swap two numbers using pointers. 5 13. What is a pointer and why is it used? 14. Define Pointer. With example explain pointer declaration and accessing data through pointers 15. What are the various memory allocation techniques? Explain how memory can 5 be dynamically allocated using malloc()? 1. Explain the functions supported by C to caary out dynamic memory allocation 5 17. Differentiate between static memory allocation and dynamic memory allocation. Explain malloc() and realloc(). 1. What are preprocessor directives? Explain any two operations that can be done using preprocessor directives 19. Bring out the differences between structures and unions. 5 UNIT II ARRAYS AND STRUCTURES 20. What is a structure? What are the different ways of declaring a structure? Explain with an example 21. Differentiate between Structure and Union with example 5
22. Incorporate a structure to contain details of a human being (name, age, salary 4 and date of birth) with date of birth containing month, day and year. 23. Write a C program with an appropriate structure definition and variable 12 declaration to store information about an employee, using nested structures. Consider the following fields like: ENAME, EMPID, DOJ(Date, Month, Year), Salary(Basic, DA, HRA) 12 24. What are structures? Explain how the structures are useful by giving various 2+4 examples. 25. What is the difference between int *a and int a[5] and int *[5]? 2. What is sparse matrix? Give ADT sparse matrix and show with a suitable example sparse matrix representation storing as triples. 27. Write a C program to read a sparse matrix of integer values and search this matrix for an element specified by the user. 2. What is a polynomial? What is the degree of the polynomial? Write a function to add two polynomials? 29. How would you represent two sparse polynomials using array of structure and also write a function to add that polynomials and store the result in the same array. 30. What is the degree of the polynomial? Consider the two polynomials A(x) = x 0 5 +1 and B(x)= x 3 + 3x 2 +1. Show diagrammatically how these two polynomials can be represented in a array. 31. Write ADT for Polynomial. What are different ways of representing a polynomial? Write a program to read, display and add two polynomials 32. What is a sparse matrix? Write a program to search an element in a given sparse matrix. UNIT III STACKS AND QUEUES 33. Define stack. What are the different operations that can be performed on stack? Write a C program to implement all stack operations 34. Explain System stack in detail. 5 35. Write a note on multiple stacks 5 3. Explain how the stack is used in parameter passing 4 37. Write short notes on dynamic stack representation 5 3. Show the stack after each operation of the following sequence that starts with the empty stack: push(a), push(b), pop, push(c), push(d), pop 39. Define Stack as a data structure and discuss its applications 40. List applications of stacks. Using stack write an algorithm to determine if a given string is palindrome and print suitable message as output. 41. Obtain prefix and postfix expression a. (A+B)*(C+D)$(A+B) b. A+B*C-D/E*H c. (A+B^C^D)*(E+F/D) 42. List the various ways of representing the arithmetic expressions by giving suitable examples 4
43. Show the detailed concept of the stack to evaluate the following positive expression 32-5*+1^7+ * 44. Write the prefix and postfix form of the following infix expressions ((A + B) * C -(D-E)) $(F+G) b) (A+B)*(C+D-E)*F 45. Implement stack using static and dynamic memory allocation. Discuss the relative merits of these two implementations 4. Write a program to check whether a given expression is a valid postfix expression or not. If valid evaluate a given postfix expression otherwise display a suitable message. 47. Write an algorithm for converting infix expression to post-fix expression. Trace the algorithm indicating content of stack for expression (a-b)/(c*d)+e 4. What are STACK? Explain operation performed on STACK. Discuss how the stack structure can be used for Tower of Hanoi problem 49. Convert the following infix expression into a postfix expression using stack i) a * (b+c) *d ii) ((a+b) * d + e)/((f+a*d) +c) 7 7 50. Show that, how stack operations takes place for the conversion of infix to postfix 7 expression. ((A-(B+C)) *D) $(E+F) 51. Write an algorithm to implement a stack of size N using an array. The elements in the stack are to be integers. The operations to be supported are PUSH, POP and DISPLAY. Take into account the exceptions of Stack overflow and underflow 52. Define queue. What are the different operations that can be performed on queue? Write a C program to implement all queue operations 53. Distinguish between Ordinary queues and Circular queues 4 54. Write a program to implement a linear queue using arrays. Take into account the exceptions like Queue Full and Queue Empty. 55. Write a C function i) to insert an element at the rear end of a queue ii) to delete an element from the front end of the queue 5. A circular queue has a size of 5 and has 3 elements, 40 and 20, where F=2 and R=4. After inserting 50 and 0, what is value of F and R. Trying to insert 30 at this stage what will happen? Delete 2 elements from the queue and insert 0. Show the sequences of steps with necessary diagrams with the value of F and R UNIT III LINKED LISTS 57. What is a SLL? Write a program to implement stack as a singly linked list 5. What are the advantages and disadvantages of linked lists over arrays? 4 59. What are different types of linked list? Write a C function to count number of 7 elements present in single linked list. 0. Write a recursive search routine to search for a node in a SLL
1. Write an algorithm to concatenate two lists (assume both are existing) 2. Write a C function to a. To count number of nodes using singly linked list b. To concatenate two singly linked list, and then to sort the resultant list c. To reverse direction of singly linked list(as shown below) 3. Write a program to represent a polynomial of single variable using linked list and perform the following functions a. Evaluation of polynomial b. Display the polynomial 4. Define and implement doubly link list 5. Write advantages of doubly linked list over singly linked list. Write C function that will insert a given integer value into an ordered doubly linked list.. What is a single linked list? Explain with an example how a single linked list can 7 be used for sorting a set of N numbers. 7. Write a program to find for a particular node (either the position or info of the 7 node can be given) in a DLL or circular DLL. What are the advantages and disadvantages of doubly linked list? Also give its applications 9. Write a C function to insert and delete a node from the front end in case of 4 doubly linked List. 70. Implement a circular SLL with the header node containing the total no of nodes in the list. The node itself consists of student details like reg no, name, marks etc. 71. What are the advantages of circularly linked list over a linear list? Write a C routine that concatenates two circular lists. 72. Write C functions to perform the following operations: a. Create a circular singly linked list b. Display Circular singly linked list 73. Write a function to insert a node at front and rear end in a circular linked list. Write down sequence of steps to be followed UNIT III STACKS AND QUEUES 74. Define stack. What are the different operations that can be performed on stack? Write a C program to implement all stack operations
75. Explain System stack in detail. 5 7. Write a note on multiple stacks 5 77. Explain how the stack is used in parameter passing 4 7. Write short notes on dynamic stack representation 5 79. Show the stack after each operation of the following sequence that starts with the empty stack: push(a), push(b), pop, push(c), push(d), pop 0. Define Stack as a data structure and discuss its applications 1. List applications of stacks. Using stack write an algorithm to determine if a given string is palindrome and print suitable message as output. 2. Obtain prefix and postfix expression a. (A+B)*(C+D)$(A+B) b. A+B*C-D/E*H c. (A+B^C^D)*(E+F/D) 3. List the various ways of representing the arithmetic expressions by giving suitable examples 4. Show the detailed concept of the stack to evaluate the following positive expression 32-5*+1^7+ * 5. Write the prefix and postfix form of the following infix expressions ((A + B) * C -(D-E)) $(F+G) b) (A+B)*(C+D-E)*F. Implement stack using static and dynamic memory allocation. Discuss the relative merits of these two implementations 7. Write a program to check whether a given expression is a valid postfix expression or not. If valid evaluate a given postfix expression otherwise display a suitable message.. Write an algorithm for converting infix expression to post-fix expression. Trace the algorithm indicating content of stack for expression (a-b)/(c*d)+e 9. What are STACK? Explain operation performed on STACK. Discuss how the stack structure can be used for Tower of Hanoi problem 90. Convert the following infix expression into a postfix expression using stack i) a * (b+c) *d ii) ((a+b) * d + e)/((f+a*d) +c) 4 7 7 91. Show that, how stack operations takes place for the conversion of infix to postfix 7 expression. ((A-(B+C)) *D) $(E+F) 92. Write an algorithm to implement a stack of size N using an array. The elements in the stack are to be integers. The operations to be supported are PUSH, POP and DISPLAY. Take into account the exceptions of Stack overflow and underflow 93. Define queue. What are the different operations that can be performed on queue? Write a C program to implement all queue operations 94. Distinguish between Ordinary queues and Circular queues 4 95. Write a program to implement a linear queue using arrays. Take into account the
exceptions like Queue Full and Queue Empty. 9. Write a C function i) to insert an element at the rear end of a queue ii) to delete an element from the front end of the queue 97. A circular queue has a size of 5 and has 3 elements, 40 and 20, where F=2 and R=4. After inserting 50 and 0, what is value of F and R. Trying to insert 30 at this stage what will happen? Delete 2 elements from the queue and insert 0. Show the sequences of steps with necessary diagrams with the value of F and R UNIT V & VI TREES I, TREES II and GRAPHS 9. What are the different ways to represent binary trees? Explain in detail. 99. What are the differences between strictly binary tree and complete binary tree 4 0. What is a TREE? Define the following a. Ancestor b. Descendants of node with respect to the TREE 1. Write C functions for following tree traversals 9 i) Inorder ii) Preorder iii) Post order 2. Write and explain with a function, level order tree traversal 3. What is a heap and what are the different types of heap 4. Give examples to show the father, son, descendent and ascendant nodes of a binary tree 5. What are the two conditions under which a binary tree becomes an almost 4 complete binary tree?. Given the following traversals In order: E I C F J B G D K H L A Preorder: A B C E I F J D G H K L Construct a Binary Tree 7.. Explain the different methods of representation of binary trees in "C". 5. Explain threaded binary trees in detail 9. Define the following a. Strict binary tree b. Almost complete binary tree c. Ordered tree d. Right in threaded binary tree 1. Write a C recursive program to find out the height of a binary tree. 5 111. Construct a binary tree for the expression A + (B-C)*(E+F)/G and draw the diagram showing each step. 112. Explain one-way and two-way threading of binary trees 5 113. Implement the recursive tree traversal of in, pre and post order traversals 114. Write an algorithms for deleting node in a binary search tree for all the three cases 115. Write an expression tree for the expression A/B*C*D+E. Give the C function for
inorder, preorder, post order traversals and apply the traversal methods to the expression tree and give the result of traversals 11. Write an algorithm for the iterative tree traversal 117. Write an algorithm to traverse the tree using father field 11. Construct a binary tree for the expression: ((7+(-3) * ) ^ 5+4) 4 119. Define the following terms with appropriate sketches a) Tree b) Directed tree c) Ordered tree d) Binary tree e) Spanning tree 120. Write recursive C routines to traverse a binary tree in different ways. Assume the dynamic node representation of a binary tree 121. Define a tree recursively. Define the following terms with example. Siblings i. Descendants ii. Complete Binary Tree iii. Strictly Binary Tree (Full Binary Tree) 122. What is heap? Explain the different types of heap? 4 123. Explain the following with an example: i) Forest ii) Graph iii) Winner tree 124. What is a binary search tree? Draw the binary search tree for the following input:14,5,,2,1,20,1,-1,21 125. Define ADT of Binary search tree. Write the iterative search function and recursive search function of BST 12. Explain with an example how to convert given forest into binary trees UNIT VII - PRIORITY QUEUES 127. Explain min and max heap with example. 12. Implement Fibonacci heap. 129. What is binomial heap? Explain the steps involved in the deletion of min element from a binomial heap. 130. Define a max heap. Write a C function to insert an item into max heap. 4 131. Write short notes on: i) Priority queues ii) Leftist trees iii) Fibonacci heaps 132. Briefly explain the following with an example: i) HBLT ii) WBLT 133. What is Fibonacci heap? Give suitable example and give the steps for deletion of node and decrease key of specified node in F-heap. 134. Explain Single ended and Double ended Priority Queue 4 135. Define F-Heap. Explain the operations: Delete and Decrease key 13. Define Pairing Heap. Explain the following operations: getmin, insert, deletemin, meld,delete, decreasekey.
UNIT VIII - EFFICIENT BINARY SEARCH TREES 137. What is an AVL tree? Write the algorithm to insert an item in to AVL tree. 13. Explain the different types of rotations of an AVL tree. 139. Write short notes on: i) Red-Black tree. ii) Splay trees. 140. Describe the following with an example: i) Height-balanced trees. ii) Optimal BST 141. Explain the Red-Black tree. State its properties 142. Explain i) Bottom-Up Splay Trees ii) Top-Down Splay Trees 143. Let h be the height of a red-black tree, let n be the number of internal nodes in the tree and r be the rank of the root then, prove that i) h 2r ii) n 2 r -1. 4