Question in image. Please answer 5.2 . Please explain how to do also with the answer. The reference Question mentioned is also given

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%
Question in image. Please answer 5.2 . Please explain how to do also with the answer. The reference Question mentioned is also given
Section 5 - Linked Lists
Question 5.1
Write a Python program that creates an unordered, singly-linked list consisting of 8 items. Each item
in the linked list should be a number. You can use the code given in the lecture slides for your Node
and UnorderedList classes.
Your node class should contain the following functions:
• a constructor
• get_data() – returns the data in the node
• get_next() – returns the next node in the list
• set_data() – sets the data in the node to the value given as a parameter
set_next() – sets the node that this node links to, to the node given as a parameter
Your UnorderedList class should contain the following functions:
• a constructor
• add() - adds a node to the head of the list, containing the number given in the parameter
• is_empty() – returns True if the list is empty, and False otherwise
• size() – returns the size of the list
print_list() – displays the contents of all nodes in the list
Add code to create an UnorderedList object, and call its add() function to add 8 items to the list. Call
the is_empty(), size() and print_list() functions to show that they work. In your logbook, show your
code and the output when you run the code.
The 8 numbers you will add them to the list should be your student ID.
Example output:
Creating a linked list containing the following numbers: 21, 35, 40, 50, 15, 8
Displaying the contents of the list using the print_list () function
8 15 50 40 35 21
Testing the is_empty () function
False
Testing the size () function
Transcribed Image Text:Section 5 - Linked Lists Question 5.1 Write a Python program that creates an unordered, singly-linked list consisting of 8 items. Each item in the linked list should be a number. You can use the code given in the lecture slides for your Node and UnorderedList classes. Your node class should contain the following functions: • a constructor • get_data() – returns the data in the node • get_next() – returns the next node in the list • set_data() – sets the data in the node to the value given as a parameter set_next() – sets the node that this node links to, to the node given as a parameter Your UnorderedList class should contain the following functions: • a constructor • add() - adds a node to the head of the list, containing the number given in the parameter • is_empty() – returns True if the list is empty, and False otherwise • size() – returns the size of the list print_list() – displays the contents of all nodes in the list Add code to create an UnorderedList object, and call its add() function to add 8 items to the list. Call the is_empty(), size() and print_list() functions to show that they work. In your logbook, show your code and the output when you run the code. The 8 numbers you will add them to the list should be your student ID. Example output: Creating a linked list containing the following numbers: 21, 35, 40, 50, 15, 8 Displaying the contents of the list using the print_list () function 8 15 50 40 35 21 Testing the is_empty () function False Testing the size () function
Question 5.2
Add a function called search() to your UnorderedList class in Question 5.1. This function should take
a number as a parameter and return True if the number is contained in the linked list, or False if the
number is not in the list.
Add code to your program to allow the user to enter a number, and search for the number in your
linked list. Display a message to the user indicating if the number they entered was found in the list
or not. In your logbook, include your code, and also output that shows you have tested the search
function for a number in the list and a number not in the list.
Example output:
Please enter a number to search for in the list: 50
True
Please enter a number to search for in the list: 28
False
Transcribed Image Text:Question 5.2 Add a function called search() to your UnorderedList class in Question 5.1. This function should take a number as a parameter and return True if the number is contained in the linked list, or False if the number is not in the list. Add code to your program to allow the user to enter a number, and search for the number in your linked list. Display a message to the user indicating if the number they entered was found in the list or not. In your logbook, include your code, and also output that shows you have tested the search function for a number in the list and a number not in the list. Example output: Please enter a number to search for in the list: 50 True Please enter a number to search for in the list: 28 False
Expert Solution
steps

Step by step

Solved in 3 steps with 7 images

Blurred answer
Knowledge Booster
Concept of Light
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