Data structures question paper anna university

27,556
-1

Published on

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
27,556
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
748
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

Data structures question paper anna university

  1. 1. data structures question paper anna university. CS 1151 DATASTRUCTURESPART – A (10 * 2 = 20 Marks)/Answer ALL questions1. Define ADT.2. How do you push and pop elements in a linked stack?3. Prove that the number of odd degree vertices in a connected graph should be even.4. Define NP hard and NP complete.5. Define binary search tree.6. List out and define the performance measures of an algorithm.7. What is Recursion? Explain with an example.8. List out the various techniques of hashing.9. What is the worst case complexity of Quick sort?10. State the algorithmic technique used in merge sort.PART B (5 * 16 = 80 Marks)11.(a) Derive the best, average, worst case time complexity of a linear search.(b) (i) Develop an algorithm for binary search. Validate the algorithm with a suitable data set.(10)(ii) What is Top down approach? Explain. (6)12. (a) Write ADT operations for array implementation of polynomial addition. (b) WriteADT operations for array implementation of a queue.13. (a) Write insertion algorithm for AVL tree. Write suitable rotation algorithms. (b) (i)Explain the algorithm for separate chaining. ( 8 )(ii) Explain implementation of priority queue ( 8 )14. (a) Write ADT operations for heap sort. Using the above algorithm sort the following:35 45 25 11 6 85 17 35(b) (i) Explain the quick sort algorithm. ( 8 )(ii) Explain external sorting. Give relevant example. ( 8 )15. (a) Explain Dijkstra’salgorithm using the following graph. Find the shortest path between v1, v2, v3, v4, v6 andv7.[Diagram not available] (b) (i) Write ADT operation for Prim’s algorithm. ( 8 )(ii) Explain the topological sort algorithm. ( 8 ) 1. What do you mean by sorting? Mention the di erent types of sorting, give some examples and explain any one indetail. [16 marks] 2. Compare the advantage and disadvantage of bubble, insertion and selection sort. 3. Write a program to sort the elements whose worst and average case are O(n log n). [16 marks]
  2. 2. 4. Write a program to explain selection sort . Which type of technique does it belong. [16 marks]5. Write a program to explain selection sort . Which type of technique does it belong. [16 marks]6. Write a program to sort the elements whose worst case is O(n2) and average case is O(n log n). [16 marks]7. (a) Explain selection sort indetail. (b) Explain bubble sort indetail. [8+8]8. Write an algorithm for routine merge(x,lb1,ub1,ub2) that assumes that x[lb1] through x[ub1] and x[ub1 + 1] through x[ub2] are sorted and merges the two into x[lb1] through x[ub2]. [16 marks]9. (a) Explain Quick sort with algorithm. (b) Analyse the worst case performance of Quick sort and compare with Selection sort.[8+8 marks]10. (a) Write a C program to sort the elements of an array using Quick sort with suitable example. (b) What is the worst case and best case time complexity of the above program?11. Write an algorithm for quick sort. What is its time complexity. [16 marks]12. (a) Write an algorithm for selection sort (b) Sort the following numbers using selection sort and give the required steps. 96,31,27,42,34,76,61,10,4 [8+8]13. (a) Using linear search delete the number 26 from the list of numbers and give the steps. 10,7,17,26,32,92 (b) Write a C program to implement the same. [8+8 marks]14. (a) Distinguish between linear and binary search methods. (b) Write an algorithm for non-recursive binary search method. [8+8 marks]15. (a) Write a C program to sort the elements of an array using bubble sort technique with a suitable example. (b) What is the worst case and best case time complexity of bubble sort? [10+6 marks]16. (a) Write a C program to sort given integers using partition exchange sort. (b) Derive the time complexity of partition exchange sort. [8+8]17. Write a C program that searches a value in a stored array using binary search. What is the time complexity of binary search? [16 marks]18. (a) Write a C program to merge two sorted arrays of integers. (b) Derive the time complexity of merge sort. [8+8 marks]19. (a) Write and explain non-recursive algorithm for binary search with suitable example and discuss the various time complexities of binary search. (b) Suppose that the list contains the integers 1,2,8 in this order. Trace through the steps of binary search to determine what comparisons of keys are done in searching. i. To lo cate 3 ii. To lo cate 4.5 [8+8 marks]20. Trace through the steps by hand to sort the following list in Quick sort. 28 7 39 3 63 13 61 17 50 21 [16 marks]21. What are the advantages and disadvantages of stack ? Write a program to illustrate stack operation ? [16 marks]22. Give an algorithm / C program to reverse a singly linked circular list inplace. [16 marks]23. What are the advantages and disadvantages of stack ? Write a program to illustrate queue operation ? [16 marks]
  3. 3. 24. Compare singly and doubly linked list to perform insertion operation . [16 marks]25. Write a program to illustrate the various operations of singly linked list . [16 marks]26. Write a program to delete a node in singly and doubly linked list . [16 marks]27. Write a C program using pointers to implement Queue with all operation. [16 marks]28. Write a routine to concatenate two singly linked lists. [16 marks]29. What is a stack? Explain two di erent representations of a stack. List the operations performed on a stack and write functions for implementing these operations.[16 marks]30. (a) Write a C Program to convert an infix expression into prefix expression (b) Transform the following expression to prefix, using the approach (A + B) * (C$(D - E) + F) - G [8+8 marks]31. (a) Mention and explain various types of queues and give an example for each (b) Compare various types of queues. [8+8 marks]32. Write an algorithm to perform each of the following operations to a linked list. (a) Return the sum of the integers in a list. (b) Return the number of elements in a list. [8+8 marks]33. Design insertion and deletion algorithms for a doubly linked circular lists. [16 marks]34. (a) Derive a method to convert a postfix expression into its prefix form (b) Consider the following arithmetic expression in postfix notation: 7 5 2 + * 4 1 5 - / - i. Find the equivalent prefix form of the above . ii. Obtain the computed value of the expression from its postfix notation.[8+4+4 marks]35. (a) What is a network? (b) What is a spanning tree? (c) Define minimal spanning tree . (d) What are the various traversals in a tree? [16 marks]36. Write an algorithm to perform deletion operation in a Binary Search Tree. [16 marks]37. (a) Define multi graph and graph with self- loop . (b) Explain connected graph with example. [8+8 marks]38. Explain Kruskals method of determining the minimal spanning tree. [16 marks]39. (a) Write a program to swap nodes in a binary tree. (b) Write a program to find min and max nodes in a binary tree. [8+8 marks]40. Explain binary search tree operations indetail. [16 marks]41. Explain non-recursive and recursive algorithm for converse in order traversal of binary tree. [16 marks]42. Write a C program for creating, inserting and deletion in a Binary tree. [16 marks]43. (a) Describe di erent types of trees. (b) Write a C program to implement Binary tree. [6+10 marks]44. (a) List and explain about the basic operations on a graph. (b) Write a C program for depth first search of a graph. [7+9 marks]45. Write a C program for creating, inserting and deletion in a Binary tree. [16 marks]46. (a) Write C function for minimum spanning tree of a weighted undirected graph (b) Write a C program to implement depth first traversal of graph. [10+6 marks]47. (a) List and explain about the basic operations on a graph. (b) Write a C program for depth first search of a graph. [7+9 marks]48. Write and explain the breath first traversal and depth first traversal in a graph with algorithm. [8+8 marks]49. Write in detail about the following: (a) Depth first search of a graph (b) Minimum spanning trees [8+8 marks]50. (a) Define graph. Explain the properties of a graph. (b) What is the di erence between strongly connected graph and weakly connected graph? [8+8 marks]
  4. 4. Time : Three hours Maximum : 100 marksAnswer ALL questions.PART A — (10 ? 2 = 20 marks)1. Define data structure and storage structure.2. What is iteration? Give example.3. What are primitive data types?4. Compare the following statement : Break and Continue.5. Differentiate singly linked list and circularly linked list.6. Define stack.7. What is hashing function?8. Define single rotation on AVL tree.9. Define direct access in a file.10. What is the difference between binary tree and binary search tree?PART B — (5 ? 16 = 80 marks)11. (i) Write an algorithm for binary searching with example. Analyze the timerequirement of the algorithm. (11)(ii) Explain the structure of indexed sequential files. (5)12. (a) (i) Explain in detail about top–down approach and bottom–up approach withsuitable programming examples. (10)(ii) Discuss about sequence selection iteration with examples. (6) Or(b) (i) What is recursion? Give the application of recursion with programs.(10)(ii) What are the features of structured programming methodologies? Explain. (6)13. (a) (i) What are the I/O statements used in ‘C’? Explain with examples. (8)(ii) Write a program to compute the sum of the digits in a number and also toreverse the digits. (8) Or(b) (i) Discuss various control functions used in C. (8)(ii) Solve the following equations for and using C language : (8)14. (a) (i) What are the various stack operations? Explain. (6)(ii) What are the various queue operations? Explain. (5)(iii) Explain the application of stack for conversion of infix to postfix. (5) Or(b) (i) What are the advantages and disadvantages of doubly linked list over singlylinked list? Explain the application of doubly linked list.(9) (ii) Implement any two operations on circular linked list. (7)15. (a) (i) Give a binary tree representation of the expression . (3)(ii) What are the various tree traversal methods? Explain. (9)(iii) Write an algorithm to convert general tree to binary tree. (4) Or(b) (i) List out the application of binary tree and explain. (6)(ii) Describe various hashing techniques. (10)
  5. 5. PART A-(10 X 2=20 marks)1.When will you say an algorithm efficient? Give the notations for time complexity.2.What is a ‘top-down’ design? Is ‘C’ language a top down design? Justify youranswer.3.Why is linked list used for polynomial arithmetic?4.Write the role of stack in function call.5.What is the minimum number of nodes in an AVL tree of height 5?6.What is the use of sentinel value in binary heap?7.Which is the best way of choosing the pivot element in quick sort?8.Merge sort is better than insertion sort. Why?9.Define a graph. How it differs from tree?10.What is minimum spanning tree? Name any two algorithms used to find MST.PART B-(5 X 16=80 marks)11.(a).(i).Given two lists L1 and L2, write the routines to compute L1 n L2 usingbasic operations.(ii).Write the routines for inserting and deleting elements from a queue. Check forthe conditions Q-empty and Q-full.11.(b).(i).How would you implement a stack of queues? Write routines for creationand inserting of elements into it.(ii).Write routines to insert heterogeneous data into the list.12.(a).(i).Write the routines to insert and remove a node from Binary Search Tree.(ii).A full node is a node with two children. Prove that the number of full nodes plusone is equal to the number of leaves in a binary tree.12.(b).(i).Show the resulting of inserting 2,1,4,5,9,3,6,7 into an empty AVL tree.(ii).Write the procedure to implement single and double rotations while insertingnodes in an AVL tree.13.(a).Explain with suitable examples the basic heap operations and algorithms forthe same.13.(b).How will you resolve the collisions, while inserting elements into the hashtable using separate chaining and linear probing? Write the routines for inserting,searching and removing elements from the hash table using the above mentionedtechniques.14.(a).(i).Write the routine for sorting n elements in increasing order using heapsort.(ii).Sort 3,1,4,1,5,9,2,6 in decreasing order using heap sort.14.(b).(i).Explain with example about the insertion sort.(ii).What is external sorting? Discuss the algorithms with proper examples.15.(a).(i).Discuss and write the program to perform topological sorting.(ii).What is single source shortest path problem? Discuss Dijikstra’s single sourceshortest path algorithm with an example.15.(b).(i).Write an algorithm to find the minimum cost spanning tree of anundirected, weighted graph.(ii).Find the MST for the following graph.
  6. 6. Data Strucutre Questions1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.2. List out the areas in which data structures are applied extensively?• Compiler Design,• Operating System,• Database Management System,• Statistical analysis package,• Numerical Analysis,• Graphics,• Artificial Intelligence,• Simulation3. What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model.• RDBMS – Array (i.e. Array of structures)• Network data model – Graph• Hierarchical data model – Trees4. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.5. Minimum number of queues needed to implement the priority queue? Two. One queue is used for actual storing of data and another for storing priorities.
  7. 7. CS 1151-DATA STRUCTURESAnswer all the questions:PART A-(10 X 2=20 marks)1.When will you say an algorithm efficient? Give the notations for time complexity.2.What is a ‘top-down’ design? Is ‘C’ language a top down design? Justify youranswer.3.Why is linked list used for polynomial arithmetic?4.Write the role of stack in function call.5.What is the minimum number of nodes in an AVL tree of height 5?6.What is the use of sentinel value in binary heap?7.Which is the best way of choosing the pivot element in quick sort?8.Merge sort is better than insertion sort. Why?9.Define a graph. How it differs from tree?10.What is minimum spanning tree? Name any two algorithms used to find MST.PART B-(5 X 16=80 marks)11.(a).(i).Given two lists L1 and L2, write the routines to compute L1 n L2 usingbasic operations.(ii).Write the routines for inserting and deleting elements from a queue. Check forthe conditions Q-empty and Q-full.(Or)11.(b).(i).How would you implement a stack of queues? Write routines for creationand inserting of elements into it.(ii).Write routines to insert heterogeneous data into the list.12.(a).(i).Write the routines to insert and remove a node from Binary Search Tree.(ii).A full node is a node with two children. Prove that the number of full nodes plusone is equal to the number of leaves in a binary tree.(Or)12.(b).(i).Show the resulting of inserting 2,1,4,5,9,3,6,7 into an empty AVL tree.(ii).Write the procedure to implement single and double rotations while insertingnodes in an AVL tree.13.(a).Explain with suitable examples the basic heap operations and algorithms forthe same.(Or)13.(b).How will you resolve the collisions, while inserting elements into the hashtable using separate chaining and linear probing? Write the routines for inserting,searching and removing elements from the hash table using the above mentionedtechniques.14.(a).(i).Write the routine for sorting n elements in increasing order using heapsort.(ii).Sort 3,1,4,1,5,9,2,6 in decreasing order using heap sort.(Or)14.(b).(i).Explain with example about the insertion sort.(ii).What is external sorting? Discuss the algorithms with proper examples.15.(a).(i).Discuss and write the program to perform topological sorting.(ii).What is single source shortest path problem? Discuss Dijikstra’s single sourceshortest path algorithm with an example.(Or)
  8. 8. 15.(b).(i).Write an algorithm to find the minimum cost spanning tree of anundirected, weighted graph.(ii).Find the MST for the following graph.1. (a) Write an algorithm for stack operations. (10)(b) Explain applications of trees with suitable examples. (10)2. (a) Explain Heap sort with suitable example. (10)(b) Write the algorithm for quick sort and explain with an example. (10)3. (a) Explain the Greedy Algorithms. (10)(b) Write the Kruskal algorithm for a minimum spanning tree. (10)4. (a) What is linear search, binary search ? Write algorithms for both and commenton the complexity. (15)(b) Write short notes on graph coloring. (5)5. (a) Explain Strassens matrix multiplication. (10)(b) Explain the travelling salesperson problem. (10)6. (a) Explain Branch and Bound algorithm. (10)(b) Discuss code optimization techniques. (10)7. (a) Discuss in detail on hashing with examples. (10)(b) Write an algorithm that will perform an insertion and deletion of a node in asingly linked list. (10)8. (a) Describe Np - Hard scheduling problems. (10)(b) Describe Np - Hard code generation. (10)MODEL QUESTION PAPERB.E / B.Tech. Degree Examinations III SemesterIF 246 DATA STRUCTURES AND ALGORITHMSPART – A(10 x 2 = 20 Marks)1. Take a linear search algorithms and discuss best-case time analysis.2. Explain the basic of the Markov algorithm and discuss two ways in which such analgorithm terminates.3. What is the purpose of a stack in implementing a recursive procedure? Explain.4. What is the need for using circular array to implement queues?5. Give the tree T, find the inorder and postorder traversals.6. Discuss the basis of the Buddy system of allocation. What type of fragmentationstill exists?7. Discuss the timing analysis of the heap-sort algorithm.8. What are the two broad classes of collision resolution techniques? Explain.9. With an example explain the Huffman encoding scheme.10. Explain how the size of a hashing table could be decreased when using (a) linearhashing, (b) dynamic hashing.
  9. 9. PART – B(5 x 16 = 80 Marks)11. i) Implement typical stack operation when stacks are represented using (1) arraysand (ii) using singly linked lists. (8 Marks)ii) Define a binary tree. (2 Marks)iii) Give the iterative algorithm for the inorder traversal of a binary tree. (6 Marks)12a. i) Design a string manipulation algorithm for duplicating a given character string Ntimes. (6 Marks)ii) Design an algorithm which trims off all the trailing blanks of a character string.(5 Marks)iii) Give a procedure that uses a stack in order to reverse the elements of a circularqueue which is stored in an array. (5 Marks)(OR)12b. i) Given as input a word form assigned to the variable WORD, derive functionORD-SEARCH which searches the ordered array of words looking for the wordform. If the word form is present, its index location is returned, else zero isreturned. Any search procedure can be used. (6 Marks)ii) Assume we have a priority queue split into several queues.To access these queues we have vectors of pointers to the front and rear of eachqueue and one to indicate the length of each.Thus to access the front of the queue representing priority 2, one merely starts atPRIORITY_F[2]. This representation allows each queue to be of different length.Given this representation, devise algorithms to insert and delete from a priorityqueue. (10 Marks)13a. i) Give an algorithm to reverse the elements of a single linked lists without using atemporary list. (6 Marks)ii) Write algorithms to insert into and delete elements from a doubly linked list.(6 Marks)iii) Write an algorithms to count the number of nodes in a given singly linked list.(4 Marks)(OR)13b. i) Write algorithms to allocate and free nodes in a body system of memoryallocation. (10 Marks)ii) Write an algorithm to add two polynomials when the polynomials are representedusing singly linked lists. (6 Marks)14a. i) Give the best case and worst case analysis of the binary search. (8 Marks)ii) Write any one external sorting algorithm in detail. (8 Marks(OR)14b. i) Write an algorithm to delete a node from a binary search tree. (8 Marks)ii) Give the radix sort algorithm in detail. (8 Marks)15a. i) Give in detail the structure of a typical Indexed Sequential file. (8 Marks)ii) Describe the direct file organization and give the procedure to retrieve a recordfrom a direct file given the key. (8 Marks)(OR)15b. Write notes on:-i. Garbage compaction (6 Marks)ii. VASM Files (5 Marks)iii. Virtual Hashing (5 Marks)
  10. 10. Subject: Data Structures Sub Code: CS 35Part- I1. With examples, explain different storage classes used in C.2. Write a note on enumeration data type.3. Write the prefix & postfix form of the following .1. (( A + B ) * C – ( D – E ) $ ( F+a)2. (A + B) * (C + D -E) * F4. Show that the detailed contents of the stack for given postfix examples. 623 + -382 / + * 2 $ 3 +5. Write a note on Preprocessor directives.6. Why MACROS are needed. Explain with examples.7. Differentiate between Structure & Unions members.8. What is the significance of dynamic memory allocation.Explain C function thatsupport Dynamic allocation.10. Write the dynamic representation of stack? For such a representations. Write thePush & Pop routines.11. Write the algorithm to find the maximum & minimum values singly linked list.12. Write the algorithm to delete all the occurrences of a given value from the list.13. List the different types of linked list & give their definitions in C.14. Write an algorithm to count the number of nodes in a singly linked list.15. Write an algorithm to reverse the linked list without creating new nodes.16. Write an algorithm to append an element to the end of a list.17.What is the advantage of Queue representing as List? For such representationwrite the insertion and deletion procedure.18.Show that output of the following assuming a = 4, b = 3, c = 101. d = a & b2. d = a / b3. d = a ^ b4. d = a >>25. d = a<< 2Part-B1. What is Priority Queue? Explain the different methods of implementing Priorityqueue & comment on the efficiency on each method.2. What are the advantages of a doubly linked list over a singly linked list? Write aprogram that inserts a given value in to an ordered doubly linked list in to its properpositions.
  11. 11. 3. Write a C programme to implement Circular singly linked list.4. Write a C programme using dynamic variables & pointers to construct a singlylinked list, consisting of following information.1. Student ID.2. Student Name.3. Semester.The operations to be supported are1. Inserting at the front2. At the end.3. At any position.4. Display all the nodes in the list.5. Write a C programme using dynamic variables & pointers to construct a singlylinked list, consisting of following information.1. Student ID.2. Student Name.3. Semester.The operations to be supported are Deleting a node based on student ID.If thespecified node is not present in the list; an error message should be displayed. Bothoptions should be demonstrated.6. Write a C programme using dynamic variables & pointers to construct a singlylinked list,consisting of following information.1. Student ID.2. Student Name.3. Semester.The operations to be supported are 1. Searching a node based on student ID &updates the information content. If the specified node is not present in the list anerror message should be displayed. Both options should be displayed.7. Write a C programme using dynamic variables & pointers to construct8. What is a Linked list? Compare static & dynamic implementation of linked list in C.9. How can an ordinary Queue is represented using a singly linked list ? Givealgorithms for insertions as well as deleting elements in to a singly linked list ?10. What are different methods to represent a binary tree and compare them?11. Given a binary tree implement the following.1. To compute its maximum depth.2. To Print the nodes in ascending order assuming that the tree is a BST.3. To count the number of nodes in a binary tree.12. Give an algorithm for constructing a binary search tree. While constructing thetree take care that duplicate values are not added. Trace the algorithm on8,13,10,12,6,9,5,2.13. Wrtie an algorithms for implementing the following:1. To concatinate two linked list.2. Delete the first occurrence of value X from a doubly linked list.3. Delete all the occurrence of given value from DLL.14. What are the advantages & disadvantages of a doubly linked list over a singlylinked list .15. What is meant by tree traversal. Explain the different traversal techniques.
  12. 12. 16. What are different schemes of representing a binary tree.17. Define the following terms.1. Strictly binary tree.2. Complete binary tree.3. Depth of a tree.4. Binary search tree.5. Almost complete binary tree.18. What is meant by threaded binary tree? Explain the impact of such arepresentation on the tree traversal procedure.19. Write a program to insert a given value into an ordered singly linked list into itsproper position.20. What is header node? Write a program to implement the circular singly linkedlist. Perform insertion, deletion and display routines.21. Construct a binary search tree for the following1. 80,40,75,30,20,90,502. 100,50,200,25,90,80,150,300,180.22. Construct the binary tree given the following traversals.Pre-order : A B D G H C E I FIn-order: G D H B A E I C F23. What is Structure? How is it different from an array? Expain the methods ofinitiating the structre members with an illustrative example.24. Distinguish between the following:1. (*m) [5] and * m[5]2. int ( * ptr ) and int * ptr( )25. Develop a C program to write data of employees into a file. Each employee is astructure with the following members: Char name[10], float salary, int id, char desig[10]. Further read from the file and display it on the console.26. What is stack? Indicate how stack is represented in C.27. Write an algorithm for converting fix expression for postfix expression. Furthertrace the above algorithm clearly indicating the contents of the stack for thefollowing expressions:(( A – ( B + C )) * D ) $ ( E + F )28. What is recursion? Comment on the efficiency of recursive routines.29. Write a recursive C function to find the sum of all the elements in an array with Ninteger values.30. With an illustrative example, show a queue can be structured as a circular list.31. Explain the working of radix sort on a suitable data set and comment on itsefficiency.32. What is hashing? Explain various methods for resolving hash collisions.
  13. 13. 33. What are bit fields? Summarize the rules for defining and using bit fields withsuitable examples. Consider the following:Struct{int count;float *p;s [20], *ptr = s;write the impact of the following statements.1. ++ ptr -> count;2. *ptr -> p ++;3. ( * ptr -> p ))++;4. *ptr ++ ->;5. ( ++ptr ) -> count;34. What is a circular Queue ? Write the implementation of circular queues usingarrays,& also write the routines to perform insertion,deletion & display on it.35. What is a Union ? With an example explain the declartion & accessing of unionmembers.36. Write a syntax & purpose of the following library functions:1. fopen2. fseek3. ftell4. rewind5. fscanf

×