Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
5 votes
2 answers
445 views

Weakly-Referencing Tree Structure in Python

For another project of mine, I decided that it would be handy to have a tree structure to dictate hierarchy between pieces of data, but I didn't want to unnecessarily keep that data alive if it would ...
BetterBuiltFool's user avatar
4 votes
1 answer
169 views

AutoComplete-Esque Tree

I've written a tree data structure that takes in input from the user, and stores the each letter based on the previous letter in the text. I'm not sure what this is called, but the closest I can find ...
Ben A's user avatar
  • 10.7k
2 votes
1 answer
206 views

Implementation of binary tree traversal

Based on what i understood of Binary Tree, queue and recursion I implemented this Breadth First Search algorithm as follows. Do you have any suggestions to improve (in term of readability, good ...
curious's user avatar
  • 333
8 votes
1 answer
2k views

Red-Black Tree Implementation in Python

I'm wondering if there are better practices, and optimizations I could make on my code, to do things easier/faster. I have added comments, in many places in the code, to make understanding easier. <...
user avatar
3 votes
0 answers
293 views

Noughts and Crosses Terminal Game with AI

I created a game which can play tic-tac-toe with: 0 players (AI vs AI), 1 player (human vs AI) or 2 player (human vs human). Here is the AI function which wraps around my innermost function. This ...
RelativelyUnique's user avatar
5 votes
1 answer
151 views

AVL Tree implementation Based on VisualGo

I have tried implementing an AVL Tree on my own, based on visualising it. But i'm unsure how many testcases it work with, and how efficient it is. Are there any ways to make it efficient, and compact? ...
Anonymous's user avatar
  • 1,244
2 votes
0 answers
95 views

Max Heap Implementation in Python

I decided to challenge myself to code this data structure by just seeing how it looks visually and this is what I got. I can change this easily to minheap by changing some greater than (>) operators. ...
Anonymous's user avatar
  • 1,244
4 votes
2 answers
317 views

Suffix Tree in Python

I was wondering why the following implementation of a Suffix Tree is 2000 times slower than using a similar data structure in C++ (I tested it using python3, pypy3 and pypy2). I know the bottleneck is ...
Pythonic AC's user avatar
2 votes
2 answers
407 views

Iterative “post order” tree traversal [closed]

I wanted to get feedback on the correctness and efficiency of this post order traversal routine that my wife and I find really easy to grasp. ...
Curious Programmer's user avatar
2 votes
1 answer
740 views

Python Fenwick Tree

I am trying to solve this question: https://open.kattis.com/problems/fenwick A Fenwick Tree (also known as a Binary Indexed Tree) is a data structure on an array which enables fast (𝑂(log𝑛)) ...
nz_21's user avatar
  • 1,051
3 votes
2 answers
2k views

Ternary search tree implementation in python 3

I have implemented a Ternary search tree. It works well. But if you think something needs to be improved, say it. This code was tested in Python 3.7.4. ...
Brijesh Kalkani's user avatar
3 votes
2 answers
361 views

Binary Search Tree implementation in Python 3

Please review my BST Code 1. Class node class Node: 2. Constructor ...
Brijesh Kalkani's user avatar
6 votes
3 answers
169 views

Symmetric Tree Check in Python

Inspired by This LeetCode Question. Instead of checking if every layer is symmetric, it instead checks if any aren't. This allows the program to leave early is an early layer fails the test. I'm ...
Ben A's user avatar
  • 10.7k
-1 votes
1 answer
1k views

Python 3 code for a binary search tree [closed]

I am working on a python3.6.5 question about BST: Binary search tree (BST) is a binary tree where the value of each node is larger or equal to the values in all the nodes in that node's left subtree ...
ywan's user avatar
  • 9
1 vote
1 answer
519 views

leetcode 987. Vertical Order Traversal of a Binary Tree

anyone can provide some suggestion about my answer for the questions 987. Vertical Order Traversal of a Binary Tree Given a binary tree, return the vertical order traversal of its nodes values. For ...
A.Lee's user avatar
  • 361

15 30 50 per page