I have an assignment in which I need to deal with intervals. Adding, removing, an interval is O(log(n)) My idea is an interval tree , implemented as an AVL tree would be the most efficient approach.
I need to check wether an interval is adjcent to any other interval in O(log(n)). For example, [10,20],[20,30] are adjcent because of 20. Given an interval [10,20] for example, I need to check if there's another interval that ends with 10 OR another intetrval that starts at 20.
The real problem is checking if there's an interval that ends with 20, how to do that?
https://www.geeksforgeeks.org/interval-tree/ for reference, an example of an interval tree.
I've tried going for an additional interval tree that is sorted according to y in an interval (x,y) (end value). didn't turn out well.