/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q31E Ternary A server has   customer... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

Ternary A server has customers waiting to be served. The service time required by eachcustomer is known in advance: it is ciminutes for customer i. So if, for example, the customers are served in order of increasing i , then the ithcustomer has to wait Pij=1tjminutes. We wish to minimize the total waiting time.

T=Xni=1(time spent waiting by customer ).

Give an efficient algorithm for computing the optimal order in which to process the customers.

Short Answer

Expert verified

Therefore, provide customized Huffman method for compressing sequences of letters from such a vocabulary with elements, where even the words appear with known frequency f1,f2,...,fn,to take use of this new technology.

Step by step solution

01

Introduction

Algorithms providing optimum customer processing ordering:

Its greedy algorithm is utilised to assist the client who serves first in the shortest period of time.

• That is, a large number of consumers are sorted according to their time "t" values, and then served in that order.

It has been discovered that it is no issue what, the total time that deals inside the consumers serve does not alter.

• The total time taken is always equal to the sum of the service times for all of the clients.

02

Total time

The total time can be calculated as:

T=∑i=1n(numberofcustomersstillwaitingattimet)

• Reduce consequently, this number of customers who should wait is increasing, implying that the optimal course of action is for consumers to be served with greater service time.

Algorithm:

Explanation: Presume that there is indeed a better option than the greedy one.

• When sort data number of customers by time, the Greedy approach is employed. Customers are served once they have been sorted.

• A minimum of one pair of consecutive consumers is required for the best solution. Serving the second consumer takes less time than serving the first.

Take, for example, the requirement that "out of order" must be met by a pair of customers.

• Pair of customers denotes as ciand ci+1.

• Service time for the pair of customers denotes as tiand ti+1.

• By assumption, the service time of first customer is greater than the service time of second customer. That is,ti>ti+1.

o Swap the order of the pair of customers will produce the better ordering. So, the second customer ci+1is served before the first customer ci.

• It does not change any waiting time of other customers.

o The waiting time for the customer ciwill increase by ti+1and customer ci+1will increase by ti. So, the assumption of ti>ti+1will reduces the overall waiting time.

• As a result, changing the order of the consumers results in the shortest overall waiting time.

Sorting the number of clients "n" will take a total of n minutes O(nlogn).

Each and every swap will reduce the total waiting time. So, after all the swaps are performed, the customers will be sorted in ascending order. The optimal solution becomes the greedy solution.

Therefore, the greedy solution must be the optimal solution.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Show that for any integer n that is a power of 2 , there is an instance of the set cover problem (Section 5.4) with the following properties:

  1. There are n elements in the base set.
  2. The optimal cover uses just two sets.
  3. The greedy algorithm picks at least log n sets.

Thus the approximation ratio we derived in the chapter is tight.

The following table gives the frequencies of the letters of the English language (including the blank for separating words) in a particular corpus.

blank

18.3%

r

4.8%

y

1.6%

e

10.2%

d

3.5%

p

1.6%

t

7.7%

l

3.4%

b

1.3%

a

6.8%

c

2.6%

v

0.9%

o

5.9%

u

2.4%

k

0.6%

i

5.8%

m

2.1%

j

0.2%

n

5.5%

w

1.9%

x

0.2%

s

5.1%

f

1.8%

q

0.1%

h

4.9%

g

1.7%

z

0.1%

  1. What is the optimum Huffman encoding of this alphabet?
  2. What is the expected number of bits per letter?
  3. Suppose now that we calculate the entropy of these frequencies

H=∑t=026ptlog1pt

(see the box in page 143). Would you expect it to be larger or smaller than your answer above? Explain.

d. Do you think that this is the limit of how much English text can be compressed? What features of the English language, besides letters and their frequencies, should a better compression scheme take into account?

Graphs with prescribed degree sequences. Given a list of n positive integers d1,d2,…,dn, we want to efficiently determine whether there exists an undirected graphG=(V,E) whose nodes have degrees preciselyd1,d2,…,dn . That is, if V={v1,…,vn}, then the degree of vi should be exactly di. We call (d1,…,dn) the degree sequence of G. This graph G should not contain self-loops (edges with both endpoints equal to the same node) or multiple edges between the same pair of nodes.

(a) Give an example of d1,d2,d3,d4 where all the di≤3 and d1+d2+d3+d4 is even, but for which no graph with degree sequence(d1,d2,d3,d4) exists.

(b) Suppose that d1≥d2≥d3≥dn and that there exists a graph G=(V,E) with degree sequence (d1,…,dn). We want to show that there must exist a graph that has this degree sequence and where in addition the neighbors of v1 are v2,v3,…,vdi+1 . The idea is to gradually transform G into a graph with the desired additional property.

i. Suppose the neighbors ofv1 in Gare not v2,v3,…,vdi+1. Show that there exists i<j≤n and u∈V and such that {v1,vi},{u,vj}∉Eand {v1,vj},{u,vi}∈E

ii. Specify the changes you would make to G to obtain a new graph G'=(V,E') with the same degree sequence as G and where (v1,vi)∈E'.

iii. Now show that there must be a graph with the given degree sequence but in which v1 has neighbors v2,v3,…,vdi+1.

c) Using the result from part (b), describe an algorithm that on input d1,…,dn (not necessarily sorted) decides whether there exists a graph with this degree sequence. Your algorithm should run in time polynomial in n and in m=∑i=1ndi .

Suppose you are given a weighted graph G=(V,E) with a distinguished vertex s and where all edge weights are positive and distinct. Is it possible for a tree of shortest paths from s and a minimum spanning tree in G to not share any edges? If so, give an example. If not, give a reason.

We use Huffman's algorithm to obtain an encoding of alphabet {a,b,c}with frequencies fa,fb,fc. In each of the following cases, either give an example of frequencies (fa,fb,fc)that would yield the specified code, or explain why the code cannot possibly be obtained (no matter what the frequencies are).

(a) Code:{0,10,11}

(b) Code:{0,1,00}

(c) Code:{10,01,00}

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.