Q3
a. A binary search tree may be balanced or unbalanced based on the arrangement
of the nodes of the tree. With you knowledge in Binary search tree:
i. Explain the best and worst case scenarios of the time and space complexity of
both type of binary trees above. (AP)15 marks
b. A program accepts natural numbers N and M as inputs into an integer array A[ ]
and B[ ], each consisting of N and M of elements respectively. Sort the arrays A[ ]
and b[ ] in descending order of magnitude. Use the sorted array to generate a merged
array C[ ]. Array C[ ] should be generated in descending order. Assume the input
arrays comprise a maximum of 20 elements each, with no duplicates. Common
elements should be included in the merged array only once.
Using C++ implement the program above to achieve its stated requirements
above

Respuesta :

The best case scenarios of the time and space complexity of binary search is simply the time complexity of the binary search algorithm which is O(log n).

However, this balanced scenarios complexity would be O(1) when the central index would directly match the desired value.

On the other end, for an unbalanced scenarios of binary search tree, the running time of a binary search would be O(n). which will represent a linked list

What is binary search tree?

The binary search tree simply refers to an advanced algorithm used for analyzing the node, its left and right branches, which are eventually modeled in a tree structure and returning the value.

So therefore, the best case scenarios of the time and space complexity of binary search is simply the time complexity of the binary search algorithm which is O(log n).

Learn more about binary search tree:

https://brainly.com/question/21130458

#SPJ1