Simple use of the dictionary tree-"go to billions of cities three loadline data check if there is a city three Loadline

Source: Internet
Author: User

Foreword: Unconsciously come c***p half a year, have been also considered not bad. Encountered problems will only be pushed to the development, has been complaining but not the solution of the business, also encountered too big V opening (can ask Niang) water bubbling development.

There are two small things to share with you:

1) The interface of our group calls an external interface, some conditions the external interface will directly put exception (stack information, code physical path also has: ) Throw it to us, I mail it to the relevant test and development,

No accident, no reply, and then I don't know what the hell they're doing, want us to put this exception also log down ...

2) Speaking of this big V beginning, is also the development of an external interface that we want to invoke. A brief description: Make an urgent change at once, I'm going to pass a string type of code to them under certain conditions,

Specific conditions are not passed (that is, null), they will be compared with the database stored code, and then tell me whether a product is a certain aviation Li booking investment products (a bit of IQ people know to return a bool value).

This large v begins without string. Equals (not case sensitive), but uses contains.  I don't care, all I want is a bool value. As a result, this x returns code as it was to me, and I'm going to do a string comparison myself. Do not want to say too much with this parallel, I endure, I compare it.

Don't think this is over, in some depressed afternoon, he and their tests, in Lync say we call their interface, will throw an exception. So I gave them an unusual detail, roughly: "System.ArgumentException NullReferenceException in String.contains (string A, String B, Str ingcompare.*****) "and presumably everybody understands what's going on,

I asked in Lync whether there was a string.isnullorempty check for the string, this x contended said, and insisted that it was our issue of communication ... Well, a stalemate for a long time, after all, my level is not high, I went to the matter to my master said, my master to find him in person to negotiate, come back to me: This matter you do not have to control, not our problem. I can see that my master is not in a good mood.

Well, life and work will inevitably encounter a variety of problems and slag, but I am lucky to come this way, is my master and I leader interview me, and came to my team, to do every change and project, to put O (n^2)

Optimize to O (Log N), even O (N), to the extreme of simple repetition!

Book a New Year's Day to Xi ' an to play the round-trip ticket, intends to this period of time the data structure and the conventional algorithm review and collation. I remember when I came to interview, master exam my first algorithm, is the title of the article;

Special from this start, and share with you: (just a bit more nonsense, please do not blame)

As for the theory of the dictionary tree, it is very simple, not wordy, paste code:

    classTrienode { PublicTrienode[] Sontrienodes {Get;Set; }  Public CharValue {Get;Set; }  Public intNum {Get;Set; }  Public BOOLIslastnode {Get;Set; }  PublicTrienode () {Num=1; Sontrienodes=Newtrienode[ -]; }    }
 Public classTrietree {PrivateTrienode _root;  PublicTrietree () {_root=NewTrienode (); }         Public voidINSERTSTR (stringstr) {            if(string. IsNullOrEmpty (str))return; varnode =_root; varLetters =Str. ToUpper ().            ToCharArray (); foreach(varLetterinchletters) {                varPosition = letter-'A'; if(node. Sontrienodes[position] = =NULL) {node. Sontrienodes[position]=NewTrienode () {Value=Letter }; }                Else{node. Sontrienodes[position]. Num++; } node=node.            Sontrienodes[position]; } node. Islastnode=true; }         Public BOOLISEXISTSTR (stringstr) {            if(string. IsNullOrEmpty (str))return false; varnode =_root; varLetters =Str. ToUpper ().            ToCharArray (); foreach(varLetterinchletters) {                varPosition = letter-'A'; if(node. Sontrienodes[position] = =NULL)                {                    return false; } node=node.            Sontrienodes[position]; }            returnnode.        Islastnode; }    }
    classProgram {Static voidMain (string[] args) {            varTrietree =NewTrietree (); string[] Cities = {"HKG","SEL","NYC","SHA",                              "BJS","SIN","BKK"}; foreach(varCityinchcities)            {trietree.insertstr (city); } Console.WriteLine ("whether the SEL exists:"); Console.WriteLine (Trietree.isexiststr ("SEL")); Console.WriteLine ("is there a tyo:"); Console.WriteLine (Trietree.isexiststr ("Tyo"));        Console.read (); }    }

As for, like entering a character, the auto-selection box prompts the character to start the city, attractions and so on, as well as support Chinese, pinyin, etc., you can use the dictionary tree to do the transformation, we are interested to play with their own.

I wish you all a pleasant weekend.

Simple use of the dictionary tree-"go to billions of cities three loadline data check if there is a city three Loadline

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.