concept item in category algorithms

This is an excerpt from Manning's book Algorithms and Data Structures in Action.
Its implementation, however, needs to take care of details like:

This is an excerpt from Manning's book Grokking Algorithms: An illustrated guide for programmers and other curious people.
The binary_search function takes a sorted array and an item. If the item is in the array, the function returns its position. You’ll keep track of what part of the array you have to search through. At the beginning, this is the entire array:
if guess < item: low = mid + 1 !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":2}]]"} !@%STYLE%@!
This is the guitar row, which means you’re trying to fit the guitar into the knapsack. At each cell, there’s a simple decision: do you steal the guitar or not? Remember, you’re trying to find the set of items to steal that will give you the most value.

This is an excerpt from Manning's book Grokking Artificial Intelligence Algorithms.
A function that iterates over a list and prints each item in the list—The number of operations is dependent on the number of items in the list. The cost is O(n).
A function that compares every item in a list with every item in another list—This operation costs O(n²).
Figure 4.17 Measuring the fitness of individuals
![]()
To make things interesting, the refinery requires a steady rate of extraction, given the extraction time and the value of the item. It’s assumed that the value of the refined material is more or less the same as the value of the item. The problem becomes an ordering problem. In what order should the items be processed to maintain a constant rate of value? Table 5.2 describes the items with their respective extraction times.
Table 5.2 Factory value per hour: 600,000 (view table figure)
Item ID
Item name
Weight (kg)
Value ($)
Extraction time
1
Axe
32,252
68,674
60
2
Bronze coin
225,790
471,010
30
3
Crown
468,164
944,620
45
4
Diamond statue
489,494
962,094
90
5
Emerald belt
35,384
78,344
70
6
Fossil
265,590
579,152
20
7
Gold coin
497,911
902,698
15
8
Helmet
800,493
1,686,515
20
9
Ink
823,576
1,688,691
10
10
Jewel box
552,202
1,056,157
40
11
Knife
323,618
677,562
15
12
Long sword
382,846
833,132
60
13
Mask
44,676
99,192
10
14
Necklace
169,738
376,418
20
15
Opal badge
610,876
1,253,986
60
16
Pearls
854,190
1,853,562
25
17
Quiver
671,123
1,320,297
30
18
Ruby ring
698,180
1,301,637
70
19
Silver bracelet
446,517
859,835
50
20
Timepiece
909,620
1,677,534
45
21
Uniform
904,818
1,910,501
5
22
Venom potion
730,061
1,528,646
5
23
Wool scarf
931,932
1,827,477
5
24
Crossbow
952,360
2,068,204
25
25
Yesteryear book
926,023
1,746,556
5
26
Zinc cup
978,724
2,100,851
10