You are on page 1of 19

EASWARI ENGINEERING COLLEGE

DEPARTMENT OF INFORMATION TECHNOLOGY

IT2201 DATA STRUCTURES AND ALGORITHMS

QUESTION BANK

II YEAR IT A&B JULY 2013 TO NOV 2013

PREPARED BY

APPROVED BY HOD

Mrs.R.Radha (AP/IT)

Unit - 1 1. Define 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. What is meant by an abstract data type? An ADT is a set of operation. Abstract data types are mathematical abstractions. Eg.Objects such as list, set and graph along their operations can be viewed as ADTs. 3. What are the operations of ADT? Union, Intersection, size, complement and find are the various operations of ADT. 4. What is meant by list ADT? List ADT is a sequential storage structure. General list of the form a1, a2, a3.., an and the size of the list is n. Any element in the list at the position I is defined to be ai, ai+1 the successor of ai and ai-1 is the predecessor of ai. 5. What are the various operations done under list ADT? Print list Insert Make empty Remove Next Previous Find kth 6. What are the different ways to implement list? Simple array implementation of list & Linked list implementation of list . 7. What are the advantages in the array implementation of list? a) Print list operation can be carried out at the linear time b) Fint Kth operation takes a constant time 8. What is a linked list? Linked list is a kind of series of data structures, which are not necessarily adjacent in memory. Each structure contains the element and a pointer to a record containing its successor. 9. What are different types of Linked List? Single linked list Double linked list Circular linked list Circular Single linked list Circular double linked list 10. List the basic operations carried out in a linked list. a. Creation of list b. Insertion of list c. Deletion of list d. Modification of list

e. Traversal of List 11. Difference between Arrays and Linked List. Array is contiguous allocated memory where individual elements can be accessed using subscript. A[i] refers to ith element in the array A. Linked list is series of nodes, which are not necessarily adjacent in memory. Each node contains the element and a pointer to the next node. Array: Advantage: PrintList operation can be carried out at the linear time. Find Kth operation takes a constant time.

Disadvantage: Maximum size of the list is required, which will be overestimate and wastage of space. Insertion and deletion are expensive.

Linked list: Advantage: insert and delete requires only pointer change and so takes constant time. Maximum size of the list is not required.

Disadvantage:

find ith element takes O(i) time. (Find kth operation) Pointer in each node occupies extra space.

12. What is single linked list? It is a linear data structure which consist a pointer field that points to the address of its next node (successor) and the data item. 13. What is a doubly linked list? In a simple linked list, there will be one pointer named as NEXT POINTER to point the next element, where as in a doubly linked list, there will be two pointers one to point the next element and the other to point the previous element location. 14. Define double circularly linked list. In a doubly linked list, if the last node or pointer of the list, point to the first element of the list, then it is a circularly linked list. 15. List three examples that uses linked list. Polynomial ADT Radix sort Multi lists 16. What is a pointer? Pointer is a variable, which stores the address of the next element in the list. Pointer is basically a number.

17. What is the need for the header? Header of the linked list is the first element in the list and it stores the number of elements in the list. It points to the first data element of the list. 18. Define HEAD pointer and NULL pointer. HEAD -> It contains the address of the first node in that list. NULL -> It indicates the end of the list structure. 19. What is meant by dummy header? It is ahead node in the linked list before the actual data nodes. 20. Give some examples for linear data structures. Stack and Queue 21. What is a stack? Stack is a data structure in which both insertion and deletion occur at one end only. Stack is aintained with a single pointer to the top of the list of elements. The other name of stack is Last-in -First-out list. 22. Write operations that can be done on stack. PUSH & POP

23. Mention applications of stack. a. Expression parsing b. Evaluation of Postfix c. balancing parenthesis d. Tower of Hanoi e. reversing a string 24. Define Infix, prefix and postfix notations. Infix operators are placed in between the operands Prefix operators are placed before the operands Postfix Operators are placed after the operands 25. Write postfix from of the expression A+B-C+D. A-B+C-D+ 26. How do you test for an empty queue? To test for an empty queue, we have to check whether REAR=HEAD where REAR is a pointer pointing to the last node in a queue and HEAD is a pointer that pointer to the dummy header. In the case of array implementation of queue, the condition to be checked for an empty queue is READ<FRONT. 27. What are the postfix and prefix forms of the expression? A+B*(C-D)/ (P-R) Postfix form: ABCD-*PR-/+ Prefix form: +A/*B-CD-PR 28. Explain the usage of stack in recursive algorithm implementation. In recursive algorithms, stack data structures is used to store the return address when a recursive call is encountered and also to store the values of all the parameters essential to the current state of the Procedure. 29. Define a queue.

Queue is an ordered collection of elements in which insertions and deletions are restricted to one end. The end from which elements are added and / or removed is referred to as the rear end and the end from which deletions are made is referred to as front end. 30. Write down the operations that can be done with queue data structure. Queue is a first in -first out list. The operations that can be done with queue are addition and deletion. 31. What is a circular queue? The queue, which wraps around upon reaching the end of the array is called as circular queue. 32. What are the conditions that followed in the array implementation of queue? Condition Situation REAR FRONT==REAR ONE ENTRY QUEUE REAR==ARRAY SIZE FULL QUEUE 33. What are the conditions that could be followed in a linked list implementations of queue? Condition Situation REAR==HEAD EMPTY QUEUE REAR==LINK (HEAD) ONE ENTRY QUEUE NO FREE SPACE TO INSERT FULL QUEUE 34. What are the conditions that could be followed in a linked list implementations of queue? Condition Situation (REAR MOD ARRAY SIZE +1) ==FRONT EMPTY QUEUE (REAR MOD ARRAY SIZE +2) ==FRONT FULL QUEUE FRONT==REAR ONE ENTRY QUEUE 35. State any two application of queue. Application of Queue: 1. Queues are useful in job scheduling algorithms in the operating system. 2. Queues are also useful for categorization of data 36. Define Algorithm. Algorithm is a solution to a problem independent of programming language. It consist of set of finite steps which, when carried out for a given set of inputs, produce the corresponding output and terminate in a finite time 37. Define Program. Set of instructions to find the solution to a problem. It is expressed in a programming language in an explicit and unambiguous manner 38. List down any four applications of data structures. Compiler design

Operating System Database Management system Network analysis

UNIT - 2 1. Define non-linear data structure. Data structure which is capable of expressing more complex relationship than that of physical adjacency is called non-linear data structure. 2. Define tree. Trees are non-liner data structure, which is used to store data items in a shorted sequence. It epresents any hierarchical relationship between any data Item. It is a collection of nodes, which has a distinguish node called the root and zero or more non-empty sub trees T1, T2,.Tk. each of which are connected by a directed edge from the root. 3. Define Height of tree. The height of n is the length of the longest path from root to a leaf. Thus all leaves have height zero. The height of a tree is equal to a height of a root. 4. Define Depth of tree. For any node n, the depth of n is the length of the unique path from the root to node n. Thus for a root the depth is always zero. 5. Define Degree of a node. It is the number of sub trees of a node in a given tree. 6. Define Degree of a tree. It is the maximum degree of a node in a given tree. 7. Define Terminal node or leaf. Nodes with no children are known as leaves. A leaf will always have degree zero and is also called as terminal node. 8. Define Non-terminal node. Any node except the root node whose degree is a non-zero value is called as a nonterminal node. Non-terminal nodes are the intermediate nodes in traversing the given tree from its root node to the terminal node. 9. Define sibling. Nodes with the same parent are called siblings. 10.Define binary tree. A Binary tree is a finite set of data items which is either empty or consists of a single item called root and two disjoin binary trees called left sub tree max degree of any node is two. 11.What are the applications of binary tree? Binary tree is used in data processing. a. File index schemes b. Hierarchical database management system 12.What are the various operation performed in the binary search tree? 1.insertion 2.deletion 3.find

4.find min 5.find max 13.Define expression tree. Expression tree is also a binary tree in which the leafs terminal nodes or operands and non-terminal intermediate nodes are operators used for traversal. 14.Construction of expression trees. 1. Convert the given infix expression into postfix notation 2. Create a stack and read each character of the expression and push into the stack, if operands are encountered. 3. When an operator is encountered pop 2 values from the stack. From a tree using the operator. 15.What is meant by directed tree? Directed tree is an acyclic diagraph which has one node called its root with in degree o while all other nodes have in degree I. 16.What is an ordered tree? In a directed tree if the ordering of the nodes at each level is prescribed then such a tree is called ordered tree. 17.What is meant by traversing? Traversing a tree means processing it in such a way, that each node is visited only once. 18.What are the different types of traversing? The different types of traversing are a. Pre-order traversal-yields prefix from of expression. b. In-order traversal-yields infix form of expression. c. Post-order traversal-yields postfix from of expression. 19.What are the two methods of binary tree implementation? Two methods to implement a binary tree are, a. Linear representation. b. Linked representation 20.Define pre-order traversal. Pre-order traversal entails the following steps; a. Process the root node b. Process the left subtree c. Process the right subtree 21.Define post-order traversal. Post order traversal entails the following steps; a. Process the left subtree b. Process the right subtree c. Process the root node 22.Define in -order traversal. In-order traversal entails the following steps; a. Process the left subtree b. Process the root node c. Process the right subtree 23.What are the disadvantages of sequential representation of tree over

the linked representation? In sequential representation for storing the binary tree an array of some fixed size is available. There are chances that some nodes of the tree do not get stored in the array or there may be wastage of some space when the tree to be stored is very small. On the other hand in linked list representation the memory gets allocated dynamically hence there will not be any wastage of memory or shortage of space for storing the tree. 24.What is meant by threaded binary tree? A threaded binary tree makes it possible to traverse the values in the binary tree via a linear traversal that is more rapid than a recursive in-order traversal. It is also possible to discover the parent of a node from a threaded binary tree, without explicit use of parent pointers or a stack, slowly. This can be useful where stack space is limited, or where a stack of parent pointers is unavailable (for finding the parent pointer via DFS).This is possible, because if a node (k) has a right child (m) then m's left pointer must be either a child, or a thread back to k. In the case of a left child, that left child must also have a left child or a thread back to k, and so we can follow m's left children until we find a thread, pointing back to k. The situation is similar for when m is the left child of k UNIT 3 1. What is balanced search tree? Balanced search trees are trees whose height in the worst case is O(log n)and for which the operations INSERT, DELETE, and SEARCH can be implemented in O(log n) time. Complete binary trees, if used a s search trees, cannot be updated after an insertion or deletion in time less than O(n). They are too rigid. The key to the design of balanced search trees is the introduction of glue, or degrees of freedom. This glue takes the form of red nodes in a red-black tree, nodes with 2 children (instead of three) in 2-3 trees, and nodes with a height-imbalance of one in AVL trees. 2. What are the types of balanced search tree? There exist over one hundred types of balanced search trees. Some of the more common types are:AVL trees, B-trees & red-black trees.

3. What is a balance factor in AVL trees? Balance factor of a node is defined to be the difference between the height of the node's left subtree and the height of the node's right subtree. 4. What is meant by pivot node? The node to be inserted travel down the appropriate branch track along the way of the deepest level node on the branch that has a balance factor of +1 or -1 is called pivot node. 5. What is the length of the path in a tree? The length of the path is the number of edges on the path. In a tree there is exactly one path form the root to each node. 6. Define expression trees. The leaves of an expression tree are operands such as constants or variable names and the other nodes contain operators. 7. Define binary heap. A binary heap is a heap data structure created using a binary tree. It can be seen as a

binary tree with two additional constraints: The shape property: the tree is a complete binary tree; that is, all levels of the tree, except possibly the last one (deepest) are fully filled, and, if the last level of the tree is not complete, the nodes of that level are filled from left to right. The heap property: each node is greater than or equal to each of its children according to some comparison predicate which is fixed for the entire data structure. A binary heap is a useful data structure if you have a collection of objects to which you are adding random objects and need to remove the object with the highest (or lowest, or the extreme of some other ordering) value. You could use a dynamic array or a list, but then you'll have to compare all the elements each time you want to find the biggest one. A binary tree is already better, but a binary heap is more space efficient, and simpler. 8. Define AVL tree. AVL tree also called as height balanced tree .It is a height balanced tree in which every node will have a balancing factor of 1,0,1 .Balancing factor of a node is given by the difference between the height of the left sub tree and the height of the right sub tree. 9. What is priority queue? A priority queue is a data structure that allows at least the following two operations: insert which does the obvious thing; and Deletion, which finds, returns, and removes the minimum element in the priority queue. The Insert operation is the equivalent of Enqueue 10. Application of priority queues. 1. For scheduling purpose in operating system 2. Used for external sorting 3. Important for the implementation of greedy algorithm, which operate by repeatedly finding a minimum. 11. What are the main properties of a binary heap? 1. Structure property 2.heaporder property 12. Define tree traversal and mention the type of traversals. Visiting of each and every node in the tree exactly is called as tree traversal. Three types of tree traversal 1.inorder traversal 2.preoder traversal 3.postorder traversal. 13. Define lazy deletion. When an element is to be deleted it is left in the tree itself and marked a s being deleted. This is called as lazy deletion and is an efficient procedure if duplicate keys are present in the binary search tree, because the field that keeps count of the frequency of appearance of the element can be decremented of the element can be decremented 14. Define B-Tree. B-tree is a tree data structure that keeps data sorted and allows searches, sequential access, insertions, and deletions in logarithmic amortized time. The B-tree is a generalization of a binary search tree in that more than two paths diverge from a single

node. Unlike self-balancing binary search trees, the B-tree is optimized for systems that read and write large blocks of data. It is commonly used in databases and file systems. 15. Define B+ Tree. B+ tree (BplusTree) is a type of tree which represents sorted data in a way that allows for efficient insertion, retrieval and removal of records, each of which is identified by a key. It is a dynamic, multilevel index, with maximum and minimum bounds on the number of keys in each index segment (usually called a "block" or "node"). In a B+ tree, in contrast to a B-tree, all records are stored at the leaf level of the tree; only keys are stored in interior nodes. The primary value of a B+ tree is in storing data for efficient retrieval in a block-oriented storage context in particular, file systems. This is primarily because unlike binary search trees, B+ trees have very high fan-out (typically on the order of 100 or more), which reduces the number of I/O operations required to find an element in the tree. 16. Heap applications The heap data structure has many applications. Heapsort: One of the best sorting methods being in-place and with no quadratic worst-case scenarios. Selection algorithms: Finding the min, max, both the min and max, median, or even the k-th largest element can be done in linear time using heaps. Graph algorithms: By using heaps as internal traversal data structures, run time will be reduced by an order of polynomial. Examples of such problems are Prim's minimal spanning tree algorithm and Dijkstra's shortest path problem. 17. Define splay tree A splay tree is a self-balancing binary search tree with the additional property that recently accessed elements are quick to access again. It performs basic operations such as insertion, look-up and removal in O(log(n)) amortized time. For many non-uniform sequences of operations, splay trees perform better than other search trees, even when the specific pattern of the sequence is unknown.All normal operations on a binary search tree are combined with one basic operation, called splaying. Splaying the tree for a certain element rearranges the tree so that the element is placed at the root of the tree. One way to do this is to first perform a standard binary tree search for the element in question, and then use tree rotations in a specific fashion to bring the element to the top. 18. What is the need for hashing? Hashing is used to perform insertions, deletions and find in constant average time. 19. Define hash function? Hash function takes an identifier and computes the address of that identifier in the hash table using some function. 20. Why do we need a Hash function as a data structure as compared to any other data structure? (may 10) Hashing is a technique used for performing insertions, deletions, and finds in constant average time. 21. What are the important factors to be considered in designing the hash function? (Nov 10)

To avoid lot of collision the table size should be prime For string data if keys are very long, the hash function will take long to compute.

22. What are the problems in hashing? a. Collision b. Overflow 23. What is collision? When two keys compute in to the same location or address in the hash table through any of the hashing function then it is termed collision. 24. Define collision resolution. What are the methods for avoiding collision? (may 10) Collision resolution is the process of finding another position for the collide record. Various collision resolution techniques are Separate chaining Open addressing

25. What are the applications of hash table? (Nov 09) Compliers use hash table to keep track of declared variable in source code. (Symbol table) Used in graph theory problem where the nodes have real names instead of numbers. Used in programs those play game. As the program searches through different lines of play, it keeps track of positions it has seen by computing a hash function based on the position (and storing its move for that position). Used in on-line spelling checkers. If misspelling detection is important, an entire dictionary can be prehashed and words can be checked in constant time.

26. List out the different types of hashing functions. The different types of hashing functions , The division method Mind square method The folding method Multiplcativehashing Digit analysis UNIT - 4 1. What is a weighted graph? A graph in which weights are assigned to every edge is called a weighted graph. 2. Define Graph? A graph G consist of a nonempty set V which is a set of nodes of the graph, a set E which is the set of edges of the graph, and a mapping from the set of edges E to set of pairs of elements of V. It can also be represented as G=(V, E). 3. Define adjacency matrix?

The adjacency matrix is an n x n matrix A whose elements aij are given by aij = 1 if (vi, vj) Exists =0 otherwise 4. Define adjacent nodes? Any two nodes, which are connected by an edge in a graph, are called adjacent nodes. For example, if an edge xE is associated with a pair of nodes (u,v) where u, v then we say that the edge x connects the nodes u and v. 5. What is a directed graph? A graph in which every edge is directed is called a directed graph. 6. What is an undirected graph? A graph in which every edge is undirected is called an undirected graph. 7. What is a loop? An edge of a graph, which connects to itself, is called a loop or sling. 8. What is a simple graph? A simple graph is a graph, which has not more than one edge between a pair of nodes. 9. What is a weighted graph? A graph in which weights are assigned to every edge is called a weighted graph. 10. Define indegree and out degree of a graph? In a directed graph, for any node v, the number of edges, which have v as their initial node, is called the out degree of the node v. Outdegree : Number of edges having the node v as root node is the outdegree of the node v. 11. Define path in a graph? The path in a graph is the route taken to reach terminal node from a starting node. 12. What is a simple path? A path in a diagram in which the edges are distinct is called a simple path. It is also called as edge simple. 13. What is a cycle or a circuit? A path which originates and ends in the same node is called a cycle or circuit. 14. What is an acyclic graph? A simple diagram, which does not have any cycles, is called an acyclic graph. 15. What is meant by strongly connected in a graph? An undirected graph is connected, if there is a path from every vertex to every other vertex. A directed graph with this property is called strongly connected. 16. When a graph said to be weakly connected?

V,

When a directed graph is not strongly connected but the underlying graph is connected, then the graph is said to be weakly connected. 17. Name the different ways of representing a graph? Give examples (Nov 10) a. Adjacency matrix b. Adjacency list 18. What is an undirected acyclic graph? When every edge in an acyclic graph is undirected, it is called an undirected acyclic graph. It is also called as undirected forest. 19. What is meant by depth? The depth of a list is the maximum level attributed to any element with in the list or with in any sub list in the list. 20. What is the use of BFS? BFS can be used to find the shortest distance between some starting node and the remaining nodes of the graph. The shortest distance is the minimum number of edges traversed in order to travel from the start node the specific node being examined. 21. Write down the steps for implementing BFS algorithm 1. Initialize the first nodes dist number and place in queue 2. Repeat until all nodes have been examined 3. Remove current node to be examined from queue 4. Find all unlabeled nodes adjacent to current node 5. If this is an unvisited node label it and add it to the queue 6. Finished.

22. Define biconnected graph? A graph is called biconnected if there is no single node whose removal causes the graph to break into two or more pieces. A node whose removal causes the graph to become disconnected is called a cut vertex. 23. Write the time complexly of BFS algorithm The time analysis for the BFS algorithm is O(n + e) Where e is the number of edges and n is the number vertices. 24. What are the two traversal strategies used in traversing a graph? a. Breadth first search b. Depth first search 25. What is a minimum spanning tree? (Nov 09) A minimum spanning tree of an undirected graph G is a tree formed from graph edges that connects all the vertices of G at the lowest total cost. 26. What are the conditions for a graph to become a tree? A graph is a tree if it has two properties. i. If it is a connected graph. ii. There should not be any cycles in the graph. 27. Explain about Adjacency Matrix

Adjacency matrix consists of a n*n matrix where n is the no. of vertices present In the graph, which consists of values either 0 or 1. 28. Explain about Adjacency linked list. It consists of a table with the no. of entries for each vertex for each entry a linked List is initiated for the vertices adjacent to the corresponding table entry. 29. What is a single source shortest path problem? Given as an input, a weighted graph, G and a distinguished vertex S as the source vertex. Single source shortest path problem finds the shortest weighted path from s to every other vertex in G. 30. Define Euler circuit. An Euler circuit is a connected graph such that starting at a vertex a, one can traverse along every edge of the graph once to each of the other vertices and return to vertex a In other words, an Euler circuit is an Euler path that is a circuit. Thus, using the properties of odd and even degree vertices given in the definition of an Euler path, an Euler circuit exists if and only if every vertex of the graph has an even degree.

This graph is an Euler circuit as all vertices have degree 2.

This graph is not an Euler circuit. 31. What is Prims algorithm? Prim's algorithm is an algorithm that finds a minimum spanning tree for a connected weighted undirected graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. Prim's algorithm is an example of a greedy algorithm. The algorithm was developed in 1930 by Czech mathematician Vojtch Jarnk and later independently by computer scientist Robert C. Prim in 1957 and rediscovered by Edsger Dijkstra in 1959. Therefore it is also sometimes called the DJP algorithm, the Jarnk algorithm, or the Prim-Jarnk algorithm. 32. What is Kruskal's algorithm? Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connected weighted graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. If the graph is not connected, then it finds a minimum spanning forest (a minimum spanning tree for each connected component). Kruskal's algorithm is an example of a greedy algorithm. 33. What is topological sort? A topological sort or topological ordering of a directed acyclic graph (DAG) is a linear ordering of its nodes in which each node comes before all nodes to which it has outbound edges. Every DAG has one or more topological sorts. 34. Give the properties of Biconnected Graph. 1. There are two disjoint paths between any two vertices.

2. There exists simple cycle between two vertices. 3. There should not be any cut vertex Cut vertex is a vertex is a vertex which if we remove then the graph becomes disconnected. UNIT V

1.

What is divide and conquer?

Given a function to compute on 'n' inputs the divide and conquer strategy suggests splitting the n inputs into k subsets yielding k subproblems. These sub problems are solved independently and then a solution must be found to combine the sub solutions into a solution of the whole. 2. State the importance of dynamic programming. Instead, a mathematical way of thinking about it is to look at what you should do at the end, if you get to that stage. So you think about the best decision with the last potential partner (which you must choose) and then the last but one and so on. This way of tackling the problem backwards is Dynamic programming. 3. Where is dynamic programming used? Dynamic programming is used when the problem is to be solved in a sequence of intermediate steps. It is particularly relevant for many optimization problems, i.e. frequently encountered in Operations research. 4. Write down the algorithm for solving Towers of Hanoi problem? 1. Push parameters and return address on stack. 2. If the stopping value has been reached then pop the stack to return to previous level else move all except the final disc from starting to intermediate needle. 3. Move final discs from start to destination needle. 4. Move remaining discs from intermediate to destination needle. 5. Return to previous level by popping stack. 5. Write the general algorithm for solving the Tower of Hanoi problem? a. Only one disc may be moved at a time. b. A disc may be moved from any needle to any other c. At no time may a larger disc rest upon a smaller disc. 6. Write the steps in the general algorithm for recursive procedure? i) Prologue- save the parameters, local variables and return address ii) Body If the base criterion has been reached then perform the final computation and go to step3, otherwise perform the partial computation and go to step1. iii) Epilogue Restore the most recently saved parameters local variables and return address. Go to return address. 5. Define Space Complexity The Space complexity of an algorithm is the amount of memory it needs to run to completion 6. Define Time Complexity Time complexity of an algorithm is the amount of computer time it needs to run to completion 7. What are asymptotic notations? The notations that enables us to make meaningful statements about the time and space complexity of a program is called asymptotic notations.

8. What is NP? NP is the class of decision problems for which a given proposed solution for a given input can be checked quickly to see if it is really a solution. PART-B UNIT-1 1. What is an Abstract Data type (ADT)? Explain? 2. Derive an ADT to perform insertion and deletion in a singly linked list.(8) (Nov 10) 3. Explain the cursor implementation of linked list? (Nov 10) 4. Write the insertion and deletion procedures for cursor based linked lists.(8)(Nov 09) 5. Explain the various applications of linked list? 6. Design an algorithm to reverse the linked list. Trace it with an example?(8) 7. Write an algorithm for inserting and deleting an element from Doubly linked list?(8) 8. Write the algorithm for the deletion and reverse operations on doubly linked list. (8) (Nov 09) 9. Write algorithms to perform the following in doubly linked list: (may 10) (i) To insert an element in the beginning, middle, end of the list. (8) (ii) To delete an element from anywhere in the list. (8) An element is a structure variable that contains an integer data field and a string data field. 10. Write an algorithm for Push and Pop operations on Stack using Linked list. (8) (Nov 09) 11. Explain the linked list implementation of stack ADT in detail? 12. Define an efficient representation of two stacks in a given area of memory with n words and explain. 13. Explain linear linked implementation of Stack and Queue? 14. (i) write an ADT to implement 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 stack underflow. (8) (Nov 10) (ii) A circular queue has a size of 5 and has 3 elements 10,20 and 40 where F=2 and R=4. After inserting 50 and 60, what is the value of F and R. Trying to insert 30 at this stage what happens? Delete 2 elements from the queue and insert 70, 80 & 90. Show the sequence of steps with necessary diagrams with the value of F & R. (8 Marks) 15. What is a Stack? Explain its operations with example? 16. Write the algorithm for converting infix expression to postfix (polish) expression? 17. Explain the applications of stack? 18. Write a C program to perform the following stack operations (may 10) Declare a structure with one integer data type. Add necessary variables to ensure that you can create a linked representation. (i) Write a function called push that takes two parameters: an integer variable and a stack into which it would push this element and returns a 1 or a 0 to show success of addition or failure. (6)

(ii) Write a function called pop that takes two parameters: An integer pointer and a stack from which we need to pop this element. (6) (iii) A display function that would print the contents of stack. Add necessary functions to check for emptiness or fullness of the stack. (4) 19. What is a Queue? Explain its operation with example? 20. Explain the array implementation of queue ADT in detail? 21. Explain the addition and deletion operations performed on a circular queue with necessary algorithms.(8) (Nov 09) UNIT 2 1. Explain the different tree traversals with an application? 2. Write the algorithm for pre-order and post-order traversals of a binary tree.(8) (Nov 09) 3. Explain Representing lists as Binary tree? Write algorithm for finding Kth element and deleting an element? 4. (i) Show that the maximum number of nodes in a binary tree of height H is 2 H+1 -1. (4) (may 10) (ii) Construct an expression tree for the expression (a+b*c) + (d*e/f)-g (4 Marks) (iii) write psuedocode to insert and delete from a binary search tree (8) 5. Explain the algorithm to convert a postfix expression into an expression tree with an example. (8) (nov 09) 6. Define binary search tree? Explain the various operations with an example? 7. Write an ADT for performing insert and delete operations in a Binary search tree. (8) (Nov 10) 8. Write an algorithm to insert an item into a binary search tree and trace the algorithm with the items 6,2,8,1,4,3,5. (8) (Nov 09). 9. (i) Show the results of inserting the nodes 2,1,4,5,9,3,6,7 into an initially empty Binary search tree. (6) (May 10). (ii) write down the functions to insert into an AVL tree by calling appropriate functions to perform double and single rotations also. (10) 10. Define AVL trees? Explain the LL, RR, RL, LR case with an example? 11. (i) Write an ADT to construct an AVL tree. (8) (Nov 10) (ii) Suppose the following sequences list nodes of a binary tree T in preorder and inorder, respectively: Preorder : A,B,D,C,E,G,F,H,J Inorder : D,B,A,E,G,C,H,F,J Draw the diagram of the tree.

12. Describe the algorithms used to perform single and double rotation on AVL tree. (8) (Nov 09). 13. Define priority queue? Explain the basic heap operation with an example? 14. Describe in detail the binary heaps. Construct a min heap tree for the following 5,2,6,7,1,3,8,9,4 (Nov 10) 15. What is a Priority Queue? What are its types? Explain? UNIT - 3 1. Explain any two techniques to overcome hash collision. 2. Discuss the common collision resolution strategies used in closed hashing system.(16) (Nov 09) 3. (i) given the input { 4371, 1323, 6173, 4199, 4344, 9679, 1989 } and a hash function of h(X)=X (mod 10) show the resulting: (may10)

a.

Separate Chaining hash table (5)

b. Open addressing hash table using linear probing (5) (ii) what are the advantages and disadvantages of various collision resolution strategies? (6) 4. Formulate an ADT to implement separate chaining hashing scheme. (8) (Nov 10) 5. Explain Open addressing. 6. Explain Re-hashing and Extendible hashing. 7. Show the result of inserting the keys 2,3,5,7,11,13,15,6,4 into an initially empty extendible hashing data structure with M=3. (8) (Nov 10) 8. (i) State and explain the dynamic equivalence problem. (6) (May 10) (ii) explain the path compression algorithm and analyse the Union/Find algorithm used. (10) 9. Explain the implementation of Disjoint set. 10. Explain smart union algorithm and path compression. 11. What is union-by-height? Write the algorithm to implement it.(8) (Nov 09) 12. (i) Formulate an ADT to perform for the union and find operations of disjoint sets. (8) (Nov 10) (ii) Describe about union-by-rank and find with path compression with code. (8) 13. Explain path compression with example. (8) (Nov 09). UNIT-4 1. Explain the various representation of graph with example in detail? 2. Explain Shortest path algorithm with example? 3. Explain Depth first and breadth first traversal? 4. Explain spanning and minimum spanning tree? 5. What is topological sort? Write an algorithm to perform topological sort?(8) (Nov 09)

6. Find the topological ordering of a graph (8)(Nov 10) 7. Write Dijkstra's algorithm to find the shortest path? (8) (Nov 09/10) 8. (i) Give the Prim's algorithm for determining minimum spanning tree and analyse this algorithm for its worst case time complexity. (10) (May 10) (ii) Determine the minimum spanning tree for a graph using prims algorithm. 9. Explain Krushal's algorithm with an example? 10. Write the Kruskals algorithm and construct a minimum spanning tree for a graph. (16) (Nov 09/10) 11. (i) write an algorithm to determine the biconnected components in the given graph. (10) (may 10) (ii)determine the biconnected components in a graph. (6) 12. Find all articulation points in a example graph. Show the depth first spanning tree and the values of DFN and Low for each vertex. (8) (nov 10) UNIT-5 1. Briefly discuss the applications of Greedy algorithm. (8) (Nov 09) (may 10) 2. Explain the concept of greedy algorithm with Huffman codes example. (8) (Nov 10) 3. Give examples for Divide and conquer algorithm and explain. 4. Discuss the running time of Divide-and-conquer merge sort algorithm. (8) (Nov 10) 5. Find the optimal tour in a example traveling salesperson problem using dynamic programming. 6. Give examples for Dynamic programming and explain.(nov 10) 7. Give examples for Randomized algorithm and explain. 8. What is NP-completeness? Explain an NP complete problem with example. ( may 10) 9. Formulate an algorithm to multiply n-digit integers using divide and conquer approach. (8) (Nov 09).