+ 1

What is arbitory order in an array

22nd May 2019, 7:55 AM
Malhar Naiya
Malhar Naiya - avatar
15 Réponses
+ 7
You have finished a lot of language tutorials. What's up with that? Shouldn't you know these things?
22nd May 2019, 8:20 AM
HonFu
HonFu - avatar
+ 6
Arbitrary order means random order.
22nd May 2019, 9:51 AM
Sonic
Sonic - avatar
+ 5
Do you mean arbitrary? It means that the elements of the array are not ordered by size or anything, but can have any order.
22nd May 2019, 8:02 AM
HonFu
HonFu - avatar
+ 4
An array will not reorder the elements without you knowing. You can put them in an arbitrarily chosen spot, and then they will remain just there.
22nd May 2019, 8:27 AM
HonFu
HonFu - avatar
+ 3
Let's say you have the numbers 1, 2, 3, 4, 5. An array doesn't mind in which order you store them. Could be... [1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 1, 4, 5, 3] ... or really any other imaginable order. What part of the tutorial are you referring to?
22nd May 2019, 8:18 AM
HonFu
HonFu - avatar
+ 1
Keeping data in any order means not much but while using arrays for display you have to sort. In that case for example if you are using an array which you have to sort every time you display it would be good practice to sort it once and store it as sorted will reduce the cpu usage by not sorting it every time you use.
22nd May 2019, 8:39 AM
Melih Melik Sonmez
Melih Melik Sonmez - avatar
+ 1
Thanks
22nd May 2019, 9:15 PM
Malhar Naiya
Malhar Naiya - avatar
0
Can you give me an exampl, please
22nd May 2019, 8:16 AM
Malhar Naiya
Malhar Naiya - avatar
0
Then, how to access it
22nd May 2019, 8:19 AM
Malhar Naiya
Malhar Naiya - avatar
0
Suppose, if I access as index - 0 then, each time it will return different value ?
22nd May 2019, 8:20 AM
Malhar Naiya
Malhar Naiya - avatar
0
How to know order of element for accessing element, and where it is useful ?
22nd May 2019, 8:21 AM
Malhar Naiya
Malhar Naiya - avatar
0
Ok
22nd May 2019, 9:07 AM
Malhar Naiya
Malhar Naiya - avatar
0
Arbitrary position is an index in array. Am I right ?
22nd May 2019, 9:08 AM
Malhar Naiya
Malhar Naiya - avatar
0
When you create your array it has its own index arrArray=['data1','data5','data3','data12] When you look at it you can say there is no order right?? Infact there is for the array When you print arrArray[0] which is first record in array will be 'data1' So arrArray[0] ==> data1 arrArray[1] ==> data5 arrArray[2] ==> data3 arrArray[3] ==> data12 Every time you use arrArray[2] you get data3 so arrays has their index but this order won't look nice we call this arbitrary, this order happens by creation. Yes you can create an array with ordered list but in any case array does not care what you stored in them and it will be arbitrary for it. We use dictionary instead of array which is still array at the end but with your own indexes. I hope this helps https://code.sololearn.com/Wxl8PLTurX7n/?ref=app https://code.sololearn.com/cBn14T9gv7gR/?ref=app
22nd May 2019, 3:46 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar