Sorting and Searching Project Problem Statement for Sorting and Searching Project Design a program that will take an unsorted list of names and use the Insertion Sort algorithm to sort them. The program then asks the user to enter names to see if they are on the list. The program will use the recursive Binary Search algorithm to see if the name is in the list. The search should be enclosed in a loop so that the user can ask for names until they enter the sentinel value 'quit' Design Considerations The main program will provide an unsorted list of names. The list will be sorted using the Insertion Sort algorithm. Once the list is sorted, the user will provide names to search for in the list. The search will be conducted using the Recursive Binary Search Algorithm. A message will be printed displaying whetherthe name was found or not found on the list. This last part will be done inside a loop where the user will enter 'quit' when they are done searching for names. The algorithm for the main()isshown below. This is notin pseudocode, it is left up to the student to convert this algorithm into a Python function: main() Initialize the unsorted list of names Print the unsorted list Sort the list using the Insertion Sort algorithm Print the sorted list Get a name from the user While the name is not equal to 'quit' Search for the name in the sorted list using the Recursive Binary Search algorithmif the name is found Write name, " was found" else Write name, "was not found" Get a name from the user The Insertion Sort and Recursive Binary Search are to be written as separate functions (see below). Use this unsorted list of names for testing: ['Paul', 'Aaron', 'Jacob', 'James','Bill', 'Sara', 'Cathy', 'Barbara', 'Amy', 'Jill'] Part 1. Insertion Sort Here is the pseudocode for the Insertion Sort function insertionSort(data) Set current to 1 length = len(data) WHILE (current < length) Set index to current Set placeFound to FALSE WHILE (index > 0 AND NOT placeFound) IF (data[index] last) RETURN FALSE ELSE Set middle to (first + last) // 2 IF (item equals data[middle]) RETURN TRUE ELSE IF (item < data[middle]) RETURN BinarySearch(data, first, middle–1, item) ELSE RETURN BinarySearch(data, middle+1, last, item)

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

Sorting and Searching Project

Problem Statement for Sorting and Searching Project

Design a program that will take an unsorted list of names and use the Insertion Sort algorithm to sort them. The program then asks the user to enter names to see if they are on the list. The program will use the recursive Binary Search algorithm to see if the name is in the list. The search should be enclosed in a loop so that the user can ask for names until they enter the sentinel value 'quit'

Design Considerations

The main program will provide an unsorted list of names. The list will be sorted using the Insertion Sort algorithm. Once the list is sorted, the user will provide names to search for in the list. The search will be conducted using the Recursive Binary Search Algorithm. A message will be printed displaying whetherthe name was found or not found on the list. This last part will be done inside a loop where the user will enter 'quit' when they are done searching for names.

The algorithm for the main()isshown below. This is notin pseudocode, it is left up to the student to convert this algorithm into a Python function:

main()

Initialize the unsorted list of names

Print the unsorted list

Sort the list using the Insertion Sort algorithm

Print the sorted list

Get a name from the user

While the name is not equal to 'quit'

Search for the name in the sorted list using the Recursive Binary Search algorithmif the name is found

Write name, " was found"

else

Write name, "was not found"

Get a name from the user

The Insertion Sort and Recursive Binary Search are to be written as separate functions (see below).

Use this unsorted list of names for testing:

['Paul', 'Aaron', 'Jacob', 'James','Bill', 'Sara', 'Cathy', 'Barbara', 'Amy', 'Jill']

Part 1. Insertion Sort

Here is the pseudocode for the Insertion Sort function

insertionSort(data)

Set current to 1

length = len(data)

WHILE (current < length)

Set index to current

Set placeFound to FALSE

WHILE (index > 0 AND NOT placeFound)

IF (data[index] <data[index –1])

Swap(data, index, index –1])

Set index to index –1

ELSE

Set placeFound to TRUE

Set current to current + 1

This algorithm has an abstract step:

Swap(data, index1, index2)

Set tempItem to data[index1]

Set data[index1] to data[index2]

Set data[index2] totempItem

Part 2. Binary Search

Write the code to implement the Recursive Binary Search algorithm as a function. Here is the pseudocode for that function:

BinarySearch(data,first, last, item)

IF (first > last)

RETURN FALSE

ELSE

Set middle to (first + last) // 2

IF (item equals data[middle])

RETURN TRUE

ELSE

IF (item < data[middle])

RETURN BinarySearch(data, first, middle–1, item)

ELSE

RETURN BinarySearch(data, middle+1, last, item)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Array
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