




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The implementation of fundamental data structures in computer science, specifically binary trees, and their real-world applications. It provides directions for completing the implementation of various binary tree methods, including depth, height, size, breadth-first, in-order, post-order, and pre-order traversals. Additionally, it outlines the implementation of methods for adding, removing, and finding nodes in a binary search tree. The document also discusses changes to the bookstore and calculator systems, requiring the implementation of methods to manage book catalogs and parse and evaluate mathematical expressions using binary trees. By studying this document, students can develop problem-solving skills, understand the advantages and disadvantages of different data structure implementations, and apply their knowledge to real-world scenarios.
Typology: Exercises
1 / 8
This page cannot be seen from the preview
Don't miss anything!
Learning Objectives:
CLO 1. Identify fundamental data structures in computer science and their use in real-life appli- cations.
CLO 3. Develop problem solving skills by implementing data structures.
CLO 4. Compare advantages and disadvantages of different data structure implementations.
CLO 5. Design and analyze composite data structures.
Files to Modify: BinaryTree.py Directions: Finish the implementation of the following methods:
Files to Modify: BinarySearchTree.py (new template) Directions: Finish the implementation of the following methods:
(Optional) Test your data structures:
1: first 2: second 3: third 4: fourth 5: fifth
Files to Modify: (i) BookStore.py (ii) BinarySearchTree.py Directions:
Initialize current to be the root. Initialize smallest to be None. While current is not None:
return smallest
For example, if the catalogue contains books with titles, “World of Borrowed Time" “World of Byzantine Architecture" “World of Cats" “World of Chaos & Darkness" “World of Chocolates" “World of Daisies" Then, addBookByPrefix(“World of C") should add the Book with title “World of Cats", and return the title. Furthermore, addBookByPrefix(“World of Co") should not add any book to the cart, and should return None.
HINTS : I. If the given prefix exists as a title itself, then prefix will match a key in self.sortedTitleIndices. Otherwise, a book with a title that may contain the prefix must be alphabetically greater than prefix, i.e., prefix < book.title. If we want to find the first alphabetically, matched book potentially containing the prefix, then we are looking for the smallest key (i.e. title) in self.sortedTitleIndices that is greater than or equal to prefix. II. Your method from problem 3. of the BookStore System section might come in handy. III. You should make sure that a book title begins with prefix in order for it to be considered a match, i.e. you should be checking if title[0:n] == prefix where n = len(prefix).
Files to Modify: Calculator.py.
Directions: Implement the following methods:
1 Check mathematical expression 2 Store variable values 3 Print expression with values 4 Evaluate expression 0 Return to main menu
If the user chooses option 4, the system should prompt them for an expression. If all the variables in the expression have been defined, then the system will display the expression with the values substituted in, and the final evaluation. For example, assuming the user has already stored variable values alpha1 = 2, alpha2 = 4, beta1 = 3, beta2 = 5, option 4 would look like the following: Enter the expression: <user enters ((alpha1+beta2)(alpha2-beta1))> Evaluating expression: ((2.0+5.0)(4.0-3.0)) Result: 7. If one or more variables are missing defined values, then the system must display the error message: "Error - Not all variable values are defined." using the following format,
Enter the expression: <user enters ((alpha1+beta2)*(alpha2-beta1)//lambda)> Result: Error - Not all variable values are defined.
Full Credit Partial Credit No Credit Pts. vary; See Code- Post
0 pts.
BinaryTree implemen- tation
7 pts: Implementation is correct and passes all CodePost tests.
Implementation is partially correct; fails one or more CodePost tests.
Implementation is incorrect/incom- plete and fails all CodePost tests. BinarySearchTree im- plementation
11 pts: Implementation is correct and passes all CodePost tests.
Implementation is partially correct; fails one or more CodePost tests.
Implementation is incorrect/incom- plete and fails all CodePost tests. _build_parse_tree(e) implementation
2 pts: Implementation is correct and passes all CodePost tests.
Implementation is partially correct; fails one or more CodePost tests.
Implementation is incorrect/incom- plete and fails all CodePost tests. _evaluate(u) imple- mentation
2 pts Implementation is correct and passes all CodePost tests.
Implementation is partially correct; fails one or more CodePost tests.
Implementation is incorrect/incom- plete and fails all CodePost tests. Bookstore Main Menu implementation
4 pts. Implementation is correct and passes all CodePost tests
Implementation is partially correct; fails one or more CodePost tests.
Implementation is incorrect/incom- plete and fails all CodePost tests. Calculator Main Menu implementation
2 pts. Implementation is correct and passes all CodePost tests
Implementation is partially correct; fails one or more CodePost tests.
Implementation is incorrect/incom- plete and fails all CodePost tests.