Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 2 0 points ) Let A be an array of strings of various lengths, and the total number of characters over all the strings

(20 points) Let A be an array of strings of various lengths, and the total
number of characters over all the strings is n. More technically, A stores
an array of pointers to string objects, whereas a string object (e.g., string
in STL) stores the length l of the string and an array of l characters. We
assume that each character can be viewed as an integer ranging from 0
to 255. The goal of this problem is to sort the strings alphabetically. For
example, ??0O(n)(n2)ABa.
(a)(5 points) Consider the following algorithm: First pad '??0'(the char-
acter with ASCII code 0)to the right of each string so that all strings
have equal length, and then run radix sort on all strings. What's the
worst-case running time of this algorithm? Give an input on which
this running time is attained.
(b)(15 points) Design and analyze an algorithm that sorts the strings
inO(n) time.
Hint: Combine divide-and-conquer with counting sort. The running
time of this divide-and-conquer algorithm can't be analyzed byare-
currence. You can try to count the total number of operations over
all recursive calls; for example, the first recursive integer multiplica-
tion algorithm has running time (n2) because it multiplies every
bit of A with every bit ofB.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago