Is it acyclic?

Exercises 5.23 and 5.24

Exercise 5.23

Design and analyse an algorithm that is able to determine if an undirected graph G=(V,E) contains cycles or not in time \mathcal O (|V|).

Exercise 5.24

Design and analyse an algorithm that determines if a directed graph contains cycles or not.

A possibility is to try to construct a topological ordering.