In: Computer Science
In Java programing :
Q1-A Deque supports operations, addFront(), addRear(), removeFront() and removeRear(). Given stacks and their push() and pop() operations only, what are the minimum number of stacks required for this implementation?
A-1, B-2, C-3, D-4,
Q2- True or false and why
The height of a random binary tree with 100 nodes can range from 7 to 100.?
Q3-One can convert a binary tree into its mirror image by swapping each node's left and right childern while traversing it in _______?.
Q4-How to calculate number of node by tree height ?
Q5-The complexity of using sequential search algorithm on a sorted list of n items is ____.
Q6-The data structure that allows deletions at both ends of the list but insertion at only one end is ________. < Which type ?
Q7-What will be the maximum number of comparisons needed with a binary search to find a particular customer's record from a sorted list of 100 records?
Q8-For an array containing 8 elements as: 42, 29, 75, 11, 65, 58, 60, 18, what will be the result of sorting it in ascending order using bubble sort after 2 passes have completed?
(2)The height of a random binary tree with 100 nodes can range
from 7 to 100.(True)
considering height of tree is equal to maximum number of nodes in
longest path from root to leaf.
If there are n nodes in binary tree, maximum height of the binary
tree is n and minimum height is floor(log2n) + 1.
Here maximum height = 100
minimum height = floor(log2100) + 1= 7
Range of height from 7 to 100
Q3-One can convert a binary tree into its mirror image by swapping each node's left and right childern while traversing it in post order.
Q4-calculate number of node by tree height
Let the height of tree be h.
minimum number of nodes = h
maximum number of nodes = 2^(h) - 1
Q5-The complexity of using sequential search algorithm on a sorted list of n items is O(n).
Q6-The data structure that allows deletions at both ends of the list but insertion at only one end isInput restricted dequeue
Q7-The maximum number of comparisons needed with a binary search
to find a particular customer's record from a sorted list of 100
records
it is equal to number of nodes = 100
Q8-For an array containing 8 elements as: 42, 29, 75, 11, 65,
58, 60, 18
Arr[] = {42, 29, 75, 11, 65, 58, 60, 18}
After first pass {29, 42, 11, 65, 58, 60, 18, 75}
After second pass {29, 11, 42, 58, 60, 18, 65, 75}