(h) (10 Pts) [Task-8] Define a function called hist B which takes the Output dictionary (given...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(h) (10 Pts) [Task-8] Define a function called hist B which takes the Output dictionary (given by hist A [Task-7]) as an input. And create a new dictionary which maps from frequencies to letters. Sample input/Output: res = hist A("kara murat kim")) print (hist B(res)) {1: ['u', 't', 'i'], 2: ['', ''r', 'k', 'm'], 3: ['a']} (i) (10 Pts) [Task-9] Define a function called get Topelements that takes a string as an input and returns the most common 3 letters in that string. If the characters have same frequency, it should return in alfabetical order. Sample input/Output: print(get Topelements ("programming")) Most common three letters are: m, a, g (j) (10 Pts) [Task-10] Define a function called compress_dict, it compresses the strings that have long sequences of equal characters. The program will accept one string as an argument, and return compressed form of the string. Sample input/Output: print(compress_dict("aaaabbaaabbbbbbcccd")) 4a2b3a5b3c1d (h) (10 Pts) [Task-8] Define a function called hist B which takes the Output dictionary (given by hist A [Task-7]) as an input. And create a new dictionary which maps from frequencies to letters. Sample input/Output: res = hist A("kara murat kim")) print (hist B(res)) {1: ['u', 't', 'i'], 2: ['', ''r', 'k', 'm'], 3: ['a']} (i) (10 Pts) [Task-9] Define a function called get Topelements that takes a string as an input and returns the most common 3 letters in that string. If the characters have same frequency, it should return in alfabetical order. Sample input/Output: print(get Topelements ("programming")) Most common three letters are: m, a, g (j) (10 Pts) [Task-10] Define a function called compress_dict, it compresses the strings that have long sequences of equal characters. The program will accept one string as an argument, and return compressed form of the string. Sample input/Output: print(compress_dict("aaaabbaaabbbbbbcccd")) 4a2b3a5b3c1d
Expert Answer:
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
(a) Let f(x)=2x+1. Use definition of the derivative to compute f'(x). (No other method will be accepted, regardless of whether you obtain the correct derivative.) (b) Find the tangent line to the...
-
Congress enacted the FLSA in 1938. More than eight thousand FLSA suits are filed in federal district courts each year. How do these facts support the court's reasoning in this case?
-
Tar Heel Corporation provides the following information at the end of 2024. Required: Prepare the income statement, statement of stockholders equity, and balance sheet for Tar Heel Corporation on...
-
A survey of cross-border money transfers found that in 38% cases, the beneficiary account has suffered double charging, in contradiction to European Union rules. You randomly select 200 crossborder...
-
Perioto Inc. currently charges manufacturing overhead costs to products using machine hours. However, company management believes that the use of ABC would provide more realistic cost estimates and,...
-
The Final Report of the Joint Union/Management Task Force on Diversity and Inclusion makes 28 recommendations. Which one(s) do you find most important? Which organization(s) do you consider essential...
-
AmeriPlas, Inc., produces 20-ounce plastic drinking cups that are embossed with the names of prominent beers and soft drinks. a. Prepare a time-series plot of the sales data. Does there appear to be...
-
Use the original schedule of cash receipts completed in Exercise E22-29, Requirement 1, and the schedule of cash payments completed in Exercise E22-28 to complete a cash budget for Armand Company....
-
Based on Exhibit 1, the target semideviation for the portfolio is closest to: A. 2.78%. B. 3.68%. C. 4.35%. Alexandra Jones, a senior adviser at Federalist Investors (FI), meets with Erin Bragg, a...
-
Identify the likely appropriate price benchmark for the LIM trade. Justify your response. Bradley also performs a cost analysis on the LIM trade. Noting the time gap between his trade instructions...
-
The most appropriate response to Knights question regarding the potential future scenario for the Heydon Quant Fund is: A. only the returns-based approach. B. only the holdings-based approach. C....
-
The Elmer funds management strategy is: A. active. B. passive. C. blended. Three years ago, the Albright Investment Management Company (Albright) added four new fundsthe Barboa Fund, the Caribou...
-
Describe the content of the advisers checklist related to manager selection. Donna Grimmett is working with a financial adviser to establish her investment goals for $850,000, which she recently...
-
Determine the molecular formula and possible structures for each unknown based on the given spectra.
-
Software Solution is family-owned business that has been in operation for more than 15 year. The board of directors is comprised of mainly family members, plus a few professionals such as an...
-
Rewrite EUCLID in an iterative form that uses only a constant amount of memory (that is, stores only a constant number of integer values).
-
Suppose that both f and f are flows in a network G and we compute flow f f. Does the augmented flow satisfy the flow conservation property? Does it satisfy the capacity constraint?
-
As a function of the minimum degree t , what is the maximum number of keys that can be stored in a B-tree of height h?
-
Which of the following is not a characteristic of a defined benefit plan? A. A guaranteed retirement benefit. B. Risk of preretirement inflation assumed by employer. C. Benefits based upon the...
-
Which is an advantage to an employee who participates in a profit-sharing plan? A. Employee does not have to make investment decisions. B. Graded vesting schedule. C. Older employees receive the...
-
Which of the following is true about cash balance plans? I. Past service credit is available. II. Employer guarantees a minimum rate of return. III. Participants direct investments in hypothetical...
Study smarter with the SolutionInn App