ANNA UNIVERSITY: CHENNAI – 600 025 B.E/B.

Tech Degree Practical Examinations Oct / Nov – 2012 CS2208 – Data Structures Laboratory Regulations - 2008 Time: 3 Hours Maximum Marks: 100

1 i ii iii iv

Implement a singly listed that has one integer data field and other necessary pointers. Write functions to do the following. Insert an element into the linked list. Swap – Swaps two adjacent elements in a linked list. PrintLots – Takes an argument containing the position of the elements to print and print them. Creates two lists and compute union of these two lists. 25 15 30 25

2

Write a stack ADT where the data in the node is an integer. Write functions to perform the following in a linked stack. i ii iii iv Push – to insert an element into the stack. 25

Pop – to delete an element from the stack. Ensure that you are not popping from 25 an empty stack. Print – to traverse the stack and display the elements 25 FindMin – determine the minimum element in the stack. 25

3

Write a stack ADT where the data in the node is a character. Write functions to perform the following in a stack implemented as an array. Push – to insert an element into the stack. 25 i ii iii iv Pop – to delete an element from the stack. Ensure that you are not popping from 25 an empty stack. Print – to traverse the stack and display the elements 25 Dualstack – Write a function to create two stacks in one array. 25

Implement a doubly linked list where the element has an integer variable as data and perform the following operations Addbegin. and uses the converted postfix expression and determines its value. Push – to insert an element into the stack. Use this expression tree and perform the following ii i ii Perform in-order and postorder traversals. Ensure that you are not popping from an empty stack. Ensure that you are not popping from 25 an empty stack. iii Topostfix – Uses the functions push and pop and convert a given infix expression to postfix iv Evalpostfix – Uses the functions push. Add two polynomials and store the result in one of the polynomials declared. Write a stack ADT where the data in the node is a character. iv Traverse – Traverse the list and print the contents. Write functions to perform the following in a linked stack. pop. 25 i Pop – to delete an element from the stack. Addend – insert an element at the beginning of the list and end of the i list respectively. Write functions to perform the following Push – to insert an element into the stack. Implement an expression tree by defining the proper elements and function. pop as declared in the previous sub. determine whether ‘x’ is a 20 factor of the polynomial. Write functions for the following and check your result. 25 25 25 7 30 20 30 20 35 8 35 Implement a stack as an array and evaluates the result of the expression of the 30 postorder traversal.25 division and check whether a given string is a palindrome or not Write a stack ADT where the data in the node is an integer. 25 i ii iii iv Subtract two polynomials and store the result in one of the polynomials declared Multiply two polynomials and store the result in a third polynomial 25 30 5 Given a polynomial and a value for the variable ‘x’. 25 i ii iii iv Pop – to delete an element from the stack. . Use this function to verify subdivision iii. iii Addsorted – Create a new list that would insert the elements and ensures that the list is always in sorted order. ii Delete – Delete should search for an element and delete the element if it is available.4 Implement a polynomial as a linked list. Print – to traverse the stack and display the elements 25 6 FindPal – that uses the functions push.

35 30 12 Implement a double ended queue that has one integer data member and other necessary pointers. Insert – inserts an element into an AVL tree.9 1. 10 Write the following functions by declaring a node having an integer as data and other necessary pointer. Write functions for the following. Traverse – To print the queue 25 13 a b Write a program that implements Prim’s minimum spanning tree algorithm to 50 determine the spanning tree for the given graph. Perform an array implementation of a stack data structure that add and deletes 50 from the stack. 25 Delete – deletes an element from the tree. Demonstrate to delete any interior node 25 having one child. . Insert an element into the double-ended queue 25 i ii iii iv Delete an element from the circular queue 25 Search for an element from the double ended queue and print the position it is in 25 the queue relative to the head. Insert – inserts an element into a Binary Search tree. 25 i ii iii iv Delete – deletes an element from the tree. Demonstrate to delete any interior node 35 having one or two children. Write the following functions with reference to the Binary search tree by declaring a node having an integer as data. Sort – that would use this heap and perform sorting. i ii iii Insert – inserts an element into the tree. Traverse – Perform in-order traversal and converse in-order traversal and verify 40 that the displayed elements of these traversals are in sorted order. Write function to perform the following Insert an element into the heap 35 i ii iii Deletes an element from the heap. 25 Findmin – Find the minimum element from the AVL tree 25 11 Implement a max heap where the data member is an integer.

of nodes in the left and right subtree of each of the interior 25 nodes . Write functions to do the following Insert – inserts an element into the list 25 i ii iii iv Delete – Given a key deletes an element from the list. 25 15 Implement a singly linked list where each element has one data member which is an integer and other necessary pointers. 30 FindPal – Insert the characters of a string as each node into the list. Insert – inserts an element into a AVL tree. Use the 40 forward and backward pointers and determines whether the string is a palindrome or not.Given a key deletes an element from the list. Traverse – Perform in-order. pop and creates a copy of the stack. 25 i ii iii Count – Count the no. post-order and pre-order traversals to display the 50 tree contents. Ensure that you are not popping from 25 an empty stack. Peep .14 Write a stack ADT where the data in the node is a character. Implement a hash function and store elements into this hash structure that 50 incorporates open addressing as a collision resolution technique Perform an array implementation of a queue data structure that add and deletes 50 from the queue.to display the top of the stack 25 Copy – that uses the functions push. 25 i ii iii iv Pop – to delete an element from the stack. . 18 Write the following functions by declaring a node having a character as data and other necessary pointer. 16 a b 17 Implement a doubly linked list where each element has one data member which is a character and other necessary pointers. Count – Counts the number of elements in the linked list 25 25 Findmid – Find the middle element in the linked list and displays it without using 25 the count function declared. Write functions to perform the following Push – to insert an element into the stack. Write functions to do the following Insert – inserts an element into the list 30 i ii iii Delete .

Write functions to do the following Insert an element into the priority queue 35 i ii iii Delete an element from the priority queue. Displays the priority queue 35 30 20 a b Write a program that implements Prim’s minimum spanning tree algorithm to 50 determine the spanning tree for the given graph.19 Implement a priority queue that has one data field which is a character and one priority field as a linked list. . Perform an array implementation of a queue structure that add and deletes from 50 the queue.