Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is just not the way to do this I have tried to make your assignments so far as real-world as possible. The final project

image text in transcribed

This is just not the way to do this I have tried to make your assignments so far as real-world as possible. The final project we come up with could actually be useful for, say, a STEM Center director, and along the way we've covered the required material for the class. This assignment is a little contrived, though. Meaning, we could do this more easily and more efficiently-but this assignment will help you understand how sorts and recursions work. It is important to understand recursion, but recursion is expensive in terms of both memory and processing time. So, if there's an easy way to do a task directly, it's probably best to avoid recursion. Unless you are doing this assignment And, it's important to understand sorts. Believe it or not, a LOT of research has been done about sorting algorithms in the last century or so. Bubble sort is easy to understand, but there are other sorts that are much faster. You will learn about them in your algorithms class. So here we are, implementing a bubble sort with recursion. It's okay, we have a very small amount of data to sort And I guarantee you will be challenged with this assignment. The Program Spec Create a function recursive sort0 which has as its parameters, list to sort (a list of tuples like the one you just made) and key. key should have a default value of zero, and refers to whether the list should be sorted by the first or second value in the tuple. Of course, recursive sorti should call itself as part of the process. The sorted part of the list will be growing from the end of the list. Each time you call recursive sort, you should be calling with a smaller list. You can use slicing for this. For example, suppose you were sorting this list list [5,4,1,2,3] after the first pass your list would look like this. The five at the end won't change after this pass, it's in its correct position. 4,1.2,3,5 For the next pass, just pass the first four elements, or list[0:4l. After sorting, the list looks like this: (1,2,3,4,5 Your list is sorted, but the program doesn't know that. It only knows for sure that the last two elements are sorted. So pass list 0:3) You might create some code in your algorithm to recognize when no flips are made in a particular pass. In this case, the program knows that the list is sorted and can end. It's also okay (but not as efficient) to continue passing the list through the recursion until there is only one item left to pass If you are struggling to get the logic right, try printing out the list inside the function you are creating, to see how it changes. Remember the unit test code I gave you for the last assignment? We don't need that anymore, please replace it with these lines: print (sensorlist) print(recursive sort(semsor list,a)) print Crecursivesart(sensor_list, ) print (senscr.list) The first four lines of your run should look exactly like those in the run below. Notice that the original list remains in its originall order [('4213' 'STEN Center," ), ('4281', 'Foundations Lab". 1)" ('420', 'CS Lab." 2), ('421S', ''orkshop Roon". 3), ('4205', 'Ti1ed Roon". 4), "Out". .Outside', [('4201' 'Foundations Lab', 1) ('4284'. "CS Lob." 2), ('420S', 'Tiled Roon'. 4), ('4213', 'STEM Center". 0), ('4218Workshop Roon", 3), "Out". .Outside', [('4204., .CS Lab". 2)" '4201'. "Foundations Lob." 1), ("Out', 'Outside', 5) ('4213', "STEM Center". 0. ('4265, .Tiled Roon". 4), ('4218'. "rkshop Root', [("4213' 'STEN Center". ), ('4281', 'Foundations Lab', 1), ('420'CS Lab". 2), ('421S', 'Horkshop Roon". 3), {'4205', 'Tiled Roon", 4), ('Out', .Outside." STEM Center Tenperoture Project Eric Reed S)] S)] 3)] S)] Moin Nenu 1-Process a new dota file 2 Choose units 3-Edit rcom filter 4 -Show surmary stotistics 5 Show terperature by date and tine 6 -Show histogron of temperatures 7 - Quit Whot is your choice? ? Thonk you for usting the STEM Center Terperature Project Process finished with exit code 0 This is just not the way to do this I have tried to make your assignments so far as real-world as possible. The final project we come up with could actually be useful for, say, a STEM Center director, and along the way we've covered the required material for the class. This assignment is a little contrived, though. Meaning, we could do this more easily and more efficiently-but this assignment will help you understand how sorts and recursions work. It is important to understand recursion, but recursion is expensive in terms of both memory and processing time. So, if there's an easy way to do a task directly, it's probably best to avoid recursion. Unless you are doing this assignment And, it's important to understand sorts. Believe it or not, a LOT of research has been done about sorting algorithms in the last century or so. Bubble sort is easy to understand, but there are other sorts that are much faster. You will learn about them in your algorithms class. So here we are, implementing a bubble sort with recursion. It's okay, we have a very small amount of data to sort And I guarantee you will be challenged with this assignment. The Program Spec Create a function recursive sort0 which has as its parameters, list to sort (a list of tuples like the one you just made) and key. key should have a default value of zero, and refers to whether the list should be sorted by the first or second value in the tuple. Of course, recursive sorti should call itself as part of the process. The sorted part of the list will be growing from the end of the list. Each time you call recursive sort, you should be calling with a smaller list. You can use slicing for this. For example, suppose you were sorting this list list [5,4,1,2,3] after the first pass your list would look like this. The five at the end won't change after this pass, it's in its correct position. 4,1.2,3,5 For the next pass, just pass the first four elements, or list[0:4l. After sorting, the list looks like this: (1,2,3,4,5 Your list is sorted, but the program doesn't know that. It only knows for sure that the last two elements are sorted. So pass list 0:3) You might create some code in your algorithm to recognize when no flips are made in a particular pass. In this case, the program knows that the list is sorted and can end. It's also okay (but not as efficient) to continue passing the list through the recursion until there is only one item left to pass If you are struggling to get the logic right, try printing out the list inside the function you are creating, to see how it changes. Remember the unit test code I gave you for the last assignment? We don't need that anymore, please replace it with these lines: print (sensorlist) print(recursive sort(semsor list,a)) print Crecursivesart(sensor_list, ) print (senscr.list) The first four lines of your run should look exactly like those in the run below. Notice that the original list remains in its originall order [('4213' 'STEN Center," ), ('4281', 'Foundations Lab". 1)" ('420', 'CS Lab." 2), ('421S', ''orkshop Roon". 3), ('4205', 'Ti1ed Roon". 4), "Out". .Outside', [('4201' 'Foundations Lab', 1) ('4284'. "CS Lob." 2), ('420S', 'Tiled Roon'. 4), ('4213', 'STEM Center". 0), ('4218Workshop Roon", 3), "Out". .Outside', [('4204., .CS Lab". 2)" '4201'. "Foundations Lob." 1), ("Out', 'Outside', 5) ('4213', "STEM Center". 0. ('4265, .Tiled Roon". 4), ('4218'. "rkshop Root', [("4213' 'STEN Center". ), ('4281', 'Foundations Lab', 1), ('420'CS Lab". 2), ('421S', 'Horkshop Roon". 3), {'4205', 'Tiled Roon", 4), ('Out', .Outside." STEM Center Tenperoture Project Eric Reed S)] S)] 3)] S)] Moin Nenu 1-Process a new dota file 2 Choose units 3-Edit rcom filter 4 -Show surmary stotistics 5 Show terperature by date and tine 6 -Show histogron of temperatures 7 - Quit Whot is your choice? ? Thonk you for usting the STEM Center Terperature Project Process finished with exit code 0

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

Step: 3

blur-text-image

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions