Platinum Partner
c#

Breadth First Search - C#

Breadth First Search using C#

class BinaryTreeNode
        {
            public BinaryTreeNode Left { get; set; }

            public BinaryTreeNode Right { get; set; }

            public int Data { get; set; }
        }


        public class BreadthFirstSearch
        {
            private Queue _searchQueue;
            private BinaryTreeNode _root;

            public BreadthFirstSearch(BinaryTreeNode rootNode)
            {
                _searchQueue = new Queue();
                _root = rootNode;
            }

            public bool Search(int data)
            {
                BinaryTreeNode _current = _root;
                _searchQueue.Enqueue(_root);

                while (_searchQueue.Count != 0)
                {
                    _current = _searchQueue.Dequeue();
                    if (__current.Data == data)
                    {
                        return true;
                    }
                    else
                    {
                        _searchQueue.Enqueue(_current.Left);
                        _searchQueue.Enqueue(_current.Right);
                    }
                }

                return false;
            }
        }
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}