Documente Academic
Documente Profesional
Documente Cultură
^dͲϭ
Code No: X0523
II B.Tech I Semester (R07) Regular Examinations, Nov- 2009
www.andhracolleges.com
All Questions carry equal marks
5. a) Write ADT for a max priority queue and briefly explain each of the operations.
(5M)
www.andhracolleges.com
b) Write the member function ( or function template) for the insertion in a priority queue
in C++ using heaps. What is the complexity for this operation? (11M)
6. a) State the four properties which define a non-empty binary search tree (BST). (6M)
b) If N elements are inserted into a BST, what is the worst case height of the Tree. Give
an example figure for such a tree when N is 5. (4M)
c) Give an example (figure with height 3) for a full BST. (6M)
8. Write an algorithm for Brute Force pattern matching and analyze it time complexity with
suitable example. (16M)
^dͲϮ
Code No: X0523
II B.Tech I Semester (R07) Regular Examinations, Nov- 2009
www.andhracolleges.com
All Questions carry equal marks
www.andhracolleges.com
b) Write the ADT specification for an Indexed BST. (6M)
c) Write the class definition for BST in C++. (6M)
7. Consider the length of the root-to-external-node path be the number of pointers on the
path. If P and Q are two two-root-to-external paths in a red-black tree, then prove that
length(P) ≤ 2length(Q). (16M)
8. Write an algorithm for Boyer Moore pattern matching and analyze it time complexity
with suitable example. (16M)
^dͲϯ
Code No: X0523
II B.Tech I Semester (R07) Regular Examinations, Nov- 2009
www.andhracolleges.com
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
1. a) What is an access specifier? Briefly discuss the access specifiers in C++. (8M)
b) Discuss the different storage classes in C++. (8M)
www.andhracolleges.com
6. a) Give an example ( figure with height 3 ) for a complete binary search tree
(BST) which is not full (4M)
b) Write a C++ function template for inserting an element into a BST.
What is the complexity (on the average and worst case)? (10+2M)
7. Consider h be the height of red black-tree (excluding external nodes), n be the number of
internal nodes in the tree and r be the rank of root
Prove that (5+5+6M)
(a) h ≤ 2r
(b) n ≥ 2r-1
(c) h ≤ 2log2(n+1)
8. Write an algorithm for KMP pattern matching and analyze it time complexity with
suitable example. (16M)
^dͲϰ
Code No: X0523
II B.Tech I Semester (R07) Regular Examinations, Nov- 2009
www.andhracolleges.com
All Questions carry equal marks
1. a) Write a C++ program to accept a 5 digit number and report whether it is divisible by
3, 5, 7, 9 or not. (8M)
b) Describe the Friend function (8M)
www.andhracolleges.com
6. a) If there are 63 nodes in binary search tree (BST) what is the maximum possible height
and what is the minimum possible height? Explain the relation between height and
complexity for the operations. (6M)
b) Write the function template in C++ for searching an element in a BST. (10M)