Given a tree with $n$ vertices. ↵
You are also given $q$ queries and each query is described by $2$ vertices of the tree.↵
↵
↵
You have to count the number of times each vertex was visited after **processing** all the queries. ↵
**Processing** a query means you travel form one vertex in that query to other vertex and you visit all the vertices including the starting vertex, ending vertex, and all the other vertices in the path once. ↵
↵
My Questions about the Problem:↵
↵
- Is it possible to solve the above problem if $1 ≤ n ≤ 10^5$ and $1 ≤ q ≤ 10^5$?↵
- What are the steps or algorithm for solving this problem? ↵
- Is their any data structure or algorithm which can be used if after some queries we are asked how many time a particular vertex has been visited?
You are also given $q$ queries and each query is described by $2$ vertices of the tree.↵
↵
↵
You have to count the number of times each vertex was visited after **processing** all the queries. ↵
**Processing** a query means you travel form one vertex in that query to other vertex and you visit all the vertices including the starting vertex, ending vertex, and all the other vertices in the path once. ↵
↵
My Questions about the Problem:↵
↵
- Is it possible to solve the above problem if $1 ≤ n ≤ 10^5$ and $1 ≤ q ≤ 10^5$?↵
- What are the steps or algorithm for solving this problem? ↵
- Is their any data structure or algorithm which can be used if after some queries we are asked how many time a particular vertex has been visited?