Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

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 Vaia!

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

The following statements may or may not be correct, In each case, either prove it (if it is correct) or give a counter-example (if it isn’t correct). Always assume that the graph G=(V,E)is undirected. Do not assume that edge weights are distinct unless this is specifically stated.

  1. If a graph G has more than |V|-1edges, and there is a unique heaviest edge, then this edge cannot be part of a minimum spanning tree.
  2. If G has a cycle with a unique heaviest edge e, then e cannot be part of any MST.
  3. Let e be any edge of minimum weight in G. Then e must be part of some MST.
  4. If the lightest edge in a graph is unique, then it must be part of every MST.
  5. If e is part of some MST of G, then it must be a lightest edge across some cut of .
  6. If G has a cycle with a unique lightest edge e must be part of every MST.
  7. The shortest-path tree computed by Dijkstra’s algorithm is necessarily an MST.
  8. The shortest path between two nodes is necessarily part of some MST.
  9. Prim’s algorithm works correctly when there are negative edges.
  10. (For any r>0, define an r-path to be a path whose edges all have weight <r). If G contains an r-path from node s to t , then every MST of G must also contain an r-path from node s to node t.

A long string consists of the four characters A,C,G,T ; they appear with frequency 31%,20%,9%and40% respectively. What is the Huffman encoding of these four characters?

Question: Suppose the symbols a,b,c,d,e occur with frequencies 12,14,18,116,116,respectively.

(a) What is the Huffman encoding of the alphabet?

(b) If this encoding is applied to a file consisting of1,000,1000 characters with the given frequencies, what is the length of the encoded file in bits?

Show that if an undirected graph with n vertices has k connected components, then it has at least n - k edges.

Give You are given a graphG=(V,E)with positive edge weights, and a minimum spanning tree T=(V,E)with respect to these weights; you may assume GandTare given as adjacency lists. Now suppose the weight of a particular edge eE'is modified fromw(e)to a new value w'(e). You wish to quickly update the minimum spanning tree T to reflect this change, without recomputing the entire tree from scratch. There are four cases. In each case give a linear-time algorithm for updating the tree.

(a) eE'and w'(e)>w(e) .

(b) role="math" localid="1658907878059" eE'and w'(e)>w(e) .

(c) role="math" localid="1658907882667" eE'and w'(e)>w(e) .

(d) role="math" localid="1658907887400" eE'and w'(e)>w(e) .

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.

Sign-up for free