Efficency in array will finding out the index number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Efficency in array will finding out the index number

I have three array of 5 boxes each consider I have to apply two loop one starting from an array and another start from end part of an array to find out wchich loop will search that index number quickly mean if some number is save in array number 2 index 5 than end loop will find that an array quickly if some number is save in array 1 index 2 than start loop will find that an array quickly? I have apply nested loop but it dosent work

10th Sep 2020, 12:18 PM
Irtiza Abbas
Irtiza Abbas - avatar
2 Answers
0
Please show the code, so that people can help you better
10th Sep 2020, 1:29 PM
Heng Jun Xi
Heng Jun Xi - avatar
0
If you are talking about three one-dimensional arrays then nested loops won't help you. Because when nested loop will run, the outer loop will wait for the nested one to complete. After that outer loop will take one step and inner loop will again run through the whole array you are iterating. It seems like you are talking about multithreading of some sort, but even if you'll use two threads one of which will iterate from the beginning and the other one from the end, the result will be unpredictable since we don't know when processor will switch treads. At least in Java.
10th Sep 2020, 3:41 PM
Aleksandrs
Aleksandrs - avatar