CS 120 (Spring 21): Introduction to Computer Programming II Short Project #15 due at 5pm, Thu 29 Apr 2021 1 Animated Linked List In this project, you’re going to be doing an animation, but this time,...

the question in the file


CS 120 (Spring 21): Introduction to Computer Programming II Short Project #15 due at 5pm, Thu 29 Apr 2021 1 Animated Linked List In this project, you’re going to be doing an animation, but this time, you will be animating insertion into a sorted linked list. So, while the pictures you draw are flexible, you will need to perform exactly the algorithm specified. Your program will be graded in two parts: an autograder will check to make sure that you print the right values, and your TA will grade the animation (and check to make sure that you’re actually using a linked list, not an array, for the data store). 2 Input You will read values from standard input. The user will type a series of integers; you should allow any number of integers per line (separated by whitespace), and you should allow blank lines. There will not be any comments in the input, or other text, other than the series of integers. Your program must not throw any exceptions, including one for the end-of- input. Store the inserted integers into a sorted linked list. (Make sure to sort them by their integer value, not string; for instance, 2 must come before 10.) 3 Output Each time that you read a new integer from input and insert it into the list, print out the list. Use the ListNode class defined in our class’s standard list_node.py; use its string format to show the contents of the list. Your output will look like this: After insertion, the list is now: 52 After insertion, the list is now: 52 -> 1000 After insertion, the list is now: 52 -> 123 -> 1000 Print nothing else. 1 4 Graphics Your animation is not required to look exactly like mine; feel free to tweak the details. However, your animation must: • Display the contents of the list (as a series of nodes and edges) after each new value is inserted. • Mark out the newly-inserted node, in some way, to show that it is different than the rest. • Automatically change the spacing between the nodes, so that, whether there are few nodes or many, the nodes should not go off screen. • Don’t make your window larger than 800x800 (so that your TA will be able to see the whole picture, even if their screen doesn’t have a huge resolution). Try to make your animation look nice. But provided that all of the nodes are spaced so that they are all on screen, it’s alright if you have some graphical glitches in exceptional situations. Here are bugs that I know about in my own animation, to give you a feel of acceptable quirks: • In my animation, if the number is large, it will stretch outside the box. • In the highlighted node, the corners of the box aren’t perfectly square. • If you insert many nodes into the linked list, my boxes will start to overlap. 2 Can you make your animation better than mine? I’d be delighted! Feel free to be creative here; you may dress up the picture if you want. I’d especially like to see if some student could actually animate the nodes - instead of inserting a new value and then just flashing a complete picture on the screen, how about making the nodes move slowly into their new locations? That’s not required, of course - but I’d love to see somebody do it. 5 Turning in Your Solution You must turn in your code using GradeScope. Name your file animated_linked_list.py . Worried about how GradeScope will work with all of your graphics code? Don’t be! We’ll be providing a “dummy” graphics file for you, as part of the autograder. This graphics file will allow you to make all your normal function calls - but they simply won’t do anything. So when we run your program on the autograder, you will read from stdin and print to stdout - and there will be no graphics at all. 3 Animated Linked List Input Output Graphics Turning in Your Solution
Apr 29, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here