841 questions
Advice
0 votes
2 replies
34 views
DFS VS DSFVisit
I'm in college learning about DFS and BFS. I knew about this before, although what's throwing me in a loop is DFSVisit. I just want to know what's the difference between DFS and DFSVisit. Is DFS just ...
-1 votes
1 answer
91 views
Why does modifying the returned pair from a recursive call break my solution in Binary Tree Consecutive Sequence II?
I'm trying to solve the Binary Tree Longest Consecutive Sequence II problem (Leetcode 549). The goal is to find the length of the longest consecutive path (increasing or decreasing) in a binary tree. ...
2 votes
3 answers
131 views
Converting a vector to a map in Clojure
I'm having a problem with a little function that's supposed to count nodes and leaves in a tree. This is what it looks like: (defn count-tree "Count nodes and leaves in a tree as produced by ...
-1 votes
1 answer
68 views
Not able to submit a binary tree code on gfg (vertical order traversal)
I was doing the GeeksforGeeks practice problem Vertical Tree Traversal: Given a root of a Binary Tree, find the vertical traversal of it starting from the leftmost level to the rightmost level. If ...
1 vote
1 answer
114 views
Is BFS and a Tree Data Structure Sufficient for Comparing if two Trees are Structurally Equal?
I’m working on a problem where I need to compare multiple lineages (family trees) to check if they are structurally identical. Each lineage starts from a single root (ancestor) and extends downwards. ...
2 votes
1 answer
168 views
Is the inorder predecessor of a node with no left subtree and being the left child of its parent always its grandparent?
I'm trying to understand the rules for finding the inorder predecessor of a node in a binary search tree (BST). If a node 𝑥 has a left subtree, the inorder predecessor is the largest value in that ...
1 vote
1 answer
179 views
Is the Inorder Predecessor of a Node with a Left Subtree Always a Leaf Node in a Binary Search Tree?
In a Binary Search Tree (BST), I am trying to understand the properties of the inorder predecessor, particularly for nodes that have a left subtree. Definition: The inorder predecessor of a node is ...
0 votes
1 answer
54 views
Optimize tree-traversal over table of data
I have a tree which contains links between multiple nodes. I also have a dataframe with 1 million rows. There is a mapping between tree nodes and dataframe columns as follows: import networkx as nx ...
0 votes
1 answer
59 views
What is wrong with my approach of finding an indorder predecessor of a binary search tree?
void inorderPredecessor(Node* root, Node* &pre,int key){ if(root == NULL ) return ; if(root -> data == key){ inorderPredecessor(root ->left , pre , key); }else if(root -&...
2 votes
1 answer
58 views
Why is my traversing in BST not showing the results like the sample output?
My question is with traversing. In my problem the sequence of the traversal is not following as it should. I am using the general logic for the inorder, preorderand the postorder traversal but it is ...
-1 votes
1 answer
157 views
A straightforward recursive level-order traversal method?
I have seen answers indicating that there is something intrinsically non-recursive about level-order traversal. I suggest it can be done recursively in a very natural way (Node is defined as expected) ...
0 votes
0 answers
47 views
Creating a Method in C# that traverses HTML document and extracts content based on a query, i.e Custom HTML Crawler
I created a program that parses each one of the elements of an HTML Document. It saves it in a Tree strcuture(unbalanced tree). public class Attribute { public string? Key { get; set; } public ...
-1 votes
3 answers
144 views
Use awk to walk a tree expressed via indendation
spec: replicas: 1 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 0 selector: matchLabels: app.kubernetes.io/name: myapp app.kubernetes.io/instance: myapp I ...
0 votes
1 answer
47 views
What is wrong with my Morris Traversal code?
I am trying to recover a binary search tree using morris traversal. /** * Definition for binary tree * class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(...
1 vote
3 answers
160 views
How to spread an infected node to its adjacent nodes and eventually to the whole binary tree?
I want to iteratively return the state of the binary tree until the infection is unable to spread to a new node. So how it goes is that the virus will spread to any directly adjacent healthy node and ...