Data Structures & AlgorithmsEasyCognizant · Capgemini pattern

How many edges does a tree with n vertices have?

  1. A. n
  2. B. n(n − 1)/2
  3. C. n − 1
  4. D. n + 1

Correct answer: C. n − 1

A tree is connected and acyclic; it has exactly n − 1 edges. Adding one more edge creates a cycle, and n(n − 1)/2 is the edge count of a complete graph.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic