0% found this document useful (0 votes)
83 views2 pages

Data Structures (CS 231)

The document is an exam for a Data Structures course covering topics like class templates, recursion, stacks, queues, linked lists, trees, graphs, and hashing. It contains 8 questions with 3 sub-questions each testing knowledge of data structures and algorithms. Students are instructed to answer any 5 full questions in 3 hours. Questions cover implementing common data structures, writing algorithms for operations like searching, traversal, and more. Time and space complexity analysis is also tested.

Uploaded by

Priyank Thakkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views2 pages

Data Structures (CS 231)

The document is an exam for a Data Structures course covering topics like class templates, recursion, stacks, queues, linked lists, trees, graphs, and hashing. It contains 8 questions with 3 sub-questions each testing knowledge of data structures and algorithms. Students are instructed to answer any 5 full questions in 3 hours. Questions cover implementing common data structures, writing algorithms for operations like searching, traversal, and more. Time and space complexity analysis is also tested.

Uploaded by

Priyank Thakkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Reg.No.

INTERNATIONAL CENTRE FOR APPLIED SCIENCES


(Manipal University)
III SEMESTER B.S. DEGREE EXAMINATION – NOV. / DEC. 2016
SUBJECT: DATA STRUCTURES (CS 231)
(BRANCH: CS & CE)
Friday, 25 November 2016

Time: 3 Hours Max. Marks: 100


 Answer ANY FIVE full Questions.
 Missing data, if any, may be suitably assumed

1A) What are class templates? Write a template class for implementing Stack with push, pop
isEmpty and isFull member functions. Show the instantiation of Stack class for integer and
float types.Use dynamic memory allocation and de-allocation.
1B) What is space complexity of program? Explain briefly the components of space
complexity.
1C) What is Big oh notation?
(10+6+ 4=20)
2A) What is a recursive function? Give the properties of the same. Define arecursive
function to find factorial of a number.
2B) Write an algorithm for evaluation of prefix expression using stack.Also show the steps
for evaluating the following prefix expression using the above algorithm:
-*+4325
2C) Write a C++ function to convert an infix expression to postfix expression using Stack.
Also write the necessary functions. Assume that a template class Stack is defined.
(4+8+8=20)

3A) What are the advantages and disadvantages of linked lists over arrays.
3B) Write a member function to find the union of two sorted singly linked lists, with the
signature, voidlist :: getUnion ( list l1,list l2) { ...} . Write appropriate comments.
3C) Write a recursive function for binary search to search for an item in an array of integers.
Compare its time complexity with linear search in best and worst cases.
(6+8+6=20)

4A) Write an algorithm for DFS of a graph. Also write its time complexity.
4B) Write the iterative member function for level order traversal of a binary tree, with the
signature, voidBinaryTree::levelorder(){ } with node *root as the pointer to root of the
tree.
4C) Write an iterative member function for inorder traversal of a binary tree.
(8+4+8=20)

5A) Write an iterative function for removing largest element from maximum heap.
5B) Sort the following numbers using quick sort:
5, 3, 1, 9, 8, 2, 4, 7
(10+10=20)

CS 231 Page 1 of 2
6A) What is the drawback of linear queue? How is it solved using circular queue?Implement
a class circular queue with the following data members and member functions with
appropriate constructor and destructor functions:
Private Data Members: int rear, front;
Member Functions: isEmpty(), isFull(), cqInsert, cqDelete(), cqDisplay()

6B)Write the following member functions for the doubly linked list with a single private data
member ‘ first’ that points to the first node of the list:
void DLL :: Ins_rear(int x){ } – Insert an element at the rear end of the list.
void DLL ::inv_list(){ } - to reverse a list just by changing the links.
(10+10=20)

7A) What is an expression tree? Write a member function to create an expression tree for the
given postfix expression.
7B)Convert the following infix expression into prefix form and construct an Expression tree
(manually) for the prefix expression obtained.
A+B*C/D-F
7C) Write a recursive function to compare whether two binary trees are equal or not and
returning true or false. Use the following prototype.
inttree_compare( node *t1, node * t2);
(7+6+7=20)

8. Write short notes on the following;


A) AVL trees and four different rotations
B) Graph representation
C) Overflow handling methods in hashing.
(5 +5+10=20)



CS 231 Page 2 of 2

You might also like