OA. free
Free
MathWorks Core Computer Science Core Computer Science Medium

1.

MathWorks technical mcq question, verified with a worked answer. Free to practise - no sign-up.

1. (Math Question) Edges in a Graph

What is the smallest number of edges that an undirected connected graph on N vertices can have?

Pick ONE option

Choose one option.
Show answer & explanation
Answer: C. N-1

A connected graph must have a path between every pair of vertices. The minimum structure achieving this is a tree, which by definition has exactly N-1 edges for N vertices. Adding any fewer edges would disconnect the graph, and any additional edges would create cycles (redundant for connectivity).

Step-by-step Derivation:
For a graph with N vertices to be connected, every vertex must be reachable from every other vertex. The minimal connected structure is a tree. A tree on N vertices has exactly N-1 edges by the fundamental tree property: edges = vertices - 1. For example: N=3 vertices need minimum 2 edges (forming a path or triangle without redundancy); N=4 vertices need minimum 3 edges. This is both necessary (fewer edges leave the graph disconnected) and sufficient (a tree is connected).