Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Accessing array information

    Beginners
    3
    3
    236
    Loading More Posts
    • 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.
    • LinkCraft
      LinkCraft F last edited by

      Let’s say I have an array of 1000 variables and each one of them is a set of 2 random numbers

      Example
      Var[0] = {563,228}
      Var[1] = {1145,105}
      Var[2] = {3,447}
      And so on

      How can I see if there’s a variable with a specific set of numbers without checking them all?

      1 Reply Last reply Reply Quote 0
      • Gothon
        Gothon F last edited by Gothon

        If the numbers are stored in a simple array as you have described you would have to just check them all.

        However it is possible to build a fast look up table that can find the variable with a set of numbers without looking at them all.
        https://en.wikipedia.org/wiki/Hash_table

        It is even possible to go a step further. At the cost of false positives you can use a bloom filter that can check to see if a set of numbers is present without actually storing all of them in a table thus saving time and memory.
        https://en.wikipedia.org/wiki/Bloom_filter

        1 Reply Last reply Reply Quote 1
        • T
          tony7059 last edited by

          Very interesting topic! I'm used to simply using Java's HashMap object which implements things for you. I've always been curious about how to implement the same thing in cases where this isn't a built-in feature of a language.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post