Question: Many states require that candidate names appear on a ballot in random order, so as to minimize biases that can arise from the order in

Many states require that candidate names appear on a ballot in random order, so as to minimize biases that can arise from the order in which candidate names appear on a ballot for a given election. For instance, in the 2012 general election, the Secretary of State of California performed a random drawing that determined that candidate names for that election must appear in alphabetical order based on the following ordering of letters: 

(I,X,C,A,P,U,Z,S,W,H,K,T,D,F,Q,V,G,M,R,J,L,Y,E,B,P,N). 

For example, if three candidates in that election had the last names, “BROWN,” “BLACK,” and “WHITE,” then they would appear on the ballot in the order, (WHITE, BROWN, BLACK). Describe an efficient algorithm that takes, as input, an array, A, specifying an ordering of letters such as this, and a collection of names, and sorts the collection of names using a lexicographic order based on the alternative ordering of letters given in A. What is the running time of your method in terms of m, the size of the array, A, and n, the number of names to be sorted? (You may assume the length of each name is bounded by some constant, but you may not assume that m or n is a constant.)

Step by Step Solution

3.46 Rating (179 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Create an auxiliary array B of size m that is indexed by the standard ordering of the letters in the ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Data Structures Algorithms Questions!