University of Gujrat: Important Instructions
University of Gujrat: Important Instructions
University of Gujrat: Important Instructions
IMPORTANT INSTRUCTIONS:
• After receiving the question paper, you need to create a solution book.
• Each page of this solution book must contain your NAME, ROLL NUMBER and
PAGE NUMBER.
• You have to write solutions in hand written form.
• Convert your solutions in PDF File Format.
• Name your solution file with your roll number only. (e.g. 19017688-021)
• Submit your solutions to your instructor by replying to the email in which you
received the question paper. (Don’t compose new email)
• Late submission or multiple time submission will result in cancellation of your
paper.
NOTE: Each question in Part 1 contains 2 marks each. Each question in Part 2 contains
4 marks each.
PART 1
1. Can we perform binary search on linked list? Explain your answer with proper
reasoning.[2]
2. Suppose we have a static implementation of the stack class, with twenty four items in the
stack stored at data[0] through data[23]. The CAPACITY is 42. Where does the push
method place the new entry in stack? [2]
3. How does dynamic memory allocation help in managing data? Explain your answer.
4. What is the minimum number of nodes in a complete binary tree with depth 3? [2]
5. What will be the postfix form of A/B*C+D equation? [2]
6. Consider the array 23 15 5 12 40 10 7. After the first pass of a particular algorithm, the
array looks like 15 5 12 23 7 40, Name the sorting algorithm used. [2]
7. What is the resultant value of the postfix expression 6 3 2 4 + – *? [2]
8. If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time,
in what order will they be removed? [2]
9. How to check if a given Binary Tree is BST or not? [2]
10. To manage all function calls in recursive function, which data structure is used? Explain
with reason. [2]
11. Write boolean expression that indicates whether the numbers in two nodes (p and q) are the
same. Assume that neither p nor q is null. [2]
12. Consider arrays, singly linked list and doubly linked list data structures. What kind of list
is best to answer questions such as "What is the item at position n?" [2]
13. Pointers allocate memory for data storage. True or False? Give proper reasons for your
answer. [2]
14. Consider the following tree, how many of the nodes have at least one sibling? [2]
15. Why do we use stack? Explain your answer with real life applications of stack. [2]
PART 2
16. Construct a binary search tree of following series and find post-order traversal. [4]
56 23 65 44 29 36 40 72 69 28 39 47
17. Given a binary search tree. Balance this tree and Draw resultant AVL tree. [4]
18. Draw the max heap tree of the following values. [4]
22 66 11 5 6 7 3 88 34 12
19. Consider following linked list having head as first Node. [4]
25 15 30 40 NULL
Write some code to insert a new node at second position of this list.
20. How do we check whether an expression is balanced or not? Write a code that inputs an
expression and tells if the expression is balanced or not. [4]