Corrected Circular-Search README

This commit is contained in:
2025-09-13 21:35:53 -04:00
parent 603b360f6f
commit 0474d82f94

View File

@@ -8,6 +8,10 @@ and ideas.
Remember, that you should design how the algorithm will work on paper before
coding.
Some sample code showing show to read in a line of numbers and store them as a
list of ints can be found here:
[cs412_reading_input.py](https://canvas.jmu.edu/courses/2112008/files/178177051?wrap=1)
## Logarithmic Search in a Circularly Sorted List
A list $A[0..(n-1)]$ is circularly sorted if there is an index $i$ such that the
@@ -16,9 +20,9 @@ list. For example $\{7, 8, 10, 1, 2, 3, 4\}$ is circularly sorted, since the
subarray $A[3..6]$ concatenated with the subarray $A[0..2]$ is the array
$\{1, 2, 3, 4, 7, 8,
10\}$, which is sorted. Your task is to write a recursive algorithm, which given
a a circularly sorted array with no duplicate values and a query integer $q$
a a circularly sorted array with **no duplicate** values and a query integer $q$
determines and returns the index of $q$ in the array if it exists, or returns
$-1$ otherwise. Your algorithm should run in $O(log n)$ time.
$-1$ otherwise. **Your algorithm should run in $O(log n)$ time**.
### Input
@@ -48,4 +52,5 @@ if it exists, or -1 if it does not exist in the list.
### Turning it in
Save your solution `cs412_circular_sort_search.py` and turn it in to Gradescope.
Save your solution **cs412_circular_sort_search.py** and turn it in to
Gradescope.