Question about this Tree Problem

Revision en2, by presumption, 2023-03-08 01:37:47

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?
Tags tree, graphs, queries on tree, question

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English presumption 2023-03-08 01:37:47 0 (published)
en1 English presumption 2023-03-08 01:37:21 806 Initial revision (saved to drafts)