Skip to main content
Stack Overflow for Teams is now Stack Internal: See how we’re powering the human intelligence layer of enterprise AI. Read more >
Filter by
Sorted by
Tagged with
-1 votes
1 answer
107 views

I have a working recursive solution to check if a binary tree is symmetric. The code works correctly for my test cases, but I'm concerned about potential stack overflow with deep trees since Python ...
Jared McCarthy's user avatar
1 vote
1 answer
48 views

Consider the following recursive data type: data Chain a = End | Link a (Chain a) By deriving a Generic instance for this recursive type, show can be defined in terms of genericShow: derive instance ...
jfMR's user avatar
  • 25.1k
0 votes
0 answers
52 views

I performed HDBSCAN Clustering hdbscan_clusterer = hdbscan.HDBSCAN(min_cluster_size=200) df['Cluster'] = hdbscan_clusterer.fit_predict(data_matrix_for_clustering) Now, I’m interested in getting the ...
name0's user avatar
  • 1
-1 votes
2 answers
83 views

i am trying to get a flatted list of dependencies. list_of_task_to_generate = [ {"version": "1", "dependency": []}, {"version": "2", "...
pelos's user avatar
  • 1,860
0 votes
1 answer
167 views

I want to parse recursive enum representing arithmetic expressions using Nom. I have the following code. #[derive(Debug, PartialEq, Eq)] enum ArithExp { Const(i32), Add(Rc<ArithExp>, Rc&...
cptkidd's user avatar
  • 37
1 vote
0 answers
22 views

I have the following type: export type TreeViewBaseItem = { id: string; label: string; editable:boolean; children?: TreeViewBaseItem[]; files: TreeFile[]; }; and I did my best to ...
MiguelG's user avatar
  • 471
-1 votes
1 answer
69 views

public ListNode swapPairs(ListNode node) { ListNode head = node; ListNode cur = node; while (head != null && head.next != null) { head = reverseList(head, 0); head....
Thor's user avatar
  • 9
1 vote
2 answers
511 views

I am currently learning about heap sort and I am having trouble understanding the heapify process, particularly when both children of the root are larger than the root itself, and the sub-children (...
Zain ul Abedin's user avatar
0 votes
2 answers
72 views

I have a deeply nested JavaScript object structure representing a hierarchical data model. The object can have multiple levels of nested children, and I need to search for a specific value within this ...
Raj Ratan's user avatar
1 vote
1 answer
299 views

I wrote a solution to the problem linked below but I'm not sure about its time complexity. I was thinking it was quadratic but it passed within 0 ms when I submitted, so it might be linear idk. I ...
renanmatulianes's user avatar
2 votes
0 answers
94 views

I'm completing the datastructures and algorithms preparatory course for a masters in data science. Here, is a breadth-first search algorithm for a graph I wrote based on the pseudocode provided in the ...
Marrtinerz's user avatar
1 vote
1 answer
94 views

In the context of the bill of materials, I have a tree structure and I want to perform a recursive function to find the different paths of this tree. I did, however, a mistake when trying to define a ...
LHA's user avatar
  • 49
0 votes
2 answers
71 views

I am working on a Java project to involving quadtrees. In this representation of the quadtree, the node with intensity -1 has 4 children and the node with any other intensity does not have children. I ...
Ahmed Taha's user avatar
1 vote
1 answer
52 views

I am trying to solve LeetCode problem 110. Balanced Binary Tree: Given a binary tree, determine if it is height-balanced. Here is my attempt: class Solution { boolean c = true; public ...
shanmukha varma's user avatar
2 votes
1 answer
96 views

I'm writing a programming language (details irrelevant) which uses Lisp-like cons cells to store its data (this makes implementing the garbage collector easy). I'll spare you the details of everything ...
dragoncoder047's user avatar
0 votes
1 answer
89 views

When the base case is reached then for next combination call we re-swap how it is taking in to account the not visited or considered cases. For example function dfs(i, nums, slate) { if (i === ...
shubham's user avatar
  • 101
0 votes
0 answers
99 views

This is a brief example from the book, by Tomas Petricek, "Functional programming in the real world", chapter 8. type QueryInfo = { Title: string Check: Client -> bool ...
dondublon's user avatar
  • 701
-2 votes
1 answer
96 views

I'm loosing my mind with this (because I'm not a very logic person). RUST Playground I cannot change the data part. The string returned from the below code is A = 1 AND (B = 2 OR C = 3 OR D = 4 OR ) ...
Fred Hors's user avatar
  • 4,273
0 votes
1 answer
74 views

So I'm fairly new to all this. I've got the beginnings of a simple Octree implementation for a Unity project. This consists of an Octree parent class, an instance of it, and a OctreeNode subclass I'm ...
Ferrick's user avatar
0 votes
1 answer
330 views

Everybody would agree that this one, shown below, is a valid Binary tree. * (R) \ \ * (C) The above binary tree node marked R, is the root and the node marked C is the child. This is not a Full ...
John Doe's user avatar
  • 2,932
0 votes
1 answer
33 views

Apologies for the butchered title. I have a db of metrics where I have fields like Metric Title, Metric ID, Metric Abbreviation, and Metric Formula. The Metric Formula indicates if the metric requires ...
Solrac's user avatar
  • 43
1 vote
1 answer
347 views

T(n) = 2T(n/2) + Logn This is the given time complexity and I am using recursive tree method to find it's time complexity. For the first call it is doing : Log(n) work For second it is doing: Log(n/2) ...
xyz xyz's user avatar
  • 21
0 votes
3 answers
121 views

I have 2 lists: a = [1, 2, 3, 4, 5] b = [9, 8, 7] I performed the following two operations and tried printing each list a.append(b) b.append(a) print(a) # Expected Result: [1, 2, 3, 4, 5, [9, 8, 7]] ...
Karan Shah's user avatar
0 votes
1 answer
86 views

so, i am following algorithm design but the below algorithm implemented from the book, fails in the following e.g., is there an issue with this algo - bool directed = true; bool dfs(...
user123456's user avatar
0 votes
1 answer
96 views

In special scenarios I have this data structure namespace x3 = boost::spirit::x3; struct one; struct two : x3::variant<x3::forward_ast<one>,int>{ using base_type::base_type; using ...
luohe's user avatar
  • 79
1 vote
1 answer
35 views

I need to write an algorithm where I have a python dictionary like {1: [2, 6], 2: [3], 6: [5], 3: [4], 5: [8, 9], 4: [5, 7]} and generate the sequence like [[1, 2, 3, 4, 5,8],[1, 2, 3, 4, 5,9], [1,2,...
user3301428's user avatar
0 votes
1 answer
314 views

I am trying to solve this problem on leetcode: https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ (Flatten binary tree into linkedlist) This is my code: class Solution{ ...
hermit's user avatar
  • 1,117
0 votes
1 answer
290 views

I am working on a small feature-incomplete Lisp interpreter to learn a bit of Zig. My inspiration is this https://norvig.com/lispy.html, this might not be the most idiomatic way of implementing that ...
Emulebest's user avatar
0 votes
0 answers
43 views

I'm working through binary search trees in The Odin Project (TOP)(https://www.theodinproject.com/lessons/javascript-binary-search-trees) and I'm having trouble with the insert function. I believe the ...
Julian's user avatar
  • 441
3 votes
1 answer
683 views

I am implementing a tree data structure. My idea to do this is to have a struct Tree that have children:SomeMapType<Tree> field to keep track of its children nodes, where SomeMapType may be ...
Clément Dato's user avatar
-2 votes
1 answer
62 views

I've written a python function to reverse a list, here are the two functions and their respective outputs. Function 1 a=[1,5] def rev(k,i): if i==len(k)-1: print("in base case {}&...
Amarjeet Kushwaha's user avatar
0 votes
1 answer
71 views

I am using a recursive function to generate text using a RegEx match, where it finds a pattern of words according to a combination of synonyms inside square brackets (pattern = '\[.*?\]') separated by ...
kg211's user avatar
  • 1
2 votes
1 answer
460 views

i am trying to make a code for a college aplication of a patricia/radix tree that inserts words read from each line in a txt file in the tree, so if i read a file that says roman romance romantic its ...
Davi Franke's user avatar
1 vote
1 answer
156 views

I am struggling to find a recursive mapping to get the end result. Here is the input df ## mapping recursive import pandas as pd data = { "group1": ["A", "A", "B&...
Joanna's user avatar
  • 673
0 votes
1 answer
515 views

I'm a student starting to learn about Computer Science, specifically Data Structures and Algorithm. Been struggling in understanding the Time Complexity of Merge Sort Algorithm, specifically deriving ...
newbieCoder's user avatar
-1 votes
1 answer
115 views

So I keep getting a maximum recursion error on line 22, for this test case list1 is 1,2,4 list2 is 1,3,4 Output is 1,1,2,3,4,4 can someone explain what is causing this infinite loop to occur, python ...
Shahryar's user avatar
1 vote
1 answer
461 views

I tried to provide an implementation of the Display trait on the recursive data structure Tree as defined below. #[derive(Debug)] struct Tree <'a> { node: (&'a str, Vec<Tree<'a>&...
Theodora's user avatar
  • 598
1 vote
1 answer
98 views

I have the following entities in my Spring boot Hibernate project. Entities Task - represents the task / job details Agent - represents the agents available to work on the tasks TaskAgent - stores ...
Jugs's user avatar
  • 53
0 votes
0 answers
32 views

Using R tibbles, I have a df as shown below. It's a BOM data structure. df <- data.frame( product_id= c("P1", "P1", "P1", "P1", "P1", "...
LHA's user avatar
  • 49
1 vote
2 answers
70 views

def populate_kids(self, arr, used_Indices): for a in self.children: a.get_all_jumps(arr, used_Indices) for a in self.children: for b in a.children: b.get_all_jumps(...
Currency's user avatar
1 vote
1 answer
89 views

I'm currently working on displaying tables. But im stuck because the data structure is super nested. This is the original structure: { "key": "parent_table", "...
tedeeee's user avatar
  • 57
1 vote
2 answers
100 views

I'm currently working on displaying item. But im stuck because the data structure is super nested. This is the original structure: [ { "key": "name", "value": &...
tedeeee's user avatar
  • 57
0 votes
1 answer
292 views

How to insert a node in a complete binary tree without using queue DS? I tried the following code: class TreeNode: def __init__(self, value=None) -> None: self.left = None self....
H_coder's user avatar
  • 13
1 vote
1 answer
96 views

I want to simulate an interview scheduler, where the names with the highest scores are called first. It is my priority to make sure I apply the mergeSort algorithm somehow to this implementation. What ...
Jeyson's user avatar
  • 11
0 votes
0 answers
59 views

You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return true if you can ...
Tarun gujral's user avatar
0 votes
1 answer
244 views

Let's imagine we have a very simple AST for programming language with only functions and calls use std::sync::Arc; struct Function { pub body: Vec<Call> } struct Call { pub function: ...
gavrilikhin.d's user avatar
1 vote
0 answers
186 views

I have a tree structure and currently I am trying to return an iterator that iterates over the elements of the datastructure so that my function can accept a block. I have currently reduced my code to ...
Ding YuChen's user avatar
-1 votes
1 answer
87 views

I was solving a question today on Leetcode named Lexicographically Smallest Equivalent String (link) and I came up with a solution of DFS with some customization to solve the problem and here's is my ...
Kiran Deep's user avatar
3 votes
2 answers
92 views

I need to build a sql query to find the least expensive squad (salary-wise) for teams in a European volleyball league. For each team, the squad consists of 6 players. The entire team has 10 players (...
VBStarr's user avatar
  • 706
0 votes
2 answers
301 views

def spynum (n,r,sm=0,pd=1): #s = 0 #p = 1 #b = False if n == 0: print (sm==pd) return sm == pd else: rem = n % 10 sm += rem pd *= rem print (sm,pd,rem) spynum(n//10,rem,...
6 A.S.Harish Kumar's user avatar

1
2 3 4 5
11