none
Algoritm for finding new/removed colums/rows in an array

    Question

  • Hello all,

    a question, I am looking for an algoritm for comparing two large arrays and finding the inserted/removed rows and columns. But it can happen that cell values change. so basically suppose you have array one:

    1   5   7   9   4
    2   6   8   2   3
    3   3   3   3   3
    5   6   7   8   4
    ab  98  dc  4c  5a
    
    
    
    1   2   5   9   9
    2   2   6   7   2
    5   2   6   8   8
    ab  2   98  dc  4c
    

    It should return that row 3 is removed from array 2 Columns 5 is added in array 1 and column 2 is removed from array 1.

    I'm very curious, but can't find a proper solution so far.

    Monday, November 07, 2016 1:48 PM

All replies

  • Hello all,

    a question, I am looking for an algoritm for comparing two large arrays and finding the inserted/removed rows and columns. But it can happen that cell values change. so basically suppose you have array one:

    1   5   7   9   4
    2   6   8   2   3
    3   3   3   3   3
    5   6   7   8   4
    ab  98  dc  4c  5a
    
    
    
    1   2   5   9   9
    2   2   6   7   2
    5   2   6   8   8
    ab  2   98  dc  4c
    

    It should return that row 3 is removed from array 2 Columns 5 is added in array 1 and column 2 is removed from array 1.

    I'm very curious, but can't find a proper solution so far.

    Monday, November 07, 2016 1:46 PM
  • Hello all,

    a question, I am looking for an algoritm for comparing two large arrays and finding the inserted/removed rows and columns. But it can happen that cell values change. so basically suppose you have array one:

    1   5   7   9   4
    2   6   8   2   3
    3   3   3   3   3
    5   6   7   8   4
    ab  98  dc  4c  5a
    
    
    
    1   2   5   9   9
    2   2   6   7   2
    5   2   6   8   8
    ab  2   98  dc  4c
    

    It should return that row 3 is removed from array 2 Columns 5 is added in array 1 and column 2 is removed from array 1.

    I'm very curious, but can't find a proper solution so far.

    Monday, November 07, 2016 1:47 PM

  • I'm very curious, but can't find a proper solution so far.

    Because there isn't one. Suppose all the numbers are the same (or very nearly the same). There is no way of knowing which columns/rows have been deleted or added.

    To make my point, I would argue that the example you gave has more than one solution. Simply put, I would state that all 5 rows have been deleted and 5 new rows (very similar to the first) have been added.

    Monday, November 07, 2016 4:18 PM
  • Hi ArieSmit,

    Welcome to the MSDN forum.

    Refer to your description, your issue is more related to the development algorithm. Since our forum is to discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor, maybe you can think about redirect to the development support forum like C++/VB…for a more professional support for your development requirement.

    As far as I know, when we compare two arrays, one array should stay the same, use another array to compare, but your idea is to compare the data after one row or column is added or removed.

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 08, 2016 3:29 AM
    Moderator