Respuesta :
Answer:
In the first case the complexity is 0(n) and in the second one the complexity is 0(n^2).
Explanation:
Consider that the celebrity is recognized to exit among give "n" group of people.
The following algorithm are:
If n=1,
that one person is inanely a celebrity by a definition.
If n>2,
than choose 2 people from "n" group "A" and "b" and ask whether "A" is knows "B", remove "A" from remaining people from who can be celebrity.
If "A" dose not know's "B", than remove "B".
Than solving the problem from the same recursively method from the same "n" group until the "n-1" group of people who can be the celebrity.
Here, the complexity is 0(n).
In the Next Case:
Visit to each of the person and ask them that the resulting "n-1" the best and the worst case of 0(n^2)
In this exercise we have to use the knowledge of algorithms to describe how many questions will be needed, so we have:
In the first case the complexity is 0(n) and in the second one the complexity is 0(n^2).
What is an algorithm?
Algorithm is simply a "recipe" for performing a task or solving a problem. And like any recipe, an algorithm must also be finite. If we follow a cake recipe correctly, we will be able to make the cake.
We can define as:
- If n=1: that one person is inanely a celebrity by a definition.
- If n>2: than choose 2 people from "n" group "A" and "b" and ask whether "A" is knows "B", remove "A" from remaining people from who can be celebrity.
So with this information we can say that the complexity of each case can be described as 0(n) and in the second 0(n^2).
See more about algorithm at brainly.com/question/21970419