Order by pair comparisons: Difference between revisions

Content added Content deleted
(added java)
mNo edit summary
Line 123: Line 123:
// Use a binary insertion sort to order the items. It should ask for
// Use a binary insertion sort to order the items. It should ask for
// close to the minimum number of questions reqired
// close to the minimum number of questions required
for(auto& item : items)
for(auto& item : items)
{
{
Line 330: Line 330:
// Use a binary insertion sort to order the items. It should ask for
// Use a binary insertion sort to order the items. It should ask for
// close to the minimum number of questions reqired
// close to the minimum number of questions required
for _, item := range items {
for _, item := range items {
fmt.Printf("Inserting '%s' into %s\n", item, sortedItems)
fmt.Printf("Inserting '%s' into %s\n", item, sortedItems)
// lower_bound performs the binary search using InteractiveCompare to
// sort.Search performs the binary search using interactiveCompare to
// rank the items
// rank the items
spotToInsert := sort.Search(len(sortedItems), func(i int) bool {
spotToInsert := sort.Search(len(sortedItems), func(i int) bool {