Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

This assignment is to alphabetically sort n strings, cach with maximum-length of k — 21 characters. (You may assume n

1 answer below »
This assignment is to alphabetically sort n strings, cach with maximum-length of k — 21 characters. (You
may assume n < 1000) The algorithm to be used is LSD (Least-Significant-Digit-First) radixsort. The
algorithm must rn in O(n) time, where one character operation takes one unit of time. You mst handle
the strings on a character-by-character basis, one character at a time. (Each character operation takes
0(1) time)
The strings consist of only upper-case letters A-Z, with no space. The strings need not be distinct. (Fo
‘example, there may be several PATEL in a class list!)
Each string has at most k characters. Shorter strings must be padded with blank characters (as they are
ead from a file) to reach the fixed length of k.
First, read the strings from a text file “Lixt”. Assume that cach string starts at the beginning of a new
line and ends with one or more white-space-characters. (An end of line character is a white-space.) Store
the strings in a two-dimesional a
ay S with n rows and k columns. That is, string 1 is stored in Si, 1A]
For efficiency, once the strings have been read into a
ay . they must stay in that order and not he moved
during the sorting. Instead, we ws a pointer a
ay (a
ay of string indices) P01. Initially, st Pf] — i
for all i. During the sorting, we move these indices. At the cud of sorting, P(0] will be the index of the
string which is the first in the sorted order, PI] the second string in the sorte order, and 50 on.
At the end, output the strings in sorted order to text file “txt”. Use the same format as the input fle,
with cach string as on line. (Each string must begin at the beginning of a line and end with an end-of line
character.)
Notes on naming files: For case of srading, your program mst receive the names of input-fle and
output-file from the command line. And these file names must have default names “fx” and “gtx”,
espectively. Then the ser will be able to cither specify a file name, or decide to £0 with the default name.
That is, your program will ist recive the name of input file.

Please specify the input file (default = Loxt ):
After receiving the name of input file, your program will then reccive the name of output fil.
Please specify the output fle (default = txt):
Answered 3 days After Mar 16, 2023

Solution

Rakesh answered on Mar 20 2023
26 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here