repeat for each vendor does the vendor have items on my list and is the cost less than predicted cost for the item if yesbuy and remove from listif nomove on to the next vendor if no more vendorsend this is simple iteratorwith decision and an action if we were to implement thiswe would need data structures to define both the list of items we want to buy as well as the list of items of each vendor we would need to determine the best way of matching items in each list and we need some sort of logic to decide whether to purchase or not there are several observations that we can make regarding this algorithm firstlysince the cost calculation is based on predictionwe don' know what the real average cost isif we underpredict the cost of an itemwe come to the end of the market with items remaining on our list thereforewe need an efficient way to backtrack to the vendor with the lowest cost alsowe need to understand what happens to the time it takes to compare items on our shopping list with items sold by each vendor as the number of items on our shopping listor the number of items sold by each vendorincreases the order in which we search through items and the shape of the data structures can make big difference to the time it takes to do search clearlywe would like to arrange our listas well as the order we visit each vendorin such way that we minimize search time alsoconsider what happens when we change the buy condition to purchase at the cheapest pricenot just the below average price this changes the problem entirely instead of sequentially going from one vendor to the nextwe need to traverse the market once andwith this knowledgewe can order our shopping list with regards to the vendors we want to visit obviouslythere are many more subtleties involved in translating real-world problem into an abstract construct such as programming language for exampleas we progress through the marketour knowledge of the cost of product improvesso our predicted average price variable becomes more accurate untilby the last stallour knowledge of the market is perfect assuming any kind of backtracking algorithm incurs costwe can see cause to review our entire strategy conditions such as high price variabilitythe size and shape of our data structuresand the cost of backtracking all determine the most appropriate solution [