Ejemplo n.º 1
0
        //Function for seeing if a movie exists
        public int SearchMovies(string movieTitle)
        {
            //If the movie to search for equals the current node, return 1
            if (movie.getTitle() == movieTitle)
            {
                return(1);
            }
            else
            {
                //If the left subtree ins't empty, search through it
                if (leftNode != null)
                {
                    return(leftNode.SearchMovies(movieTitle));
                }

                //If the right subtree ins't empty, search through it
                if (rightNode != null)
                {
                    return(rightNode.SearchMovies(movieTitle));
                }
            }

            //If the movie doesn't exist in the tree, return -1
            return(-1);
        }
 //Searching for a movie
 public int SearchMovies(string movieTitle)
 {
     //If root is not null then keep searching
     if (root != null)
     {
         int result = root.SearchMovies(movieTitle);
         return(result);
     }
     return(-1);
 }