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

1 answer below »
in python please


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. (for ‘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 read 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 array 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 array . they must stay in that order and not he moved during the sorting. instead, we ws a pointer array (array 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”, respectively. 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): 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.="" (for="" ‘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="" read="" 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="" array="" 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="" array="" .="" they="" must="" stay="" in="" that="" order="" and="" not="" he="" moved="" during="" the="" sorting.="" instead,="" we="" ws="" a="" pointer="" array="" (array="" 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”,="" respectively.="" 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="">
Answered 3 days AfterMar 16, 2023

Answer To: This assignment is to alphabetically sort n strings, cach with maximum-length of k — 21 characters....

Rakesh answered on Mar 20 2023
27 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