Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Objective - Data Structures - Homework, Slides of Data Structures and Algorithms

key points of Data Structures are: Objective, Download, Extract, Node Class, Interactively, Description of Operation, Cursor-Based Operations, Current, Returns, Postcondition

Typology: Slides

2012/2013

Uploaded on 04/30/2013

naji
naji 🇮🇳

4.3

(6)

88 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download Objective - Data Structures - Homework and more Slides Data Structures and Algorithms in PDF only on Docsity! Objective: To gain experience using a cursor-based list by implementing a text-editor program. Plus, it provides experience using a doubly-linked list with header and trailer nodes. To start the homework: Download and extract the file hw3.zip from / / The hw3.zip file contains:  the Node class (in the node.py module) and the Node2Way class (in the node2way.py module)  the skeleton CursorBasedList class (in the cursor_based_list.py module) which you will complete  the cursorBasedListTester.py file that you can use to interactively test your CursorBasedList class. Part A: Recall that in a cursor-base list a cursor (indicating the current item) can be moved around the list with the cursor being used to identify the region in the list to be manipulated. We will insert and removing items relative to the current item. A current item which is always defined as long as the list is not empty. Precondition: the list is not empty. Removes and returns the current item. Making the next item the current item if one exists; otherwise the tail item in the list is the current item unless the list in now empty. L.remove() Precondition: the list is not empty. Replaces the current item by the newValue. L.replace(newValue) Inserts item before the current item, or as the only item if the list is empty. The new item is the current item. L.insertBefore(item) Inserts item after the current item, or as the only item if the list is empty. The new item is the current item. L.insertAfter(item) Precondition: the list is not empty. Makes the last item the current item. L.last() Precondition: the list is not empty. Makes the first item the current item. L.first() Precondition: hasPrevious returns True. Postcondition: The current item has moved left one item L.previous() Precondition: the list is not empty. Returns True if the current item has a previous item; otherwise return False. L.hasPrevious() Precondition: hasNext returns True. Postcondition: The current item has moved right one item L.next() Precondition: the list is not empty. Returns True if the current item has a next item; otherwise return False. L.hasNext() Precondition: the list is not empty. Returns the current item without removing it or changing the current position. L.getCurrent() Description of operationCursor-based operations The cursor_based_list.py file contains a skeleton CursorBasedList class. You MUST uses a doubly-linked list implementation with a header node and a trailer node. An empty list looks like: previous data next previous data next _header _current _trailer _size 0 All “real” list items will be inserted between the header and trailer nodes to reduce the number of “special cases” (e.g., inserting first item in an empty list, deleting the last item from the list). Use the provided cursorBasedListTester.py program to test your list. Data Structures (CS 1520) Homework #3 Docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved