Questions And Answers 2024
Tree Set - Correct Answer-A set interface that uses a tree for storage
what is the time complexity of a single for loop? - Correct Answer-O(n)
What is the time complexity of linked list's get operation? - Correct Answer-O(n)
How is the bucket number calculated for a hash set ? - Correct Answer-hashcode %
number_of_buckets
AVL Tree - Correct Answer-a self-balancing sorted binary tree, in which the heights of
subtrees differ by at most 1.
Max Heap - Correct Answer-a complete binary tree in which the value in each internal
node is greater than or equal to the values of the children in those nodes(Note* NOT the
SUM, just each individual value)
What does the factory method do? - Correct Answer-For the factory method pattern, we
need to define an abstract class that subclasses can use to return subclasses of the
dependency
What is a race condition in regards to Threads? - Correct Answer-When you dont know
what thread will finish first, so therefore the threads are "racing" against each other and
you have thread non determinism... (not good)
What does UML stand for? - Correct Answer-Unified Modeling Language
How does a stack operate? - Correct Answer--think of a stack as literally a stack of
bricks but each element contains data
-It is a linked list that is last in first out
How does a queue operate? - Correct Answer--adds to the rear and removes from the
front
-It is a linked list that is first in first out
True/False, BSTs have only unique elements and keep their elements in order? -
Correct Answer-TRUE
What in general, is the time complexity for searching a BST? - Correct Answer--O(h)
where h is the height, but O(n) in the worst case !
-For balanced trees, h=O(logn)