Skip to content

TopWork0ut/C-Cpp-algorithms

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Second Lab

Finding the minimum depth of a binary tree

Fisrt

Given a binary tree, find its minimum depth. The minimum depth is the total number of nodes along the shortest path from the root node to the nearest end node.

For example, the minimum depth of the following binary tree is 3. The shortest path is 1 —> 3 —> 6.

To represent the graph, you should use the adjacency list, the data is read from the input.txt file

input.txt contains: 1 #tree root 1,2 # a list of edges where the order of the vertices determines the direction. In this case, the edge is directed from 1 to 2 1,3 2,4 …

Result

Minimum tree depth should be output to the output.txt file

Credits

Queue code implementation in C language was taken from:

https://anupam-tech.medium.com/how-to-code-a-binary-tree-using-queue-implemented-using-linked-list-in-c-15c68741106c

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published