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

DSAA Practice Questions

Uploaded by

ahmad4630496
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)
11 views2 pages

DSAA Practice Questions

Uploaded by

ahmad4630496
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

List the steps, pseudo-code, for the following problems.

1. A method for finding the number of full nodes in the binary tree without using recursion.
2. A method for finding the number of full nodes in the binary tree by using recursion.
3. Given two binary trees, return true if they are structurally identical.
4. Give a method for finding the level that has the maximum sum in the binary tree.
5. Give a method for checking the existence of path with given sum. That means, given a sum, check
whether there exists a path from root to any of the nodes.
6. Give a method for printing all the ancestors of a node in a Binary tree.
7. Zigzag Tree Traversal: Give an algorithm to traverse a binary tree in Zigzag order. For example, the
output for the tree below should be: 1 3 2 4 5 6 7

8. Give a method for Building Expression Tree from a given Postfix Expression.
9. Give a method for finding the shortest path between two nodes in a BST.
10. Given a singly linked list where elements are sorted in ascending order, convert it to a height
balanced BST.
11. Given two BSTs, check whether the elements of them are the same or not. For example: two BSTs
with data 10 5 20 15 30 and 10 20 15 30 5 should return true and the dataset with 10 5 20 15 30
and 10 15 30 20 5 should return false. Note: BSTs data can be in any order.
12. Given a BST and two integers (minimum and maximum integers) as parameters, how do you
remove (prune) elements that are not within that range?
13. Given a min-heap, give a method for finding the maximum element.
14. Give a method for merging two binary max-heaps. Let us assume that the size of the first heap is
m + n (m cells filled, n cells empty) and the size of the second heap is n.
15. A priority queue is a list of items in which each item has associated with it a
16. priority. Items are withdrawn from a priority queue in order of their priorities starting with
17. the highest priority item first. If the maximum priority item is required, then a heap is constructed
such than priority of every node is greater than the priority of its children. Design such a heap
where the item with the middle priority is withdrawn first. If there are n items in the heap, then
the number of items with the priority smaller than the middle priority is if n is odd, else ∓ 1.
Explain how withdraw and insert operations work, calculate their complexity, and how the data
structure is constructed.

You might also like