RTX Interview Question

Time complexity of accessing linkedlist, hashmap, and binary trees. Formula for #nodes in complete binary tree.

Interview Answers

Anonymous

Apr 7, 2016

linked list access is O(n) (singly linked and doubly linked) hashmap access is O(1) average case, and O(n) worst case using a collision resolution technique like linear probing binary tree access is O(log n) average is O(n) worst case (if all nodes (excluding the final leaf) has a child that is to the left or to the right) Let the root of the tree have height h = 0 and let there be L leaves where L <= 2^h #nodes in Complete binary tree = (2^h - 1) + L #nodes in Full binary tree = 2^(h+1) - 1

1

Anonymous

Feb 17, 2016

your on site interview was in Dec. and still have no reply?