Provide pseudocode for an algorithm that will alphabetically sort a list that wi
ID: 3691659 • Letter: P
Question
Provide pseudocode for an algorithm that will alphabetically sort a list that will contain somewhere between 32,000 and 64,000 records where the person's first name is treated as the sort key, and the length of any single first name is between 3 and 9 (inclusive). Your algorithm needs to sort these in linear time, and use at most linear temporary space. Your solution needs to make use of at least one "clever thing" that you identify for us. It doesn't have to be very clever, though I would like you to try to think of different approaches as you work on this question.
Explanation / Answer
Solution:
pseudocode:
type
{Employeerecord as above}
var
workrecord: employeerecord;
begin
{ get workrecord into memory here. }
writeln(workrecord.number);
writeln(workrecord.surname);
writeln('I''m getting sick of typing workrecord all the time!');
with workrecord do
writeln(firstname);
writeln(position);
writeln(yrsworked);
end;
end.
begin
ignass(firstname,'FIRSTNAME.TXT)
reset(firstname);
assign(filelist, 'FILES.TXT');
reset(filelist);
assign(counts, 'FRNDDATA.TXT');
rewrite(counts);
readln(fristname,filelist, filename);
filenums := 0;
while (not eof(filelist<32000)) and (filenums < 64000) do
begin
countfile(firstname,filename, ltrstorage, filenums);
writefdata(filename, ltrstorage);
readln(filelist, filename);
end;
countfile(filename, ltrstorage, filenums);
writefdata(filename, ltrstorage);
doend(filenums, ltrstorage);
if not eof(filelist) then
writeln(counts, 'You gave me more than 100 records to process!');
close(filelist);
close(counts);
end.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.