Lab5_21W

docx

School

Centennial College *

*We aren’t endorsed by this school

Course

254

Subject

Computer Science

Date

Jan 9, 2024

Type

docx

Pages

2

Uploaded by ChefPorcupineMaster87

Report
Data Structures and Algorithms COMP-254 Lab Assignment #5 – Using Trees and Priority Queues Due Date: Friday, Week 11 Purpose: The purpose of this Lab assignment is to: Design algorithms that describe operations on ADT Trees and priority queues. Implement and test appropriate methods in Java References: Read the course’s text chapter 8, 9 and the lecture slides. This material provides the necessary information that you need to complete the exercises. Be sure to read the following general instructions carefully: - This assignment must be completed individually by all the students. - You will have to demonstrate your solution in a scheduled lab session and upload the solution on eCentennial through the assignment link. Exercise 1 Design the algorithm and method for one of the following operations for a binary tree T: preorderNext(p): Return the position visited after p in a preorder traversal of T (or null if p is the last node visited). inorderNext(p): Return the position visited after p in an inorder traversal of T (or null if p is the last node visited). postorderNext(p): Return the position visited after p in a postorder traversal of T (or null if p is the last node visited). Write a Java program to test your solution. What are the worst-case running times of your algorithms? (5 marks) Exercise 2 Give an alternative implementation of the HeapPriorityQueue’s upheap method that uses recursion (and no loop). Hint : Do a single upward swap and recur (if necessary). (2 marks) Lab #5 Page 1 of 2
Data Structures and Algorithms COMP-254 Evaluation: Correct implementation of requirements: Correct ADT data structure algorithm Correct Java implementation Explanation of algorithm when asked 90% Friendly I/O 10% Total 100% You must name your Eclipse project according to the following rule: YourFullname_COMP254Labnumber_Exercisenumber . Example: JohnSmith_ COMP254Lab5_Ex1 Submission rules: Submit your modules as zip files that are named according to the following rule: YourFullname_ COMP254Labnumber_Exercisenumber.zip Example: JohnSmith_ COMP254Lab5_Ex1.zip Lab #5 Page 2 of 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help