GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Logic to generate even odd pattern

I have a tableview cell which displays data in the following pattern

cell1    cell2

cell3   cell4

cell5   cell6

​cell7   cell8

cell9   cell10

I want to display my data as follows

data1  data5

data2  data6

​data3  data7

data4 data8

 

Here the number specifies the index of the cell i.e cell1 is 1st index.  Basically its an even odd pattern and this should work on any split.. for example, if tomorrow the data limit goes to 20 then 10 records on left side and  10 on right side should display. So please tell me good logic to generate the above and also logic to access  proper cell data on tap of each cell.

asked Nov 25, 2015 by anonymous

1 Answer

The series is like an AP. the first term is the i-th row and common difference is the number of rows.

answered Nov 30, 2015 by harshitgarg
...