CS1602-Data Structures and Algorithms-Anna University-Question Papers
CS1602-Data Structures and Algorithms-Anna University-Question Papers
PART B (5 x 16 = 80 marks)
11.
i. A and B are two sorted linked lists. Write an algorithm to create new linked
list C that contains all data in A, B without duplicates in sorted order.
(6)
ii. Formulate an algorithm to multiply two polynomials P1, P2 using linked list
implementation. Explain with suitable example.
(10)
12.
(a)
i. Write an algorithm to insert and delete from the ith stack when multiple stacks
are represented in a single array. Check for Stack Full condition.
B.BHUVANESWARAN / REC
(6)
Page No. : 1
ii. Show the results of inserting 3, 2, 1, 4, 5, 6, 7, 9, 6, 15, 14, 13, 12, 11, 10, 8
and 9 into initially empty AVL tree. Explain with neat algorithm.
(6)
(4)
Or
(b)
i. Two binary trees are similar if they are both empty or both non empty and
have similar left and right subtrees. Write an algorithm to decide whether two
binary trees are similar.
(10)
ii. Write a non-recursive algorithm for post order tree traversal. Perform time
analysis for your algorithm.
(6)
13.
(a)
i. Write an algorithm to find the smallest and largest element in a given set S. (8)
ii. Give an algorithm to find the minimum number of edges that need to be
removed from an undirected graph G so that the resulting graph is acyclic. (8)
Or
(b)
i. How do you remove data from a priority queue? Explain the application of
priority queue.
(6)
ii. Explain the Prims algorithm and apply to the following graph.
10
11
2
E
2
H
1
4
5
6
(10)
2
F
3
1
G
11
2
8
J
14.
(a)
i. Explain an efficient method for garbage collection of equal sized blocks.
(8)
(8)
Or
B.BHUVANESWARAN / REC
Page No. : 2
(b)
i. Discuss the problems in allocating and freeing space in each memory
management scheme.
(8)
(8)
15.
(a)
i. Explain the heap sort algorithm for sorting a list of n values and perform the
time analysis.
(6)
ii. Explain the Optimal Binary Search Tree with an example and algorithm.
(6)
(4)
Or
(b)
i. What is external sorting? Explain the polyphase sort with example.
(6)
ii. In the game of chess, a Knight in row R and column C may move to row
1<R<B and column 1<C<B (Where B is the size of the board) provided that
either
|R-R| = 2 and |C-C| = 1
Or
|R-R| = 1 and |C-C| = 2
A Knights tour is a sequence of moves that visits all sequences exactly one
before returning to the starting point. Give a backtracking algorithm to find
knights tour.
(10)
__________
B.BHUVANESWARAN / REC
Page No. : 3
Q 8099
M.E. DEGREE EXAMINATION, MAY / JUNE 2006
First Semester
Computer Science and Engineering
CS 1602 DATA STRUCTURES AND ALGORITHMS
(Regulation 2005)
Time : Three hours
PART B (5 x 16 = 80 marks)
11.
i. Write a non-recursive function to reverse a singly linked list in O(N) time. (6)
ii. Given two sorted list L1 and L2, write an algorithm to computer L1L2.
(5)
(5)
12.
(a)
i. Write an algorithm to convert a postfix expression to infix.
(8)
(8)
Or
B.BHUVANESWARAN / REC
Page No. : 4
(b)
i. Show that the maximum number of nodes in binary tree of height h is 2 h+1 1
with an example.
(8)
ii. Keys1, 2, 2k 1 are inserted in order into an initially empty AVL tree.
Prove that the resulting tree is perfectly balanced.
(6)
13.
(a)
i. Propose an algorithm to insert M nodes into a binary heap on N elements.
Perform time analysis for your algorithm.
(8)
ii. Given an algorithm to find an undirected (Connected) graph path that goes
through every edge exactly once in each direction.
(8)
Or
(b)
i. Write an algorithm to find the largest element in a set S
(6)
ii. Explain the Dijkstras algorithm and apply to the following graph.
(10)
1
B
5
G
3
F
6
14.
(a)
i. Discuss the memory management issues in detail.
(8)
(8)
Or
(b)
i. Discuss the method of allocating storage for objects with mixed sizes
(8)
(8)
B.BHUVANESWARAN / REC
Page No. : 5
15.
(a)
i. Consider the problem of placing eight queens on an (eight by eight) chess
board. Two queens are said to attack each other if they are on the same row,
column, or (not necessarily main) diagonal. Give a backtracking algorithm to
solve the above problem.
(8)
ii. In the analysis of merge sort, constants have been disregarded. Prove that the
number of comparisons used in the worst case by merge sort is
N[log N] 2[log N] + 1.
(8)
Or
(b)
i. Write an algorithm that reads in two alphabetized files and merges them
together forming a third alphabetized file.
(8)
ii. You are a tournament director and need to arrange a round robin tournament
among n = 2k players. In this tournament, everyone plays exactly one game
each day. After n 1 days, a match has occurred between every pair of
players. Give an algorithm to do this.
(8)
__________
B.BHUVANESWARAN / REC
Page No. : 6
W 2579
M.E. DEGREE EXAMINATION, JANUARY 2007
First Semester
Computer Science and Engineering
CS 1602 DATA STRUCTURES AND ALGORITHMS
(Regulation 2005)
Time : Three hours
PART B (5 x 16 = 80 marks)
11.
(a)
i. Write an algorithm to insert into a doubly linked list. Insertion should be to
enable first node insertion, last node insertion and in the middle.
(8)
ii. Write algorithms to reverse a singly linked list and to count the number of
nodes.
(8)
Or
(b)
B.BHUVANESWARAN / REC
(16)
Page No. : 7
12.
(a)
i. Write an algorithm to implement stack operations Push and Pop.
(8)
ii. Write any two tree traversal algorithm and apply it the figure given below: (8)
A
Or
(b)
i. Write an algorithm to implement Queue operations.
(8)
ii. Explain how insertion and deletion takes place in AVL trees.
(8)
(6)
13.
(a)
ii. Write an algorithm to find spanning tree and apply it to figure given below:
(10)
1
6
5
1
5
3
3
6
5
Or
B.BHUVANESWARAN / REC
Page No. : 8
(b)
i.
(8)
ii. Write a shortest path algorithm and apply it to the figure given.
(8)
1
10
100
30
50
60
10
3
20
14.
(a)
i. Write and explain the garbage collection algorithm for equal sized blocks. (8)
ii. Explain how compaction can be implemented.
(8)
Or
(b)
i. Explain how storage allocation for objects of mixed sizes is implemented. (8)
ii. Write a note on buddy systems.
B.BHUVANESWARAN / REC
(8)
Page No. : 9
15.
(a)
i. Explain how divide and conquer algorithm is applied to Tower of Hanoi.
(8)
ii. Write the Bubble sort algorithm and apply it to sort the key set.
(8)
(6)
(10)
B.BHUVANESWARAN / REC
Page No. : 10
G 6160
M.E. DEGREE EXAMINATION, MAY / JUNE 2007
First Semester
Computer Science and Engineering
CS 1602 DATA STRUCTURES AND ALGORITHMS
(Regulation 2005)
Time : Three hours
B.BHUVANESWARAN / REC
Page No. : 11
PART B (5 x 16 = 80 marks)
11.
(a)
i. Explain how to add and delete an element from a double linked chain with
head pointer.
(10)
ii. Let P be a pointer to a singly linked list and Q is a pointer. Find out the effect
of the following statements. Each node consists of two fields namely Data and
Next. Next field is points to the same node type.
Q = P Next
P Next = Q Next
P Next = (Q Next) Next
(P Next) Next = Q
(6)
Or
(b)
i. Discuss any possible scheme to implement the following:
(10)
1. Dynamic Array Number of values and data type of the array elements
are decided at run time.
2. Varying Array Number of values decided at run time and data type and
maximum number of values are decided at translation time.
ii. Write a critical essay about for and against the Pointer type. Enumerate
common errors in pointer usage.
(6)
12.
(a)
Write and explain an algorithm that takes two strings of alphabets. One string
represents an in order traversal of a binary tree in which each node contains one
alphabet; the second string represents a pre order traversal of the same tree.
Assume that no two nodes of the tree contain the same letter. The algorithm is to
determine whether there can be such tree. If there is a tree, output a string that
represents the post order traversal of the tree.
(16)
Or
B.BHUVANESWARAN / REC
Page No. : 12
(b)
i. Write and explain a recursive algorithm to convert the PREFIX form
expression into POSTFIX form of the expression. Trace this with simple
example.
(10)
(6)
13.
(a)
Write an algorithm which helps for a railway passenger to know whether there
exists a path from a given city to a another city i.e. does there exists a railway
link direct or indirect. Which way graph represented in memory? Why? Explain.
(16)
Or
(b)
(16)
14.
(a)
i. Discuss the impact of equal size and mixed size blocks based storage
allocation.
(10)
ii. Identify the various data structures possible to use for Memory management.
(6)
Or
(b)
(16)
15.
(a)
Explain how to implement merge sort with and without recursion. Analyze the
performance both.
(10 + 6)
Or
(b)
(8 + 8)
B.BHUVANESWARAN / REC
Page No. : 13