The code of a sequential search function is shown on textbook page 60. In fact, if the list is already sorted, the search can halt when the target is less than a given element in the list. For example, given my_list = [2, 5, 7, 9, 14, 27], if the search target is 6, the search can halt when it reaches 7 because it is impossible for 6 to exist after 7.  Define a function linearSearchSorted, which is used to search a sorted list. This function displays the position of the target item if found, or ‘Target not found’ otherwise. It also displays the elements it has visited. To test your function, search for these targets in the list [2, 5, 7, 9, 14, 27]: 2, 6, 14, 27 and 28.

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%

The code of a sequential search function is shown on textbook page 60. In fact, if the list is already sorted, the search can halt when the target is less than a given element in the list. For example, given my_list = [2, 5, 7, 9, 14, 27], if the search target is 6, the search can halt when it reaches 7 because it is impossible for 6 to exist after 7.  Define a function linearSearchSorted, which is used to search a sorted list. This function displays the position of the target item if found, or ‘Target not found’ otherwise. It also displays the elements it has visited. To test your function, search for these targets in the list [2, 5, 7, 9, 14, 27]: 2, 6, 14, 27 and 28.

CSC130-Lab03(1) - Protected View - Saved to this PC -
o Search
michael terani
Layout
References
Mailings
Review
View
Help
A Share
P Comments
om the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View.
Enable Editing
E Reading list
PROGRAM 1
Ask an Expert
The code of a sequential search function is shown on textbook page 60. In fact, if the list is
already sorted, the search can halt when the target is less than a given element in the list.
For example, given my_list = [2, 5, 7, 9, 14, 27], if the search target is 6, the search can
halt when it reaches 7 because it is impossible for 6 to exist after 7. Define a function
linearsearchsorted, which is used to search a sorted list. This function displays the
position of the target item if found, or 'Target not found' otherwise. It also displays the
elements it has visited. To test your function, search for these targets in the list [2, 5, 7, 9,
14, 27]: 2, 6, 14, 27 and 28.
stion in 30
jects...and growing!
Expected output:
rts
List: [2, 5, 7, 9, 14, 27]
Search target: 2
Elements visited: 2
Target found at position 0
Search target: 6
Elements visited: 2 57
a detailed solution
s fast as 30 minutes.*
Target not found
Search target: 14
Elements visited: 2579 14
Target found at position 4
Search target: 27
CSC130
Lab 03
Page 2
Elements visited: 2579 14 27
Target found at position 5
Search target: 28
Elements visited: 2579 14 27
Target not found
PROGRAM 2
Define the function reverse(lyst, start, end), which reverse elements in the list lyst, starting
巴
D Focus
100%
Python 3.7.8 64-bit
O 0 A 0
Ln 27, Col 20 Spaces: 4 UTF-8 CRLF Python R Q
*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers
8:21 PM
and may belengar fararamotionalofs
P Type here to search
79°F Clear
(1
9/13/2021
近
Transcribed Image Text:CSC130-Lab03(1) - Protected View - Saved to this PC - o Search michael terani Layout References Mailings Review View Help A Share P Comments om the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View. Enable Editing E Reading list PROGRAM 1 Ask an Expert The code of a sequential search function is shown on textbook page 60. In fact, if the list is already sorted, the search can halt when the target is less than a given element in the list. For example, given my_list = [2, 5, 7, 9, 14, 27], if the search target is 6, the search can halt when it reaches 7 because it is impossible for 6 to exist after 7. Define a function linearsearchsorted, which is used to search a sorted list. This function displays the position of the target item if found, or 'Target not found' otherwise. It also displays the elements it has visited. To test your function, search for these targets in the list [2, 5, 7, 9, 14, 27]: 2, 6, 14, 27 and 28. stion in 30 jects...and growing! Expected output: rts List: [2, 5, 7, 9, 14, 27] Search target: 2 Elements visited: 2 Target found at position 0 Search target: 6 Elements visited: 2 57 a detailed solution s fast as 30 minutes.* Target not found Search target: 14 Elements visited: 2579 14 Target found at position 4 Search target: 27 CSC130 Lab 03 Page 2 Elements visited: 2579 14 27 Target found at position 5 Search target: 28 Elements visited: 2579 14 27 Target not found PROGRAM 2 Define the function reverse(lyst, start, end), which reverse elements in the list lyst, starting 巴 D Focus 100% Python 3.7.8 64-bit O 0 A 0 Ln 27, Col 20 Spaces: 4 UTF-8 CRLF Python R Q *Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers 8:21 PM and may belengar fararamotionalofs P Type here to search 79°F Clear (1 9/13/2021 近
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
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