✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
A graph has n vertices. A tool has run depth-first search on it many times, with each run visiting the neighbours of a vertex in a different order. We have recorded N of the orderings it produced. Each ordering is the sequence of all n vertices in the order that the run visited them. Every run started at the same vertex.
These 8 orderings of one graph on 8 vertices are an example:
1 ahbfdceg
2 aedfbhgc
3 aghbcdfe
4 aedcbhgf
5 ahbfdecg
6 ahgbedcf
7 aedfhbcg
8 ahfdebcg
You have to design a data structure that can answer how many of the recorded orderings begin with a given sequence of m vertices. For example, how many of the 8 orderings above start with the sequence ahb? (The answer would be 2.)
Give the following in your answer:
N, n and m).Write in plain text. You may write a running time as Theta(...) or O(...).
Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!