array and string algorithms