Depth First Traversal and Breadth First Traversal
The essential feature of DFT is that when a node is visited, all descendent of the node are visited before its unvisited brothers. In this traversal method,One starts at the root(selecting some arbitrary node as the root in the case of a graph) and explores as far as possible along each branch before backtracking. DFS can be implemented by recursive or non-recursive methods. The non-recursive method of DFS uses stack. BFT is implemented using a queue. In BFT, the general method is: Visit all successor of a visited node before visiting any successor of any of those successor.
Summary
The essential feature of DFT is that when a node is visited, all descendent of the node are visited before its unvisited brothers. In this traversal method,One starts at the root(selecting some arbitrary node as the root in the case of a graph) and explores as far as possible along each branch before backtracking. DFS can be implemented by recursive or non-recursive methods. The non-recursive method of DFS uses stack. BFT is implemented using a queue. In BFT, the general method is: Visit all successor of a visited node before visiting any successor of any of those successor.
Things to Remember
- The essential feature of DFT is that when a node is visited, all descendent of the node are visited before its unvisited brothers
- In this traversal method,One starts at the root(selecting some arbitrary node as the root in the case of a graph) and explores as far as possible along each branch before backtracking.
- DFS can be implemented by recursive or non-recursive methods.
- The non-recursive method of DFS uses stack.
- BFT is implemented using a queue.
- In BFT, the general method is: Visit all successor of a visited node before visiting any successor of any of those successor.
MCQs
No MCQs found.
Subjective Questions
Q1:
Define conjunctivitis?
Type: Short Difficulty: Easy
<p>Pink eye is commonly caused by a bacterial or viral infection, an allergic reaction, or &mdash; in babies &mdash; an incompletely opened tear duct.</p>
<p> </p>
Q2:
What are the causes of conjuctivitis?
Type: Short Difficulty: Easy
<p>Causes of pink eye include:</p>
<p>- Viruses</p>
<p>- Bacteria</p>
<p>- Allergies</p>
<p>- A chemical splashes in the eye</p>
<p>- A foreign object in the eye</p>
<p>- In newborns, a blocked tear duct</p>
<p> </p>
<ol>
<li>Viral and bacterial conjunctivitis</li>
</ol>
<p>Viral conjunctivitis and bacterial conjunctivitis may affect one or both eyes. Viral conjunctivitis usually produces a watery discharge. Bacterial conjunctivitis often produces a thicker, yellow-green discharge. Both viral and bacterial conjunctivitis can be associated with colds or with symptoms of a respiratory infection, such as a sore throat.</p>
<p> </p>
<ol>
<li>Allergic conjunctivitis</li>
</ol>
<p>Allergic conjunctivitis affects both eyes and is a response to an allergy-causing substance such as pollen. In response to allergens, your body produces an antibody called immunoglobulin E (IgE).</p>
<p> </p>
<p>iii.Conjunctivitis resulting from irritation</p>
<p>Irritation from a chemical splash or foreign object in your eye is also associated with conjunctivitis. Sometimes flushing and cleaning the eye to rid it of the chemical or object causes redness and irritation.</p>
<p> </p>
Q3:
Whar the symptoms and risk factors of the conjuctivitis?
Type: Short Difficulty: Easy
<p>The most common pink eye symptoms include:</p>
<p>- Redness in one or both eyes</p>
<p>- Itchiness in one or both eyes</p>
<p>- A gritty feeling in one or both eyes</p>
<p>- A discharge in one or both eyes that forms a crust during the night that may prevent your eye or eyes from opening in the morning</p>
<p>- Tearing</p>
<p> </p>
<p> </p>
<p> </p>
<p>Risk factors for pink eye include:</p>
<p>- Exposure to something for which you have an allergy (allergic conjunctivitis)</p>
<p>- Exposure to someone infected with the viral or bacterial form of conjunctivitis</p>
<p>- Using contact lenses, especially extended-wear lenses</p>
Q4:
How conjuctivitis can be treated and what are its nursing management?
Type: Long Difficulty: Easy
<p> </p>
<p>Treatment for viral conjunctivitis</p>
<p>There is no treatment for most cases of viral conjunctivitis. Instead, the virus needs time to run its course ;up to two or three weeks. Viral conjunctivitis often begins in one eye and then infects the other eye within a few days.</p>
<p> </p>
<p>Treatment for allergic conjunctivitis</p>
<p>If the irritation is allergic conjunctivitis, your doctor may prescribe one of many different types of eyedrops for people with allergies. These may include medications that help control allergic reactions, such as antihistamines and mast cell stabilizers, or drugs that help control inflammation, such as decongestants, steroids, and anti-inflammatory drops.</p>
<p> </p>
<p>Nursing management</p>
<p>_ wash hand before touching and after putting medicine in eyes.</p>
<p>_ accumulated secretion are always removed by wiping from inner canthus downward and outward,away from the opposite eye.</p>
<p>_ wash eyes with cold, boiled water before putting in an ointment.</p>
<p>_ warm moist compress, such as a clean washcloth compress out with hot tap water, are helpful in removing the crust.</p>
<p>_ medication is instilled immediately after the eyes have been cleaned and according to correct procedure.</p>
<p>_ don't cover infected eye</p>
Videos
No videos found.

Depth First Traversal and Breadth First Traversal
Depth First Traversal
Depth First Search (DFS)is also called depth first search. The essential feature of DFT is that when a node is visited, all descendent of the node are visited before its unvisited brothers. It traverses a single path of the graph as far as it can go until it visits a node with no successor or a node all of whose successors have already been visited.
In this traversal method,One starts at the root(selecting some arbitrary node as the root in the case of a graph) and explores as far as possible along each branch before backtracking.
Algorithm:
Input: A graph G and a vertex v of G
Output: All vertices reachable from v labeled as discovered
A recursive implementation of DFS:
procedure DFS(G,v):
label v as discovered
for all edges from v to w in G.adjacentEdges(v) do
if vertex w is not labeled as discovered then
recursively call DFS(G,w)
A non-recursive implementation of DFS:
procedure DFS-iterative(G,v):
let S be a stack
S.push(v)
while S is not empty
v = S.pop()
if v is not labeled as discovered:
label v as discovered
for all edges from v to w in G.adjacentEdges(v) do
S.push(w)
Example
For the graph below:

A depth first search strategy starts at A, assumingthat the left edges in the graph are chosen before right edges, and thatthe search remembers previously visited nodes and hence, will not repeat them (since this is a small graph). Thus the algorithm will visit the nodes in the following order:
A, B, D, F, E, C, G.
The edges traversed in this search form a tree.
The two variations of DFS visit the neighbors of each vertex in the opposite order from each other:the first neighbor of v visited followingthe recursive algorithmis the first one in the list of adjacent edges, while in the iterative method,the first visited neighbor is the last one in the list of adjacent edges. The recursive implementation will visit the nodes from the example graph above in the following order: A, B, D, F, E, C, G while the non-recursive implementation will visit the nodes as: A, E, F, B, D, C, G.
Example 2:

Applications
- Finding connected components
- Topological sorting
- Finding the bridges of a graph
- Planarity testing
- Maze generation and solving
Breadth First Traversal
Breadth First Traversal (BFS) is also called Breadth FIrst Search. It is implemented using a queue. In BFT, the general method is: Visit all successor of a visited node before visiting any successor of any of those successor.
It starts at the root of the tree(or some arbitrary node of a graph, sometimes referred to as a 'search key') and explores the neighbor nodes first, before moving to the next level neighbors, i.e. at first all the nodes in the same level are covered before moving to the next level of the graph.
Algorithm
Input: A graph Graph and a starting vertex root of Graph
Output: All vertices reachable from root labeled as explored.
A non-recursive implementation of breadth-first search:

Example 1:



Applications
- Copying garbage collection
- Finding the shortest path between two nodes u and v
- Computing the maximum flow in a flow network
References:
1.https://en.wikipedia.org/wiki/Depth-first_search
2.https://en.wikipedia.org/wiki/Breadth-first_search
2. Karumanchi, N. "Data Structures and Algorithms Made Easy"
3. Y. Langsam, M. J. Augenstein and A. M Tenenbaum, “Data Structures using C and C++”
4. R. L. Kruse, B. P. Leung, C. L. Tondo, “Data Structure and Program design in C”
Lesson
Graphs
Subject
Computer Engineering
Grade
Engineering
Recent Notes
No recent notes.
Related Notes
No related notes.