diff_months: 12

Data Structure :Array Sorting Assessment

Download Solution Now
Added on: 2023-05-12 05:45:34
Order Code: fb
Question Task Id: 0
  • Country :

    Australia

PROBLEM: Consider a sorted array containing the letters COMPUTER

C/E/M/O/P/R/T/…

When a letter is added, you insert the letter in the correct place in the array, moving the other letters. If the letter is already in the array, insert it BEFORE the existing occurrence.

Continuing with the example above, let's add the letters BAT. The shaded cell is where the new letter is positioned:

Add B: B/C/E/M/O/P/R/T…

Add A: A/B/C/E/M/O/P/R/T…

Add T:A/B/C/E/M/O/P/R/T/T..

INPUT:

You'll process 5 lines of data. Each line will start with a positive number, N, followed by a space, and then a string, xxx. Into an empty array, insert each letter in the string, one at a time. Ignore non- letters and also, convert all lowercase letters into uppercase.

OUTPUT:

For each input line, print how many different letters occupied the Nth element of the array while the string was processed. For example, "2 Computer" has answer of 3: The different letters in position 2 of the array were O. M. and finally E. The input line "2 COMPUTER Bar" has an answer of 5: the different letters at position 5 were O, M. E. C, and B.

SAMPLE INPUT SAMPLE OUTPUT
2 Computer 1.3
COMPUTER bat 2.5
3COMPUTER 3.2
4ACSL is fun 4.3
9 the xylophone 5.4

  • Uploaded By : Katthy Wills
  • Posted on : May 12th, 2023
  • Downloads : 0
  • Views : 150

Download Solution Now

Can't find what you're looking for?

Whatsapp Tap to ChatGet instant assistance

Choose a Plan

Premium

80 USD
  • All in Gold, plus:
  • 30-minute live one-to-one session with an expert
    • Understanding Marking Rubric
    • Understanding task requirements
    • Structuring & Formatting
    • Referencing & Citing
Most
Popular

Gold

30 50 USD
  • Get the Full Used Solution
    (Solution is already submitted and 100% plagiarised.
    Can only be used for reference purposes)
Save 33%

Silver

20 USD
  • Journals
  • Peer-Reviewed Articles
  • Books
  • Various other Data Sources – ProQuest, Informit, Scopus, Academic Search Complete, EBSCO, Exerpta Medica Database, and more