Running time of Breath-First-Search — Proof

Charangan Vasantharajan
1 min readJan 21, 2020

Running time of Breath-First-Search is (V+E), where V — number of vertexes and E — number of edges.

Pseudocode for BFS.

· Enqueue and dequeue operations take O(1) time, so the total time for queuing is O(V).

· Since each adjacency list is explored at most once the sum of all the adjacency list is O(E). So the total time for exploring adjacency lists is O(E).

Therefore the total running time of BFS is O(V+E).

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Charangan Vasantharajan
Charangan Vasantharajan

Written by Charangan Vasantharajan

Data Scientist @ Iterate.ai, California | MASc @ McMaster University, Canada | Former Research Intern @ NTU, Singapore

No responses yet

Write a response