Questions tagged [search-tree]

A tree shaped data structure which allows for storing orderable data so it may be efficiently searched later.

A tree shaped data structure which allows for storing orderable data so it may be efficiently searched later.

49 questions
0
votes
1 answer

Binary Search Tree in Haskell

I am starting to learn Haskell and therefore I tried to implement a Binary Search Tree. My current code looks like this: data SearchTree = Empty | Node Int SearchTree SearchTree deriving Show insert :: SearchTree -> Int -> SearchTree insert…
Mr. Moose
  • 101
  • 8
0
votes
1 answer

A star Search: Does Manhattan Distance dominate over Number of Missing Tiles for 8-Puzzle?

Considering three heuristics for 8-puzzle: h1(n) = number of misplaced tiles h2(n) = total Manhattan distance h3(n) = max(h1, h2) In an 8-puzzle, I was performing different puzzles and noticed that the h3 heuristic function (max) seems to…
user11576265
0
votes
1 answer

BST Rotations to make one tree equal to the other

I have this problem: You are given two non-empty binary search tree T1 and T2.T1 and T2 store the same keys. The structure of both trees, however, is different. Implement an algorithm that uses rotations on T1 to make it equivalent to T2. That is,…
0
votes
1 answer

Write entries of a searchtree(non-binary) into a list. (Iterative)

I am trying to write all entries of a search tree into a list. In unchanged order, nodes before children. But I mix the order up somewhere along the way. def n(value, children=[]): return [value,children] #I want to keep this order in the…
PeterPefi
  • 87
  • 1
  • 1
  • 7
0
votes
0 answers

Search in associative array by key

I have a set of numbers where each number has a key (ex. {"key1":1, "key2":2}). All the keys are unique. What is the best data structure to store them such that I can search by a key and find the value of that key efficiently? (possibly in logN…
Mateo
  • 83
  • 5
0
votes
2 answers

Storing values in binary search tree with C++

This code for a standard binary search tree does not contain any information, only the value of the nodes. Is there any way I can contain another value, for example, age, in the nodes? So that the node number will be id and the value it is carrying…
user840
  • 134
  • 1
  • 13
0
votes
0 answers

Max number of cores in a recursive search tree with Open MP

I want to implement a search tree using a recursive function. In each node, I evaluate a function Pass_or_Die. If Pass then the node is extended into n more branches, otherwise it dies. Suppose a node passes with a certain fixed probability. Suppose…
0
votes
2 answers

Finding values between min and max in 1d array in Javascript

I have an array with values and I need to find all values between min and max. I believe I need to construct some kind of search tree, is that correct? I want something like: var values : number[] = tree.findBetween(min : number, max: number); The…
daniel.sedlacek
  • 8,129
  • 9
  • 46
  • 77
0
votes
1 answer

Search tree node via closure in Google Apps Script

General problem I'm trying to solve I'm trying to implement a search tree in Google Apps Script, sorted by pkgName attribute, with the end purpose of comparing imported metadata on a software project against a Sheet containing similar data. To keep…
Mike Warren
  • 3,796
  • 5
  • 47
  • 99
0
votes
1 answer

How to create a binary search tree from string?

I tried to create a Morse encoder-decoder, and I have to do it with binary search tree (not with arrays). The following part supposedly takes a character array (which we created previously from a text file), and creates a search tree based on it. In…
Heves
  • 5
  • 3
0
votes
0 answers

Backtracking—convinient way to store resulting DataTree on Filesystem

I have created a backtracking algorithm, but after a while the program runs out of memory, since the amount of results is so huge. So I am about to find a way to store the resulting Data Tree onto the Filesystem, rather than the Memory/RAM. So I am…
philipp
  • 15,947
  • 15
  • 61
  • 106
0
votes
1 answer

Confusion whilst drawing query search tree?

We are working with the following knowledge base: house_elf(dobby). witch(hermione). witch('McGonagall'). witch(rita_skeeter). magic(X):- house_elf(X). magic(X):- wizard(X). magic(X):- witch(X). The question of the exercise was: Which of the…
CJ Carter
  • 27
  • 8
0
votes
1 answer

Ruby Search tree example confusion

I've been trying to take apart this app which creates a search tree based on keywords, but I'm afraid its a bit too complex for me. Would anyone mind explaining it? The format is off, so here's a pastebin (is pastie.org down?) version of it. Any…
sent-hil
  • 18,635
  • 16
  • 56
  • 74
0
votes
1 answer

Deleting Parts of Binary Search Tree

I am trying to solve the following problem: Return the root of a binary search tree t modified to contain only values <= k. (Using the normal BST class where we have an item,left and right) def prune(t,k): if not t: return None if k…
Mac
  • 123
  • 4
0
votes
1 answer

Tree traversal to find the most 'logical' SQL joins between two tables

I'm creating a report builder-like application with the intent on making an extremely novice friendly front end. The back end of the application will be managed by developers who can build a 'report model' which will specify which tables, fields…
Lex Webb
  • 2,772
  • 2
  • 21
  • 36