Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Prochain SlideShare
Chargement dans…5
×

# Data structures question paper anna university

• Full Name
Comment goes here.

Are you sure you want to Yes No
• Identifiez-vous pour voir les commentaires

### 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]
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.