Calculating Subsets of an Array Recursively?

I'm just really confused here...
I need to take a positive integer n
E.G.
Output:
Enter n: 3
{1}
{2}
{3}
{1, 2}
{1, 3}
{2, 3}
{1, 2, 3}
I know how to take input and all of that jazz... But I'm just abhorrently stuck with the recursion part...
Help me out?

petes1234 wrote:
What works for me is I start with the trivial an work my way up. This means that I start with an array of 0 items, then 1item, and 2 items, and think through with pencil and paper how I would recursively figure out all the permutations (or is it combinations -- my math is getting rusty!). Then see if I can come up with an algorithm that will work for an array of any size. But again, firstly, think small and simple!I usually do it the opposite way:
1. Figure out the base case (I get we are not into the opposite part yet!)
2. Assuming you know how to solve the case of size N, use that to solve the case of size N+1.
This is easy: if you can generate all the combinations of 1...N, the combinations of 1...N+1 will be that list repeated twice: once without adding (N+1) and once adding (N+1).

Similar Messages

  • Could someone help me with arrays & recursion??

    Hi, I'm new here and I'm having trouble.
    I have to write a java application which uses recursion to find the maximal contiguous sum in a list of integers.
    The input is read from a text file where each line represents a list containing the following integers:
    For example, it might contain
    7 -2 -4 30 15 -7 -5 1000
    2 -50 100
    6 1000 -2000 900 2800 -2900 2801
    4 100 -10 5 8
    4 100 -50 5 8
    And for the output, for each line of data read, I have to display the largest sum of consecutive integers in the list followed by the list itself. For example for the lists above, my output would be:
    (on the left side is the largest sum of consecutive integers and on the right is the list of integers)
    1033

    R.S. wrote:
    Hi, I'm new here and I'm having trouble.
    I have to write a java application which uses recursion to find the maximal contiguous sum in a list of integers.
    The input is read from a text file where each line represents a list containing the following integers:
    For example, it might contain
    7 -2 -4 30 15 -7 -5 1000
    2 -50 100
    6 1000 -2000 900 2800 -2900 2801
    4 100 -10 5 8
    4 100 -50 5 8
    And for the output, for each line of data read, I have to display the largest sum of consecutive integers in the list followed by the list itself. For example for the lists above, my output would be:
    (on the left side is the largest sum of consecutive integers and on the right is the list of integers)
    1033Where did this 1033 come from? Could you explain your problem in a bit more detail and also post what you have done so far and explain where you are stuck: only posting the problem description sound a bit like "can some one do it for me", it's better to ask a specific question here.

  • Calculating mode with interger arrays.

    I'm having some trouble implementing code to search for modes inside of an interger array. The array is of values from 0 to 100.
    public static String modeFinder(int[] input)
    String output = "";
    int[] modes = new int[input.length/2];
    int[] occurances = new int[input.length/2];
    int counter = 0;
    int counter2 = 0;
    for (int i = 0; i < input.length; i++)
    int num1 = input;
    for (int j = 0; j < input.length; j++)
    if (input[i] == input[j])
    counter++;
    if (counter > 1)
    modes[counter2] = num1;
    occurances[counter2] = counter;
    counter2++;
    The last part is where i am having trouble. I esentially need to find the highest value in the occurances array and then check to see if there are multiple modes and then make a connection with the modes array of actual interger values that are a part of the mode. Thanks for any help.

    Now you get to figure out how I did it....
    public class Test {
      public static void main(String[] args) {
        int[] myInt = {1,2,3,4,5,6,7,6,5,4,3,2,1,2,3};
        int min=100, max=0;
        for (int x=0; x<myInt.length; x++) {
          if (myInt[x]>max) max=myInt[x];
          if (myInt[x]<min) min=myInt[x];
        System.out.println("min="+min+" max="+max);
        int[] cnts = new int[max-min+1];
        for (int x=0; x<myInt.length; x++) cnts[myInt[x]-min]++;
        int maxCnt = -1;
        for (int x=0; x<cnts.length; x++) if (cnts[x]>maxCnt) maxCnt = cnts[x];
        for (int x=0; x<cnts.length; x++) if (cnts[x]==maxCnt)  System.out.println("mode at "+(x+min));

  • Multiplying elements of two different arrays

    hey, I have a while loop thats performing two separate operations similtaneously and filling the data elements of two different 1d arrays with data.with each iteration of the loop a new value pass from an operation to an array.
    I need to multipy to corresponding elements of the arrays such the first element of one array is skipped. so element i0 * element j1 , element i1 * elemnent j2 etc. how can i acess the elements and make the calculations? arrays could have hundreds of elements.
    Thanks.
    Brendan

    blue silver wrote:
    hi Peter,
    I have an array of 2,000,000 values (each long int). I need to do an "Moving average" operation which would than:
    1) takes average of the first 10 values , plots it
    2) remove the first value ,add 11.th value, take average, plots it in the next 100 ms in the chart
    3) remove the first value, add 12.th value, take average, plots it in the next 100 ms in the chart
    (as you see , it is a kind of shifting) the averaged array elements is always 10 , and after averaging those 10 elements , plot it with 100 ms distance in the graph.
    1999989)  remove the 1,999,989 th element , add the last element
    you have a possible idea ?
    your help will be tremendously appreciated.
    Regards
    Silver
    Try this.  It iterates 10 times taking a subset of the array each time to sum it to a shift register.  When done, divides by the total number of iterations.  So it adds i0 to i1 to i2 to i3 to i{N}.  For each element from i0 up.  It will give you an array where n elements are missing  (because elements 0 through n-1 don't have N samples to average to.
    Message Edited by Ravens Fan on 11-26-2007 09:26 PM
    Attachments:
    Example_BD.png ‏4 KB

  • Recursive Help!!!!

    I was given the assignment of writing a recursive method for finding the median of an array and I am having a great deal of difficulty. This is what I have so far and I am thinking that this is not even the way to go about solving for the median. Can anyone help me please????
    public static int median( double [] A, int i, int j, int k)
    if (A[i] < =A[j] )
    if ( A[j] <= A[k] )
    return j ;
    else if ( A[i] < = A[k] )
    return k ;
    else
    return i ;
    else // A[j] < A[i]
    if ( A[i] <= A[k] )
    return i ;
    else if ( A[j] < = A[k] )
    return k ;
    else
    return j ;

    First, when you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.
    Second, can you describe the recursive algorithm without using Java? E.g. in plain ol' English, or pseudocode, or a mathematical notation.
    For example, the classic recursion example, factorial (!) :
    For non-negative integers N:
    If N == 0, then N! is 1
    If N > 0, then N! = N * ((N-1)!)
    Make sure you understand the following without regard to Java:
    * How your algorithm is defined in terms of itself (e.g., how the median of the array is based on the median of a subset of the array)
    * What the non-recursive, fundamental case is (e.g., the median of a single element is that element)
    So, are you having trouble with the recursive nature of the problem, or with the mechanics of how to express that in Java?

  • Multiple Comboboxes with single instance of Array Collection

    First off - thanks to everyone for their contributions.  This forum provides a lot of good information.
    I'm stuck on a particular problem and I suspect I'm not thinking about the issue correctly.
    I'm developing a dynamic module that instantiates components at runtime based on an XML scheme.  Many of these components are drop-downs that are chained togther (a selection in one drives the population of the next)
    I loop through the initial XML document to create and layout the components.  I have been using a single Array Collection to populate the drop-down.  This worked fine with the chained comboboxes since I only load one combox initially.  However, when I add a couple of static combo boxes, the arraycollection seemed to be binding to the orginal combobox.  For example, if I create 3 combo boxes they have drop-down values that display all 3 lists appended together.  I was a bit surprised because I didn't think that I could bind an Array Collection.  I certainly haven't defined a Binable ArrayCollection.
    I thought I could solve the issue by simply creating a unique Array Collection at runtime - one for each element.  However, I don't think this is possible or I can't figure out how to create a new Array Collection with a dynamic name - something like this:
    I was hoping this would work -
    var newDropDown_[numOfElement]:ArrayCollection = new ArrayCollection(); 
    I've tried to use a Dictionary object to store each ArrayCollection.  I couldn't get that to work properly.
    Essentially - my code loops on the number of components to add:
    for (var i:int = 0; i < numFormElements; i++)
              for (var j:int = 0; j < numvalues; j++)
                                    var valuefield:String = 'value_' + [j+1];
                                    var obj:Object=new Object();
                                    obj.label=instFields[i][valuefield].@label;
                                    obj.data=instFields[i][valuefield].@data;
                                    newDropDown.addItemAt(obj,j);
    Then I add the components:
              var c:ComboBox = new ComboBox ();
                c.labelField='label';
                c.name=numberOfElement.toString();                                  
                c.dataProvider=    newDropDown;
                _h1.addChild(c);
                numComboDropDwns.push(c);
    I need a way of looping, getting data and populating each component independently??
    Any ideas?
    Thanks,
    John

    I went a different route and solved the issue.  For someone looking at a similar problem - this what I ended up doing:
    I just loaded one array collection with data for all of the drop-downs on the form.  I then populated each dataprovider with individual elements from the array.
    for (var i:int = 0; i < numFormElements; i++)
    for (var j:int = 0; j < numvalues; j++)
                                    var valuefield:String = 'value_' + [j+1];
                                    var obj:Object=new Object();
                                    obj.label=instFields[i][valuefield].@label;
                                    obj.data=instFields[i][valuefield].@data;
                                    newDropDown.addItemAt(obj,elementCounter);
                                    elementCounter = elementCounter + 1;
    I keep track of the element #, number of values for each element and the overall index for the array.
    Each data provider is then loaded with the subset from the array:
    for (var z:int = (_counter - _numvalues) ; z < _counter; z++)
                                var _label:String=    newDropDown.getItemAt(z).label.toString();
                                var _data:String = newDropDown.getItemAt(z).data.toString();
                                c.dataProvider.addItem({label:[_label],data:[_data]});
    This seems to work nicely - each component is created and loaded with only their data.  I spent 3 days searching for a way to create a dynamic arraycollection at runtime.  I don't think it's possible - but I'm not sure it was the best method anyway.

  • Auto-indexing is slow for arrays with 1 dimensions

    Hi,
    I was looking at the performance of operations on all individual elements in 3D arrays, especially the difference between auto-indexing (left image) and manual-indexing (right image, calling "Index array" and "Replace array subset" in the innermost loop). I'm a bit puzzled by the results and post it here for discussion and hopefully somebody's benefit in the future.
    Left: auto-indexing; right: manual-indexing
    In the tests I added a different random number to all individual elements in a 3D array. I found that auto-indexing is 1.2 to 1.5 times slower than manual-indexing. I also found that the performance of auto-indexing is much more dependent on the size the dimensions: an array with 1000x200x40 elements is 20% slower than an array with 1000x40x200 elements. For manual-indexing there is hardly any difference. The detailed results can be found at the end of this post.
    I was under the impression that auto-indexing was the preferred method for this kind of operation: it achieves exactly the same result and it is much clearer in the block diagram. I also expected that auto-indexing would have been optimized in LabView, but the the tests show this is clearly not the case.
    What is auto-indexing doing?
    With two tests I looked at how auto-index works.
    First, I looked if auto-indexing reorganizes the data in an inefficient way. To do this I made a method "fake-auto-indexing" which calls "Array subset" and "Reshape array" (or "Index array" for a 1D-array) when it enters _every_ loop and calls "Replace array subset" when exiting _every_ loop (as opposed to manual-indexing, where I do this only in the inner loop). I replicated this in a test (calling it fake-auto-indexing) and found that the performance is very similar to auto-indexing, especially looking at the trend for the different array lengths.
    Fake-auto-indexing
    Second, I looked if Locality of reference (how the 3D array is stored in memory and how efficiently you can iterate over that) may be an issue. Auto-indexing loops over pages-rows-columns (i.e. pages in the outer for-loop, rows in the middle for-loop, columns in the inner for-loop). This can't be changed for auto-indexing, but I did change it for manual and fake-indexing. The performance of manual-indexing is now similar to auto-indexing, except for two cases that I can't explain. Fake-auto-indexing performs way worse in all cases.
    It seems that the performance problem with auto-indexing is due to inefficient data organization.
    Other tests
    I did the same tests for 1D and 2D arrays. For 1D arrays the three methods perform identical. For 2D arrays auto-indexing is 15% slower than manual-indexing, while fake-auto-indexing is 8% slower than manual-indexing. I find it interesting that auto-indexing is the slowest of the three methods.
    Finally, I tested the performance of operating on entire columns (instead of every single element) of a 3D array. In all cases it is a lot faster than iterating over individual elements. Auto-indexing is more than 1.8 to 3.4 times slower than manual-indexing, while fake-auto-indexing is about 1.5 to 2.7 times slower. Because of the number of iterations that has to be done, the effect of the size of the column is important: an array with 1000x200x40 elements is in all cases much slower than an array with 1000x40x200 elements.
    Discussion & conclusions
    In all the cases I tested, auto-indexing is significantly slower than manual-indexing. Because auto-indexing is the standard way of indexing arrays in LabView I expected the method to be highly optimized. Judging by the tests I did, that is not the case. I find this puzzling.
    Does anybody know any best practices when it comes to working with >1D arrays? It seems there is a lack of documentation about the performance, surprising given the significant differences I found.
    It is of course possible that I made mistakes. I tried to keep the code as straightforward as possible to minimize that risk. Still, I hope somebody can double-check the work I did.
    Results
    I ran the tests on a computer with a i5-4570 @ 3.20 GHz processor (4 cores, but only 1 is used), 8 GB RAM running Windows 7 64-bit and LabView 2013 32-bit. The tests were averaged 10 times. The results are in milliseconds.
    3D-arrays, iterate pages-rows-columns
    pages x rows x cols : auto    manual  fake
       40 x  200 x 1000 : 268.9   202.0   268.8
       40 x 1000 x  200 : 276.9   204.1   263.8
      200 x   40 x 1000 : 264.6   202.8   260.6
      200 x 1000 x   40 : 306.9   205.0   300.0
     1000 x   40 x  200 : 253.7   203.1   259.3
     1000 x  200 x   40 : 307.2   206.2   288.5
      100 x  100 x  100 :  36.2    25.7    33.9
    3D-arrays, iterate columns-rows-pages
    pages x rows x cols : manual  fake
       40 x  200 x 1000 : 277.6   457       
       40 x 1000 x  200 : 291.6   461.5
      200 x   40 x 1000 : 277.4   431.9
      200 x 1000 x   40 : 452.5   572.1
     1000 x   40 x  200 : 298.1   460.4     
     1000 x  200 x   40 : 460.5   583.8
      100 x  100 x  100 :  31.7    51.9
    2D-arrays, iterate rows-columns
    rows  x cols  : auto     manual   fake
      200 x 20000 :  123.5    106.1    113.2    
    20000 x   200 :  119.5    106.1    115.0    
    10000 x 10000 : 3080.25  2659.65  2835.1
    1D-arrays, iterate over columns
    cols   : auto  manual  fake
    500000 : 11.5  11.8    11.6
    3D-arrays, iterate pages-rows, operate on columns
    pages x rows x cols : auto    manual  fake
       40 x  200 x 1000 :  83.9   23.3     62.9
       40 x 1000 x  200 :  89.6   31.9     69.0     
      200 x   40 x 1000 :  74.3   27.6     62.2
      200 x 1000 x   40 : 135.6   76.2    107.1
     1000 x   40 x  200 :  75.3   31.2     68.6
     1000 x  200 x   40 : 133.6   71.7    108.7     
      100 x  100 x  100 :  13.0    5.4      9.9
    VI's
    I attached the VI's I used for testing. "ND_add_random_number.vi" (where N is 1, 2 or 3) is where all the action happens, taking a selector with a method and an array with the N dimensions as input. It returns the result and time in milliseconds. Using "ND_add_random_number_automated_test.vi" I run this for a few different situations (auto/manual/fake-indexing, interchanging the dimensions). The VI's starting with "3D_locality_" are used for the locality tests. The VI's starting with "3D_norows_" are used for the iterations over pages and columns only.
    Attachments:
    3D_arrays_2.zip ‏222 KB

    Robert,
    the copy-thing is not specific for auto-indexing. It is common for all tunnels. A tunnel is first of all a unique data space.
    This sounds hard, but there is an optimization in the compiler trying to reduce the number of copies the VI will create. This optimization is called "in-placeness".
    The in-placeness algorithm checks, if the wire passing data to the is connected to anything else ("branch"). If there is no other connection then the tunnel, chance is high that the tunnel won't create an additional copy.
    Speaking of loops, tunnels always copies. The in-placeness algorithm cannot opt that out.
    You can do a small test to elaborate on this: Simply wire "0" (or anything less than the array sizy of the input array) to the 'N' terminal.......
    Norbert
    PS: Auto-indexing is perfect for a "by element" operation of analysis without modification of the element in the array. If you want to modify values, use shift registers and Replace Array Subset.
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • How does one empty an array during runtime with a front panel switch

    I can 'empty array' from the front panel during runtime but I want to empty all arrays (20) from my vi with a front panel switch (see screenshot). I have used replace array subset and reshape array with no success. Any help would be appreciated
    Attachments:
    TempScan_screenshot.JPG ‏26 KB

    Hmm... You can empty an array by reshaping it or by assigning a constant empty array - using local variables or properies of the original control (see attached example... hmmm... not the best one ). May be you can attach a part of your code to see what is better to do in the given case.
    Attachments:
    reset_table.vi ‏20 KB

  • Swap element in array

    I am trying to control a screw elevator with labview.  I have an array which holds the values for current lift position.  Once the lift is at a new position I need to overwrite the old position of the lift with the new value in the array.  I went through all the array commands and dont think anyone is going to work.  I am using labview 7.0

    Replace Array Subset should work. You can use it for single elements - one element is a subset of the array. Just feed it the index of the element you want to overwrite and the new value. You may also need to put the array into a shift register.
    Lynn

  • Example on how to set an array as a Global Variable (LV2?).

    Hi,
    I am new to Labview and recently I have been given the task to evaluate labview as our new data acquisition software.
    Let me briefly describe what we currently have set-up and what I need to accomplish.
    We have developed several dll's (created in C) to access the shared memory where the data is located and I have imported these dll's in labview and read them in as one big 1-d array. (There are several 1-d array's that I import but I will try to keep things simple by starting out with one)
    Now I want to share this array to several sub-vi�s, which will I am planning to call from the run-time menu. How can I assign this array globally so that I can access it from any sub-vi?
    For example, lets say
    that my array name that I imported is called ARRAY1 (name created using the local variable option). ARRAY1 is a 1-d array with 10000 elements.
    I would like to access only a few elements of this array on another sub-vi by its name and index number i.e. ARRAY1[10], ARRAY1[20].
    Please let me know if you need any more information.
    I would really appreciate it if someone can help me out.
    Thanks
    Nish
    My E-mail: [email protected]

    Attached is the VIs in LV 6i format...The advantage of those VIs is that they allow you to read and write subsets of the array, not just one element at a time.
    MTO
    Attachments:
    Example.vi ‏27 KB
    ArrayGlobal.vi ‏27 KB

  • Data extraction from an array of data

    So I want to extract a
    subset from an array of data. 
    I have two columns of data that I need to do with,
    these are potential energy (expressed in terms of kT) and relative separation.  The data typically results in a parabola-type
    shape with the potential energy on the y-axis and the separation on the
    x-axis.  The potential energy starts at
    high kT's at small separation and then decreases to zero as the separation
    increases and then it starts to increase again once it is past zero kT.  The issue I have is that I need to disregard
    any data that is greater than 6 kT.  Thus
    I need to extract the data (both the potential energy data and the
    corresponding separation data) from the array that is 6kT or below.  So the problem I am having is trying to work
    out how to approach the extraction of this data.  I would love to get some suggestion as to how
    I should approach it.
    I initially thought of using a mathscript node to do this,
    but I am not sure of how I should code this, if this is indeed possible.
    Another option I considered was to use one of the array vi's
    to perform this extraction as I thought I could use them to find the element
    where the kT is higher than 6 and the corresponding index element which I could
    then use to extract the relevant portions of the array.  But I don't see an easy way to achieve this.
    So the vi I will write for this will function will actually
    be a subvi of another vi I have written (this vi is named ‘non-linear fit to PE
    data mod.vi' and it also has a couple of other subvis).  I have attached this vi and a relevant data
    file (as an example of the data I will be getting and needing to analyse) in a
    zip file.  I haven't included an example
    of the subvi I need to write because I looking to find some pointers as to how
    I could do this first.  In the ‘non-linear
    fit to PE data mod.vi' I have included a text box in the location I will be
    putting this subvi.
    Any help in helping me out here would be appreciated.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    data extraction help needed.zip ‏31 KB

    Try the attached VI. as per my understanding you want to remove the data in the array which is grater than the specified value,am right?
    Balaji PK (CLA)
    Ever tried. Ever failed. No matter. Try again. Fail again. Fail better
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
    Attachments:
    Remove Data.vi ‏8 KB

  • Subset of an arrayCollection

    How do I select a subset of an array
    Collection to appear in a datagrid? For example, in the code below, how do I select only the records where pop > 2000?
    <?xml version="1.0"?>
    <!-- dpcontrols\SimpleDP.mxml -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  creationComplete="creationCompleteHandler()">
        <mx:Script>
            <![CDATA[
    import mx.collections.ArrayCollection;
    [Bindable] private var _populations:ArrayCollection;
                public function creationCompleteHandler():void {
                    _populations=new ArrayCollection;
                    _populations.addItem({country: "Canada", continent:"NA", pop:"50"});
                    _populations.addItem({country: "Ven", continent:"SA", pop:"1000"});
                    _populations.addItem({country: "USA", continent:"NA", pop:"5000"});
                    _populations.addItem({country: "Brazil", continent:"SA", pop:"4000"});
             ]]>
        </mx:Script>
        <mx:DataGrid  id="datagrid"   dataProvider="{_populations}" width="100%" height="100%" />
    </mx:Application>

    hi,
    You use a filter function on your array collection, this is reasonably simple I have a basic example which I did for another poster a few weeks back
    http://flashhub.net/filter/ - source is included
    So your filter would look something like this, you could hard code the value in but it is always better to use variables so that any part of your program can alter the filter requirements.
                            private var minPopulation: int = 500;  <=== global variable
                protected function arrColl_filterFunc(item:Object):Boolean
                        if (item.pop > minPopulation)               
                            return true    
                        else
                            return false;

  • When does an array end? for TCP

    Hello,
    I have a numeric control which is an array.
    I have noticed that I can stretch this with the pointer, and there are
    more elements to the array.
    However, that array is written to a labview TCP socket.
    I know that when I code in 'C' and use sockets, that I MUST inform the
    WRITER how
    many bytes are being sent into the socket to be received, on the other
    end, by the server.
    However, with labview, the WRITE does NOT have a #-of-bytes-to-write
    input wire.
    This is now a problem because my server is NOT reading the data properly
    from labview.
    I fear it is because the digital controlling array does not have a size
    limit?
    So...
    When I wire an array into a TCP socket, to write to it, HOW does it know
    how many
    of those seemingly endl
    ess array elements to write?
    Does an array have an end?
    tom

    Certainly the array has an end. Since LabVIEW knows the number of elements in the array, it will send them all. If you want to limit the number, you must take the subset of the array before sending it into the TCP socket. If you need the receiver to know how many are coming, you must take the array size yourself and write it to the socket, before the data. This is very similar to raw file IO. the only things sent are what you send it.
    Stu
    Stu McFarlane
    Viewpoint Systems, Inc.

  • How to edit subarray "block" of array?

    Hey all,
    What's the best way to go about replacing the elements in a 20x20 section of a larger array? Does LabView allow this? I see that it's possible to replace the elements of an entire row/column at one time, but I can't find any documentation on changing a block of elements.
    Any advice?
    Thanks in advance to anyone who has the time to help out. Kudos shall flow as wine.
    Solved!
    Go to Solution.

    Wire both indices of Replace Array Subset (with 2D array input) and wire your 2D block into the new element input.  It will replace the block inside the larger array.  It will not grow your original array if the block extends beyond its limits, but you didn't really want to do that anyway.

  • Storing set of values in an array

    I am curious how this would be done best. I have 15 sets of x and y values, that should be stored together. I was thinking I could have an array, holding 15 other arrays, each holding the x and y value? Is that a valid way to do this? Also, is there a way to create those arrays holding the x and y, dynamically, so they just get numbered?
    MainArray[
         subArray[x1, y1];
         subArray[x2, y2];
         subArray[x3, y3];
         subArray[x4, y4];
         subArray[x5, y5];
         subArray[x6, y6];
         subArray[x7, y7];
         etc...
    Obviously, above is not correct AS. Is this even a way to do this? Are there other much better ways???
    Thanks a lot!

    In addition to Ned's suggestion you can use points:
    var array:Array = [new Point(100, 50), new Point(40, 30), etc.]
    You would read/write it the same way as in Ned's example:
    array[1].x
    array[1].y
    Although Ned's suggestion is more compact, if you need to use Point class' properties and methods that may save some calculations (especially if the array intended to use in some physics engine) - holding x/y in point instance is probably more desirable.

Maybe you are looking for