Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. Strings issue...

Strings issue...

Scheduled Pinned Locked Moved Algorithms
javadata-structureshelptutorialquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    ventomito
    wrote on last edited by
    #1

    Hi everyone! I'm working on a project and i need to do what follows: i have an array of strings,example: house3 house2 green23 green.5 H6 H01 G19 G78 ..and so on. I have to extract only the recurrent strings: house,green,H,G. Any idea about it? (the language is java but doesn't matter, i just need the idea!) Thanks in advance, Enrico.

    Program your life ^^

    C M A S 4 Replies Last reply
    0
    • V ventomito

      Hi everyone! I'm working on a project and i need to do what follows: i have an array of strings,example: house3 house2 green23 green.5 H6 H01 G19 G78 ..and so on. I have to extract only the recurrent strings: house,green,H,G. Any idea about it? (the language is java but doesn't matter, i just need the idea!) Thanks in advance, Enrico.

      Program your life ^^

      C Offline
      C Offline
      cmk
      wrote on last edited by
      #2

      The following should give you some ideas: http://en.wikipedia.org/wiki/Patricia_tree[^]

      ...cmk The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying. - John Carmack

      1 Reply Last reply
      0
      • V ventomito

        Hi everyone! I'm working on a project and i need to do what follows: i have an array of strings,example: house3 house2 green23 green.5 H6 H01 G19 G78 ..and so on. I have to extract only the recurrent strings: house,green,H,G. Any idea about it? (the language is java but doesn't matter, i just need the idea!) Thanks in advance, Enrico.

        Program your life ^^

        M Offline
        M Offline
        Mohammad Dayyan
        wrote on last edited by
        #3

        What are you gonna do exactly ? Do you want to identify the strings that contain house,green,H,G ?

        V 1 Reply Last reply
        0
        • M Mohammad Dayyan

          What are you gonna do exactly ? Do you want to identify the strings that contain house,green,H,G ?

          V Offline
          V Offline
          ventomito
          wrote on last edited by
          #4

          not exactly. I have some strings and i have no idea which they are. I have to identify the recurrent substrings such as house, green...but i don't have them as input..

          Program your life ^^

          1 Reply Last reply
          0
          • V ventomito

            Hi everyone! I'm working on a project and i need to do what follows: i have an array of strings,example: house3 house2 green23 green.5 H6 H01 G19 G78 ..and so on. I have to extract only the recurrent strings: house,green,H,G. Any idea about it? (the language is java but doesn't matter, i just need the idea!) Thanks in advance, Enrico.

            Program your life ^^

            A Offline
            A Offline
            Alan Balkany
            wrote on last edited by
            #5

            Some of the problem parameters aren't clear: Do the recurrent strings always start at the beginning of the line? Do you just ignore non-letters (numbers and punctuation)? If the answer to both of these questions is yes, you can do this:

            1. For each line
            2. Extract the string of just the letters from the beginning of the line.
            3. See if this string is in a hash table. If so, it's a recurrent string.
            4. Else insert this string into the hash table.

            If the strings don't always start at the beginning of the line, you have to do multiple insertions for each string: the whole string, the substring starting at the 2nd letter, 3rd letter, etc...

            1 Reply Last reply
            0
            • V ventomito

              Hi everyone! I'm working on a project and i need to do what follows: i have an array of strings,example: house3 house2 green23 green.5 H6 H01 G19 G78 ..and so on. I have to extract only the recurrent strings: house,green,H,G. Any idea about it? (the language is java but doesn't matter, i just need the idea!) Thanks in advance, Enrico.

              Program your life ^^

              S Offline
              S Offline
              Scott Dorman
              wrote on last edited by
              #6

              You need to look at using a data structure like a Trie[^], or as was already pointed out Patrcia Trie[^]. The Wikipedia articles should give you enough information to get started on an actual implementation.

              Scott Dorman

              Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


              Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups