# SKP's Algorithms and Data Structures #1

### This article is a version of the Graph Search or Graph Traversal Code in C Programming Language. Read the entire series to find out more!

Join the DZone community and get the full member experience.

Join For FreeMy article series on algorithms and data structures in a sort of "programming language agnostic way." A few of the algorithms and data structures are in C, a few in C++, and others in Core Java. There is an assorted collection for learning, revising, revisiting, quick refresh, and a quick glance for interviews. You may even include them directly for professional or open-source efforts. I have included an explanation only for a few of these! I hope these turn out to be really helpful as per the author’s intention.

## Graph Search or Traversal Algorithms

A graph is a set of connected vertices {V} and edges {E}. A graph may be connected, disconnected, weighted, or non-weighted. In other terms, a Graph could also be a tree with cycles. Graph Search or Traversal can be done in two ways as explained below:

**1. Depth First Search — **In this type of search, we begin at a vertex Vi and traverse through all vertices from Vi unto Vx depth-wise, until there is no adjacent vertex that is unvisited. Then, we back up all the way up to an unvisited vertex Vy and continue. We continue until there are no unvisited vertices left. It represents * Backtracking *in Algorithmic Problem Solving.

**2. Breadth-First Search —**In this type of search, we begin at a vertex Vi and traverse each vertex Vj that is reachable from there. Then, we continue in the same way at every vertex reachable from Vj. It creates a queue of vertices visited from a given vertex and, then, deletes each of them if visited or after visiting them. The process is terminated once there is no non-visited vertex left. It represents

*in Algorithmic Problem Solving.*

__Dynamic Programming__Published at DZone with permission of Sumith Puri. See the original article here.

Opinions expressed by DZone contributors are their own.

Comments