In this paper we give, for all constantsk,l, explicit algorithms that, given a graphG=(V,E) with a tree-decomposition ofGwith treewidth at mostl, decide whether the treewidth (or pathwidth) ofGis at mostk, and, if so, find a tree-decomposition (or path-decomposition) ofGof width at mostk, and that useO(|V|) time. In contrast with previous solutions, our algorithms do not rely on non-constructive reasoning and are single exponential inkandl. This result can be combined with a result of B. Reed [in“Proceedings of the 24th Annual Symposium on Theory of Computing,” pp. 221–228, 1992], yielding explicitO(nlogn) algorithms for the problem, given a graphG, to determine whether the treewidth (or pathwidth) ofGis at mostk, and, if so, to find a tree- (or path-) decomposition of width at mostk(kconstant). Also, H. L. Bodlaender [in“Proceedings of the 25th Annual Symposium on Theory of Computing,” pp. 226–234, 1993] has used the result of this paper to obtain linear time algorithms for these problems. We also show that for all constantsk, there exists a polynomial time algorithm that, when given a graphG=(V,E) with treewidth ≤k, computes the pathwidth ofGand a path-decomposition ofGof minimum width.