Question

In: Finance

What is the selection algorithm that will always maximize financial return on available monies for mutually...

What is the selection algorithm that will always maximize financial return on available monies for mutually exclusive projects? List all steps. No Excel

Solutions

Expert Solution

In computer science, a selection algorithm is an algorithm for finding the kth smallest number in a list or array; such a number is called the kth order statistic. This includes the cases of finding the minimum, maximum, and median elements. There are O(n)-time (worst-case linear time) selection algorithms, and sublinear performance is possible for structured data; in the extreme, O(1) for an array of sorted data. Selection is a subproblem of more complex problems like the nearest neighbor and shortest path problems. Many selection algorithms are derived by generalizing a sorting algorithm, and conversely some sorting algorithms can be derived as repeated application of selection.

The simplest case of a selection algorithm is finding the minimum (or maximum) element by iterating through the list, keeping track of the running minimum – the minimum so far – (or maximum) and can be seen as related to the selection sort. Conversely, the hardest case of a selection algorithm is finding the median. In fact, a specialized median-selection algorithm can be used to build a general selection algorithm, as in median of medians. The best-known selection algorithm is quickselect, which is related to quicksort; like quicksort, it has (asymptotically) optimal average performance, but poor worst-case performance, though it can be modified to give optimal worst-case performance as well.

Contents

  • 1Selection by sorting
    • 1.1Unordered partial sorting
    • 1.2Partial selection sort
  • 2Partition-based selection
    • 2.1Median selection as pivot strategy
  • 3Incremental sorting by selection
  • 4Using data structures to select in sublinear time
  • 5Lower bounds
  • 6Space complexity
  • 7Online selection algorithm
  • 8Related problems
  • 9Language support
  • 10See also
  • 11References
  • 12External links

Selection by sorting[edit]

By sorting the list or array then selecting the desired element, selection can be reduced to sorting. This method is inefficient for selecting a single element, but is efficient when many selections need to be made from an array, in which case only one initial, expensive sort is needed, followed by many cheap selection operations – O(1) for an array, though selection is O(n) in a linked list, even if sorted, due to lack of random access. In general, sorting requires O(n log n) time, where n is the length of the list, although a lower bound is possible with non-comparative sorting algorithms like radix sort and counting sort.

Rather than sorting the whole list or array, one can instead use partial sorting to select the k smallest or k largest elements. The kth smallest (resp., kth largest element) is then the largest (resp., smallest element) of the partially sorted list – this then takes O(1) to access in an array and O(k) to access in a list.

Unordered partial sorting[edit]

If partial sorting is relaxed so that the k smallest elements are returned, but not in order, the factor of O(k log k) can be eliminated. An additional maximum selection (taking O(k) time) is required, but since {\displaystyle k\leq n}, this still yields asymptotic complexity of O(n). In fact, partition-based selection algorithms yield both the kth smallest element itself and the k smallest elements (with other elements not in order). This can be done in O(n) time – average complexity of quickselect, and worst-case complexity of refined partition-based selection algorithms.

Conversely, given a selection algorithm, one can easily get an unordered partial sort (k smallest elements, not in order) in O(n) time by iterating through the list and recording all elements less than the kth element. If this results in fewer than k − 1 elements, any remaining elements equal the kth element. Care must be taken, due to the possibility of equality of elements: one must not include all elements less than or equal to the kth element, as elements greater than the kth element may also be equal to it.

Thus unordered partial sorting (lowest k elements, but not ordered) and selection of the kth element are very similar problems. Not only do they have the same asymptotic complexity, O(n), but a solution to either one can be converted into a solution to the other by a straightforward algorithm (finding a max of k elements, or filtering elements of a list below a cutoff of the value of the kth element).

Partial selection sort[edit]

A simple example of selection by partial sorting is to use the partial selection sort.

The obvious linear time algorithm to find the minimum (resp. maximum) – iterating over the list and keeping track of the minimum (resp. maximum) element so far – can be seen as a partial selection sort that selects the 1 smallest element. However, many other partial sorts also reduce to this algorithm for the case k = 1, such as a partial heap sort.

More generally, a partial selection sort yields a simple selection algorithm which takes O(kn) time. This is asymptotically inefficient, but can be sufficiently efficient if k is small, and is easy to implement. Concretely, we simply find the minimum value and move it to the beginning, repeating on the remaining list until we have accumulated k elements, and then return the kth element. Here is partial selection sort-based algorithm:

 function select(list[1..n], k)
     for i from 1 to k
         minIndex = i
         minValue = list[i]
         for j from i+1 to n
             if list[j] < minValue
                 minIndex = j
                 minValue = list[j]
                 swap list[i] and list[minIndex]
     return list[k]

Partition-based selection[edit]

Further information: Quickselect

Linear performance can be achieved by a partition-based selection algorithm, most basically quickselect. Quickselect is a variant of quicksort – in both one chooses a pivot and then partitions the data by it, but while Quicksort recurses on both sides of the partition, Quickselect only recurses on one side, namely the side on which the desired kth element is. As with Quicksort, this has optimal average performance, in this case linear, but poor worst-case performance, in this case quadratic. This occurs for instance by taking the first element as the pivot and searching for the maximum element, if the data is already sorted. In practice this can be avoided by choosing a random element as pivot, which yields almost certainlinear performance. Alternatively, a more careful deterministic pivot strategy can be used, such as median of medians. These are combined in the hybrid introselect algorithm (analogous to introsort), which starts with Quickselect but falls back to median of medians if progress is slow, resulting in both fast average performance and optimal worst-case performance of O(n).

The partition-based algorithms are generally done in place, which thus results in partially sorting the data. They can be done out of place, not changing the original data, at the cost of O(n) additional space.

Median selection as pivot strategy[edit]

Further information: Median of medians

A median-selection algorithm can be used to yield a general selection algorithm or sorting algorithm, by applying it as the pivot strategy in Quickselect or Quicksort; if the median-selection algorithm is asymptotically optimal (linear-time), the resulting selection or sorting algorithm is as well. In fact, an exact median is not necessary – an approximate median is sufficient. In the median of medians selection algorithm, the pivot strategy computes an approximate median and uses this as pivot, recursing on a smaller set to compute this pivot. In practice the overhead of pivot computation is significant, so these algorithms are generally not used, but this technique is of theoretical interest in relating selection and sorting algorithms.

In detail, given a median-selection algorithm, one can use it as a pivot strategy in Quickselect, obtaining a selection algorithm. If the median-selection algorithm is optimal, meaning O(n), then the resulting general selection algorithm is also optimal, again meaning linear. This is because Quickselect is a divide and conquer algorithm, and using the median at each pivot means that at each step the search set decreases by half in size, so the overall complexity is a geometric series times the complexity of each step, and thus simply a constant times the complexity of a single step, in fact {\displaystyle 2=1/(1-(1/2))} times (summing the series).

Similarly, given a median-selection algorithm or general selection algorithm applied to find the median, one can use it as a pivot strategy in Quicksort, obtaining a sorting algorithm. If the selection algorithm is optimal, meaning O(n), then the resulting sorting algorithm is optimal, meaning O(n log n). The median is the best pivot for sorting, as it evenly divides the data, and thus guarantees optimal sorting, assuming the selection algorithm is optimal. A sorting analog to median of medians exists, using the pivot strategy (approximate median) in Quicksort, and similarly yields an optimal Quicksort.

Incremental sorting by selection[edit]

Converse to selection by sorting, one can incrementally sort by repeated selection. Abstractly, selection only yields a single element, the kth element. However, practical selection algorithms frequently involve partial sorting, or can be modified to do so. Selecting by partial sorting naturally does so, sorting the elements up to k, and selecting by partitioning also sorts some elements: the pivots are sorted to the correct positions, with the kth element being the final pivot, and the elements between the pivots have values between the pivot values. The difference between partition-based selection and partition-based sorting, as in quickselect versus quicksort, is that in selection one recurses on only one side of each pivot, sorting only the pivots (an average of log(n) pivots are used), rather than recursing on both sides of the pivot.

This can be used to speed up subsequent selections on the same data; in the extreme, a fully sorted array allows O(1) selection. Further, compared with first doing a full sort, incrementally sorting by repeated selection amortizes the sorting cost over multiple selections.

For partially sorted data (up to k), so long as the partially sorted data and the index k up to which the data is sorted are recorded, subsequent selections of j less than or equal to kcan simply select the jth element, as it is already sorted, while selections of j greater than k only need to sort the elements above the kth position.

For partitioned data, if the list of pivots is stored (for example, in a sorted list of the indices), then subsequent selections only need to select in the interval between two pivots (the nearest pivots below and above). The biggest gain is from the top-level pivots, which eliminate costly large partitions: a single pivot near the middle of the data cuts the time for future selections in half. The pivot list will grow over subsequent selections, as the data becomes more sorted, and can even be passed to a partition-based sort as the basis of a full sort.

Using data structures to select in sublinear time[edit]

Given an unorganized list of data, linear time (Ω(n)) is required to find the minimum element, because we have to examine every element (otherwise, we might miss it). If we organize the list, for example by keeping it sorted at all times, then selecting the kth largest element is trivial, but then insertion requires linear time, as do other operations such as combining two lists.

The strategy to find an order statistic in sublinear time is to store the data in an organized fashion using suitable data structures that facilitate the selection. Two such data structures are tree-based structures and frequency tables.

When only the minimum (or maximum) is needed, a good approach is to use a heap, which is able to find the minimum (or maximum) element in constant time, while all other operations, including insertion, are O(log n) or better. More generally, a self-balancing binary search tree can easily be augmented to make it possible to both insert an element and find the kth largest element in O(log n) time; this is called an order statistic tree. We simply store in each node a count of how many descendants it has, and use this to determine which path to follow. The information can be updated efficiently since adding a node only affects the counts of its O(log n) ancestors, and tree rotations only affect the counts of the nodes involved in the rotation.

Another simple strategy is based on some of the same concepts as the hash table. When we know the range of values beforehand, we can divide that range into h subintervals and assign these to h buckets. When we insert an element, we add it to the bucket corresponding to the interval it falls in. To find the minimum or maximum element, we scan from the beginning or end for the first nonempty bucket and find the minimum or maximum element in that bucket. In general, to find the kth element, we maintain a count of the number of elements in each bucket, then scan the buckets from left to right adding up counts until we find the bucket containing the desired element, then use the expected linear-time algorithm to find the correct element in that bucket.

If we choose h of size roughly sqrt(n), and the input is close to uniformly distributed, this scheme can perform selections in expected O(sqrt(n)) time. Unfortunately, this strategy is also sensitive to clustering of elements in a narrow interval, which may result in buckets with large numbers of elements (clustering can be eliminated through a good hash function, but finding the element with the kth largest hash value isn't very useful). Additionally, like hash tables this structure requires table resizings to maintain efficiency as elements are added and n becomes much larger than h2. A useful case of this is finding an order statistic or extremum in a finite range of data. Using above table with bucket interval 1 and maintaining counts in each bucket is much superior to other methods. Such hash tables are like frequency tables used to classify the data in descriptive statistics.

Lower bounds[edit]

In The Art of Computer Programming, Donald E. Knuth discussed a number of lower bounds for the number of comparisons required to locate the t smallest entries of an unorganized list of n items (using only comparisons). There is a trivial lower bound of n − 1 for the minimum or maximum entry. To see this, consider a tournament where each game represents one comparison. Since every player except the winner of the tournament must lose a game before we know the winner, we have a lower bound of n − 1 comparisons.

The story becomes more complex for other indexes. We define {\displaystyle W_{t}(n)} as the minimum number of comparisons required to find the t smallest values. Knuth references a paper published by S. S. Kislitsyn, which shows an upper bound on this value:

{\displaystyle W_{t}(n)\leq n-t+\sum _{n+1-t<j\leq n}\lceil {\log _{2}\,j}\rceil \quad {\text{for}}\,n\geq t}

This bound is achievable for t=2 but better, more complex bounds are known for larger t.

STEPS

Selection Sort Algorithm

  1. Get a list of unsorted numbers
  2. Set a marker for the unsorted section at the front of the list
  3. Repeat steps 4 - 6 until one number remains in the unsorted section
  4.    Compare all unsorted numbers in order to select the smallest one
  5.    Swap this number with the first number in the unsorted section
  6.    Advance the marker to the right one position
  7. Stop

Related Solutions

What will the probability always be of events occurring that are mutually exclusive?  What are the...
What will the probability always be of events occurring that are mutually exclusive?  What are the different types of probability distribution and what are their characteristics?
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of...
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of shareholders wealth maximization? If a company attempts to maximize its shareholders wealth, is this good or bad for society? Explain by providing some examples.
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of...
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of shareholders wealth maximization? If a company attempts to maximize its shareholders wealth, is this good or bad for society? Explain by providing some examples. Please use the Keyboard , No pic
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of...
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of shareholders wealth maximization? If a company attempts to maximize its shareholders wealth, is this good or bad for society? Explain by providing some examples. Do you think maximizing shareholders’ wealth also applies in Saudi Arabia? For your discussion post, your first step is to summarize the article in two paragraphs, describing what you think are the most important points made by the authors (remember...
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of...
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of shareholders wealth maximization? If a company attempts to maximize its shareholders wealth, is this good or bad for society? Explain by providing some examples. Do you think maximizing shareholders’ wealth also applies in Saudi Arabia? Search the SEU library or the Internet for an academic or industry-related article. Select an article that relates to these concepts and explain how it relates to doing business...
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of...
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of shareholders wealth maximization? If a company attempts to maximize its shareholders wealth, is this good or bad for society? Explain by providing some examples. Do you think maximizing shareholders’ wealth also applies in Saudi Arabia? Note: For your discussion post, your first step is to summarize the article in two paragraphs, describing what you think are the most important points made by the authors...
Seether inc has the following two mutually exclusive projects available. What is the crossover rate for...
Seether inc has the following two mutually exclusive projects available. What is the crossover rate for these two projects? What is the NPV of each project at the crossover rate? Year Project R Project S 0 -45000 -76000 1 17000 20000 2 19000 20000 3 21000 35000 4 9000 30000 5 7000 10000
What does it mean when they say with operating leverage you use fixed costs to maximize return?
What does it mean when they say with operating leverage you use fixed costs to maximize return? How can you used fixed costs for that?
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of shareholders wealth maximization?
The purpose of the financial management is to maximize shareholders wealth. What is the meaning of shareholders wealth maximization? If a company attempts to maximize its shareholders wealth, is this good or bad for society? Explain by providing some examples. Do you think maximizing shareholders’ wealth also applies in Saudi Arabia?Search the SEU library or the Internet for an academic or industry-related article. Select an article that relates to these concepts and explain how it relates to doing business in...
What actions should a financial manager make in order to maximize the value of the company's stock?
What actions should a financial manager make in order to maximize the value of the company's stock? does it mean that maximizing profit results to maximizing the company's stock value?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT