c++ - Determining order of traversal of a sequence -
i have list of elements 1 30 in ascending order. list may or may not contain 30 elements. can start traversing list point , once reach end, can jump , resume traversal other end, i.e. along lines of circular queue.
given 2 consecutive elements (by position, may or may not value), possible determine direction of traversal, i.e. beginning end, or other way?
note: don't have access list's indices , given values @ instant.
i can 3 values, not two.
no, it's not possible determine direction of traversal given 2 elements. conditions allow following list: [1, 30]
.
you're given 2 consecutive elements: 1, 30
. did start @ 1
travel right reach 30
, or did travel left , wrap around reach 30
? it's impossible tell.