Results for “Array traversal & selection”
Small, practical examples. Search by task or narrow things down below.
Find the largest array value
Track the maximum in a nonempty C integer array.
C✓ Tested
Find the smallest value in a nonempty array
C: Initialize from the first element instead of assuming a numeric sentinel.
C✓ Tested
Insert into an array with spare capacity
C: Move the trailing elements before inserting and keep the logical length separate from capacity.
C✓ Tested
Iterate over a fixed array of records
C: Compute the array element count with sizeof at the point where it is still an array.
C✓ Tested
Join an array into text
PowerShell: Join an array into text using PowerShell 7.
PowerShell✓ Tested
Join array items with a one-character separator
Bash Scripts: A local IFS controls the separator used by the quoted star expansion.
Bash Scripts✓ Tested
Locate a value in a sorted array
Java: Use Arrays.binarySearch only after establishing ascending order.
Java✓ Tested
Look up values in an associative array
Use named keys for a small in-memory configuration table.
dictionary✓ Tested
Loop over an array safely
Preserve spaces in array elements while iterating.
array✓ Tested
Merge two sorted arrays
C: Advance the pointer belonging to the smaller next element and copy any remaining suffix.
C✓ Tested
Offer a selection list
Provide a labeled HTML select with a default option.
HTML✓ Tested
Pair corresponding values from two arrays
PowerShell: Check lengths before indexing to reject mismatched input collections.
PowerShell✓ Tested