- A A 248 Local backup on יויד והן ≡≡ index 0 1 2 3 The following algorithm performs an operation on a list of names. 4 5 6 7 8 9 10 11 12 13 41 14 15 |||| names Ahmed Amin Arnold Bob Beatrice Brad Charlie Chloe Chelsey Elizabeth Gavin Jordan Quan Ursula Weasley Zara first Line Spacing: 1 0 last def algorithm (): global names searchName-input ("Enter name to search") first-0 last-len (names)-1 while first<-last: 15 Character Spacing: 0 First Line Indent: 0 mid=(first+last) //2 if names [mid]-searchName: return True elif names [mid]>searchName: last-mid-1 else: main () if first>last: def main (): first-mid+1 return False Table1 a)Copy and complete the trace table to trace the flow of execution of algorithm in Figure 2. The table contains the state of the variables immediately before the while loop is entered. names are specified in Table 1 and the searchName entered is 'Weasley'. (Assume that the result of integer division is rounded down (e.g. the result of 5//2 is 2) found-algorithm () print (found) mid names[mid] Exit result I

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
Inse
Α' Α' Δ
A
& E
Local backup on
7
index
0
The following algorithm performs an operation on a list of names.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
==
15
names
m
Ahmed
Amin
Arnold
Bob
Beatrice
Brad
Charlie
Chloe
Chelsey
Elizabeth
Gavin
Jordan
Quan
Ursula
Weasley
Zara
first
Line Spacing: 1
0
1
last
def algorithm ():
global names
searchName-input ("Enter name to search")
15
first=0
last-len (names) -1
while first<-last:
mid=(first+last) //2
if names [mid]=searchName:
return True
elif names [mid]>searchName:
last-mid-1
else:
Character Spacing: 0
First Line Indent: 0
main ()
if first>last:
def main ():
Table1
a)Copy and complete the trace table to trace the flow of execution of algorithm in Figure2.
The table contains the state of the variables immediately before the while loop is entered.
names are specified in Table 1 and the searchName entered is 'Weasley'.
(Assume that the result of integer division is rounded down (e.g. the result of 5//2 is 2)
return False
first-mid+1
found-algorithm ()
print (found)
mid
♫
A
<><>
names[mid]
result
X
Exit
][
[
Transcribed Image Text:Inse Α' Α' Δ A & E Local backup on 7 index 0 The following algorithm performs an operation on a list of names. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 == 15 names m Ahmed Amin Arnold Bob Beatrice Brad Charlie Chloe Chelsey Elizabeth Gavin Jordan Quan Ursula Weasley Zara first Line Spacing: 1 0 1 last def algorithm (): global names searchName-input ("Enter name to search") 15 first=0 last-len (names) -1 while first<-last: mid=(first+last) //2 if names [mid]=searchName: return True elif names [mid]>searchName: last-mid-1 else: Character Spacing: 0 First Line Indent: 0 main () if first>last: def main (): Table1 a)Copy and complete the trace table to trace the flow of execution of algorithm in Figure2. The table contains the state of the variables immediately before the while loop is entered. names are specified in Table 1 and the searchName entered is 'Weasley'. (Assume that the result of integer division is rounded down (e.g. the result of 5//2 is 2) return False first-mid+1 found-algorithm () print (found) mid ♫ A <><> names[mid] result X Exit ][ [
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Hash Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education