## What is hiring problem?

The term "hire" means "to employ" or "to obtain services for a fee." When you hire someone, you are employing or paying them to perform a certain task for you. A step-by-step method for hiring a new employee is an efficient and successful hiring process in which a business determines its talent needs, recruits from its talent pool, and hires the best-qualified individuals. The hiring problem is a well-known decision-making problem in the analysis of algorithms. The problem is solved by designing an efficient algorithm to choose the best candidate from a list of n candidates.

## Problem Description

Assume you require the services of a new office assistant. You decide to engage an employment agency because your prior attempts at hiring were unsatisfactory. Each day, the job agency will give you one candidate. You will have an interview with that individual before deciding whether or not to hire them. To interview an applicant, you must pay a nominal charge to the employment agency. However, it is more expensive to hire an applicant because you must terminate your current office helper and pay a substantial hiring charge to the employment agency. You are dedicated to hiring the best individual for the job at all times. As a result, you determine that if a candidate is better qualified than the present office assistant after interviewing them, you will sack the present office assistant and hire the new applicant. You are willing to pay the strategy's final cost, but you want to know what that cost will be.

This hiring technique is expressed in pseudocode by the operation HIRE-ASSISTANT, which is shown below. It is assumed that the candidates for the position of office assistant are numbered from 1 to n. The approach implies you can evaluate whether candidate i is the greatest candidate you've seen so far after interviewing him or her. To begin, the method creates a dummy applicant with the number 0 who is less competent than the others.

HIRE-ASSISTANT(n)

1  best ← 0     ®candidate 0 is a least-qualified dummy candidate

2  for i ← 1 to n

3       do interview candidate i

4          if candidate i is better than candidate best

5             then best ← i

6                  hire candidate i

## Cost of Hiring and Total Cost

• The expense of interviewing is inexpensive ${c}_{i}$.
• Hiring comes at a high price ${c}_{h}$.
• Let n represent the number of candidates who will be interviewed, and m represent the number of persons who will be hired.
• After that, the overall cost is $O\left(n*{c}_{i}+m*{c}_{h}\right)$.
• Because the number of candidates is fixed, we'll concentrate on the $m*{c}_{h}$ term of the algorithm. The cost of recruiting is governed by this term $\left(m*{c}_{h}\right)$.

## Worst-case Analysis

• In the worst-case scenario, everyone we interview proves to be superior to the individual we already have.
• In this scenario, the algorithm's recruiting cost will be $O\left(n*{c}_{h}\right)$.
• Since this horrible condition is unlikely to occur on a regular basis, it's worth pondering what happens in the average instance.

## Probablistic analysis of the Hiring Problem

Probabilistic analysis of algorithms is a method for estimating the computational complexity of an algorithm. It is predicated on the assumption of the probabilistic distribution of all possible inputs. This assumption is then utilized to create a more efficient algorithm or to calculate the complexity of an existing one.

Although this method is not the same as probabilistic algorithms. We can suppose that the applicants arrive in a random sequence for the hiring problem. We presume that we can compare any two candidates and determine which one is more qualified; that is, we assume that the candidates are ranked in order. As a result, we may assign each candidate a unique number between 1 and n, using rank(i) to signify the rank of applicant i and follow the agreement that a higher rank refers to a more competent individual. A permutation of the list <1, 2,..., n> is the ordered list <rank(1), rank(2),..., rank(n)>. To argue that the candidates arrive in a random sequence is the same as saying that this list of ranks might be any of the n! permutations of the numbers 1 through n. Alternatively, we can argue that the rankings constitute a uniform random permutation, which means that each of the n! permutations has an equal chance of appearing.

• Assume ${X}_{i}$ is a random variable that is 1 if applicant $i$ is hired and 0 otherwise.
• Allow
• By our lemma {candidate$i$ is hired}
• Candidate $i$ will be hired if he or she is better than candidates 1 through $i-1$.
• Because each contender is assigned to a number at random, any of the first candidate $i$ is equally likely to be the best candidate thus far. As a result, $E\left[{X}_{i}\right]=1}{i}$.

## More research into the hiring issue

$E\left[X\right]=E\left[\sum _{i=1}^{n}{X}_{i}\right]=\sum _{i=1}^{n}E\left[{X}_{i}\right]=\sum _{i=1}^{n}1}{n}=\mathrm{ln}\left(n\right)+O\left(1\right)$

Lemma assume that If the candidates are presented in random order, the Hire-Assistant method has a recruiting cost of $O\left({c}_{h}\mathrm{ln}\left(n\right)\right)$.

Proof- Previously, the cost of hiring was $O\left(m*{c}_{h}\right)$, where m was the number of candidates hired. This is based on the lemma $O\left(\mathrm{ln}\left(n\right)\right)$.

## Randomized algorithms

Although it appears like the candidates are being presented to us in a random sequence in the hiring problem, we have no means of knowing whether or not this is the case. As a result, we need more control over the order in which we interview individuals in order to build a randomized algorithm for the hiring problem. As a result, we'll make a little adjustment to the model. We'll pretend the job agency has n candidates and has sent us a list of them ahead of time. Every day, we pick an applicant to interview at random. We have made a substantial difference while knowing little about the candidates. We took control of the process and enforced a random order, rather than depending on a guess that the candidates would come to us in that order.

If the behavior of an algorithm is determined not just by its input but also by values generated by a random number generator, it is referred to as a randomized algorithm. We'll assume we have a random number generator called RANDOM at our disposal. RANDOM(a, b) returns an integer between a and b, inclusive, with each integer having the same probability. RANDOM(0, 1), for example, returns 0 with probability 1/2 and 1 with probability 1/2. A call to RANDOM(3, 7) returns one of three numbers: 3, 4, 5, 6, or 7, with a probability of one in five. RANDOM returns integers that are unrelated to the integers returned by earlier calls. To get its output, think of RANDOM as rolling a (b - a + 1)-sided die. (Most programming environments have a pseudorandom-number generator, which is a deterministic process that returns numbers that "appear" statistically random).

## Concepts and Applications

This topic is significant in the professional exams for both graduate and postgraduate courses, especially for:

• Bachelor of Technology in Computer science
• Master of Technology in Computer Science
• Master of business Administration
• Secretary problem
• Recruiter
• Probabilistic analysis and randomized algorithm

## Practice Problems

Q1- What is the worst-case analysis of the hiring algorithm?

1. $O\left(n*{c}_{h}\right)$
2. $O\left({n}^{2}*{c}_{h}\right)$
3. $O\left({n}^{3}*{c}_{h}\right)$
4. None

Correct answer- 1. $O\left(n*{c}_{h}\right)$

Explanation-  In the worst-case scenario, we hire every candidate in the interview. If the candidates are ranked in increasing order of quality, we will recruit n times for a total hiring cost of $O\left(n*{c}_{h}\right)$.

Q2. The hiring problem is based on which of the following techniques?

1. Divide and conquer
2. Decision-based
3. Dynamic programming
4. None of the above

Correct answer- 2. Decision-based

Explanation- Making the perfect hiring decision entails not only finding the best person for the job but also that this person believes they've discovered the best role for them. You must communicate your expectations for the candidate during the entire hiring process.

Q3. The hiring problem assumes that

1. The candidates arrive in a random order.
2. The candidates arrive in a specific order.
3. The candidates arrive in a descending order of qualification.
4. The candidates arrive in a ascending order of qualification.

Correct answer- 1. The candidates arrive in a random order

Explanation- The hiring problem assumes that candidates arrives in random order because it gives the best result.

Q4. What is the expected value of the random variable Xi for a candidate i in a random distribution of n candidates?

1. 1/2i
2. 2i
3. 1/i
4. None of the above

Correct answer- 3. 1/i

Explanation- 1/i is the expected value of the random variable Xi for a candidate i in a random distribution of n candidates.

Q5. The primary aim of the hiring process is:

1. Meet the higher labor turnout
2. Hire the best candidate at optimum cost
3. Both
4. None

Correct answer- 2. Hire the best candidate at optimum cost

Explanation- The major goal of the recruitment and selection process is to hire the best people for the optimum cost. It can help HR personnel choose the best candidate for the job based on merit and job relevance.

### Want more help with your computer science homework?

We've got you covered with step-by-step solutions to millions of textbook problems, subject matter experts on standby 24/7 when you're stumped, and more.
Check out a sample computer science Q&A solution here!

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.

### Search. Solve. Succeed!

Study smarter access to millions of step-by step textbook solutions, our Q&A library, and AI powered Math Solver. Plus, you get 30 questions to ask an expert each month.

Tagged in
EngineeringComputer Science

### Hiring Problem

• Copyright, Community Guidelines, DSA & other Legal Resources: Learneo Legal Center
• bartleby, a Learneo, Inc. business