Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Thirty ( 3 0 ) students registered for a field trip. When the bus arrives, the students randomly line up to board the bus, but

Thirty (30) students registered for a field trip. When the bus arrives, the students randomly line up to board the bus, but their teacher needs to take attendance using a list containing the students names. The student names are in alphabetical order by last name. Two different algorithms are given for finding each student's name as they board the bus.
\table[[Algorithm 1,Algorithm 2],[Repeat until the name is found or until,Let the current name be the first name],[you run out of names in the list:,on the list.],[Repeat until you find the name in the list,],[Look at the middle name in the list,or reach the end of the list.],[If the name in the list is too high,,If the current name matches the],[student's name,],[Cut off the top half of the list.,Mark the student present and stop.],[If the name in the list is too low,,],[Cut off the bottom half of the list.,\table[[Otherwise, make the current name the],[next name in the list.]]],[If the name in the list matches the,],[student's name,,],[Mark the student present.,]]
Algorithm A always finds the student's name, but Algorithm B does not.
Algorithm B always finds the student's name, but Algorithm A does not.
Both Algorithm A and B always finds the students name
Neither Algorithm A nor Algorithm B finds the students name.
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_2

Step: 3

blur-text-image_3

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions