Tree Traversal Functions​


Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due


Team Programming Project Instructions

Grade: 10 points

Project Objective

The goal of this project is to work as a team to complete a provided code by developing specific functions related to tree and graph manipulation. This assignment will help you enhance your programming,collaboration, and problem-solving skills.

Tasks to Complete

Analyze the Provided Code


  • Task: Download the base code provided by the instructor and familiarize yourself with its structure.
  • Requirements: Understand the classes and objects that have already been implemented.


Tree Traversal Functions

Task: Implement two tree traversal functions.

  • Depth-First Search (DFS): This function should traverse the tree in depth and return a list of visited nodes in the order of traversal.
  • Breadth-First Search (BFS): This function should traverse the tree in breadth and return a list of visited nodes in the order of traversal.
  • Documentations:
    • https://www.boost.org/doc/ibs/1 87 0/libs/graph/doc/depth first search.html
    • https://www.kirupa.com/data_structures_algorithms/dfs_bfs.htm
    • https://brilliant.org/wiki/depth-first.search-dfs/
    • https://web.archive.org/web/20141029100806/http://opendatastructures.org/ versions/edition-0.1e/ods-java/12_3_Graph_Traversal.html#SECTION001531000000000000000

Graph to Adjacency Matrix Transformation

  • Task: Implement a function that takes a graph (represented as an adjacency list) and transforms it into an adjacency matrix.
  • Requirements:The matrix should be a list of lists where each element indicates the presence (1) or absence (0) of an edge between nodes.

Implementation of Search Functions

  • Task: Implement a function to search for a specific node in the tree or graph.
  • Requirements:The function should allow searching by value or by property and return the node if found, or indicate that the node does not exist.

Insertion and Deletion Functions

  • Task: Add functions to insert and delete nodes in the tree or graph.
  • Requirements:
    • The insertion function should allow adding a node with a specified value and, if applicable, a parent node.
    • The deletion function should remove a specified node and handle any necessary adjustments to maintain the structure of the tree or graph.

Depth Calculation Function

  • Task: Implement a function that calculates the maximum depth of the tree.
  • Requirements:The function should return an integer representing the maximum depth,defined as the longest path from the root node to a leaf node.
Cycle Detection Function
  • Task: Add a function that detects whether a graph contains a cycle.
  • Requirements: The function should return a boolean value: true if a cycle is detected and false otherwise. Ensure that the function works for both directed and undirected graphs.

Error Handling

  • Task: Implement error handling for cases where operations cannot be performed.
  • Requirements:
    • Ensure that your insertion and deletion functions check for conditions such as attempting to delete a non-existent node or inserting a duplicate node.
    • Provide meaningful error messages or exceptions to inform users of the issues encountered.

Testing and Validation

  • Task: Write unit tests for each function you develop.
  • Requirements: Ensure that your functions work correctly with different test cases, including edge cases.

Documentation

  • Task: Comment your code appropriately to explain the logic behind your implementations.
  • Requirements: Write a presentation document (1 to 2 pages) that describes your approach, the challenges you encountered, and how you overcame them.

Naming Conventions

  • Task: Each group will receive different naming conventions to follow in their code.
  • Requirements: Ensure that you adhere to the specific naming conventions provided to your group to maintain consistency and clarity in your code

Report Submission


  • Task: Submit a report summarizing your project.
  • Requirements: The report should detail your approach, findings, and any challenges faced during the project.

Evaluation

Your work will be graded out of 10 points based on the following criteria:
Functionality (6 points): The implemented functions work correctly and meet the specifications.
Code Quality (3 points): The code is well-structured, readable, and commented.
Report (1points): The presentation is clear and well-written.

Submission

The submission dead line is2025-03-31
Submit your code (source files only) and presentation document in one zip file. The report must be in .pdf.

Collaboration

Work as a team, but ensure that each member actively contributes to the project.Task distribution should be equitable


发表评论

电子邮件地址不会被公开。 必填项已用*标注