GithubHelp home page GithubHelp logo

davis-ty / node.py Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2 KB

Python script: Binary tree implementation with traversal methods (inOrder, preOrder, postOrder), adjacency list generation, BFS, DFS, and search algorithms. Demonstrates tree operations & search techniques.

Python 100.00%

node.py's Introduction

Tree

-This Python script defines a binary tree structure and various traversal methods (inOrder, preOrder, postOrder). It also generates an adjacency list representation of the tree and performs breadth-first search (BFS) and depth-first search (DFS) traversal on the tree.

Binary Tree Implementation:

  • The Node class represents a node in the binary tree. The insert method inserts new nodes into the tree.

Traversal Methods:

  • inOrderPrint, preOrderPrint, and postOrderPrint methods perform in-order, pre-order, and post-order traversals of the tree, respectively.
  • Adjacency List Generation: The makeList function creates an adjacency list representation of the tree.

Search Algorithms:

  • bfs and dfs functions perform breadth-first search (BFS) and depth-first search (DFS) traversals on the tree, respectively.
  • search function checks if a given key exists in the tree.

Usage:

  • Instantiate a tree by creating a root node and inserting elements.
  • Call the traversal methods or search functions as needed.
  • This script demonstrates fundamental tree operations and search algorithms in Python, offering insight into tree data structures and traversal techniques.

node.py's People

Contributors

davis-ty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.