Given a binary tree with n nodes how long does it take in the worst case
Answers
Answered by
1
On average, binary search trees with n nodes have O(log n) height. However, in the worst case, binary search trees can have O(n) height, when the unbalanced tree resembles a linked list (degenerate tree).
Attachments:
Answered by
1
Given a binary tree with n nodes complexity it take in the worst case is:
- For searching, for assumption if you are breadth first traversal in a binary tree then the worst case complexity is O(n).
- For deletion, initially you have to traverse the element and you should delete it , complexity is O(n).
- For insertion, first you should find where to place for that you need to traverse all elements, complexity is O(n).
Similar questions
Computer Science,
6 months ago
Math,
6 months ago
English,
6 months ago
History,
11 months ago
Computer Science,
1 year ago