Recursive implementation of the binary python search tree

I'm trying to implement Binary Search tree in python using recursion. I got trapped in some infinite recursions happening in my program.I'm making recursive calls to the function RecursBST by passing address and the data until the top traverse down t

List _Global_ in Java

I am developing a java program for class, and I have some restrictions that are killing me. I have to read a file and save its words on a list, and then keep that list so I can take words out of it. I have to read the file and select n words out of t

Pointers to other structures in a structure

My lecturer has presented the following piece of code, with an insufficient explanation of what it represents. typedef struct _s { int value; struct _s *next; } STACKITEM; STACKITEM *stack = NULL; I understand what pointers and structures are. Howeve

What data structure should I use to manage multi-value data?

I started working on an investing project in java and I need a good data-structure to meet its requirements. I've seen some solutions here to a bit similar questions, but with different requirements. My requirements are as follow: A Company object ha

Table with consecutive numbers - Algorithm

I am trying to answer the following question: given a sorted array with some sequenced numbers and some non-sequenced numbers, write an algorithm that obtains a pair {start, end} for each group of consecutive numbers. Consecutive numbers have differe

Add only unique items to a list from another list

I am creating a service that returns lists of articles from an XML feed. I am trying to find a better way to update the list of articles currently stored in my program whenever the client code calls for an update. I have a variable named articleHisto

Insert in a doubly linked list

I am trying to insert into a doubly linked list. I am then trying to print the list in both forward and reverse direction. I have created a head node and I am trying to insert another one, but I am unable to do so. The program shows a runtime error.

Can we use the dijkstra algorithm to find cycles

Can we use Dijkstra's algorithm to find cycles??? 1) Negative cycles 2) Positive cycles If we can what are the changes we have to do?1) Dijkstra's doesn't work on graphs with negative edges because you can (possibly) find a minimum distance of negati

Loop in a binary tree represented as an adjacency list

I attained an interview where I was asked a question as below: You are given with parent -----> child relationships i.e. N1 ---> N2 where N1 is the parent of N2. This is nothing but representing a binary tree in adjacency list form. So I had to find

Automatic correction algorithm

I want to implement the following in C++: 1) Check whether the given word exists in a dictionary. The dictionary file is a huge file; consider 100MB or 3-4 Million words. 2) Suggest corrections for the incorrect word. 3) Autocomplete feature. My Appr

conformable variable length structure in C ++

In standard C you can end a struct with an array of size 0 and then over allocate it to add a variable length dimension to the array: struct var { int a; int b[]; } struct var * x=malloc(sizeof(var+27*sizeof(int))); How can you do that in C++ in a st

What is the best data structure to use for type query?

I am in the process of making a game, and in that process I have come across a bit of a problem. I have many different types of game elements. These are all of type Entity. There are many types of Entities, including ones that are visible and need to

Are JSON and XML comparable?

I heard someone state that "JSON is the same as XML." Are JSON and XML comparable? What are the major similarities and differences of each? There are a few StackOverflow Q&As which touch on comparing JSON and XML [1] [2] [3] [4] [5] [6] [7],

Implementing a balanced binary search tree?

I have implemented a binary search tree and I want to add more functionality in its insertion function to make it a self-balancing tree. I am coding in C#. Can anybody please suggest me good tutorials or links on this? I did some searches and found s

How to create a graph from this data structure?

I took this data structure from this A* tutorial: public interface IHasNeighbours<N> { IEnumerable<N> Neighbours { get; } } public class Path<TNode> : IEnumerable<TNode> { public TNode LastStep { get; private set; } public Path<

Find a binary tree and print valuable children

So I have spent many sleepless nights the last two weeks trying to work on what I thought would be a simple program: I am trying to create a Binary Tree from a list of integers in a specific file. The numbers are inserted into a binary tree. I then p

Does std :: multiset guarantee insertion order?

I have a std::multiset which stores elements of class A. I have provided my own implementation of operator< for this class. My question is if I insert two equivalent objects into this multiset is their order guaranteed? For example, first I insert a

Store a set of numbers in an efficient data structure

I have a buckets of numbers e.g. - 1 to 4, 5 to 15, 16 to 21, 22 to 34,.... I have roughly 600,000 such buckets. The range of numbers that fall in each of the bucket varies. I need to store these buckets in a suitable data structure so that the looku

What are algorithms and data structures in simple terms?

I currently work with PHP and Ruby on Rails as a web developer. My question is why would I need to know algorithms and data structures? Do I need to learn C, C++ or Java first? What are the practical benefits of knowing algorithms and data structures

Transform the map with multiple values ​​to the tree?

Given a randomly distributed set of keys, with each key mapped to a set of values, how would you transform it into multiple trees? Example Data Set NB2 => {NC2 ND2} ND1 => {NG1 NH1} NA1 => {NB1} NB1 => {NC1 ND1 NE1} NA2 => {NB2} NC1 => {

What is a linked quad list?

I'm currently working on implementing a list-type structure at work, and I need it to be crazy effective. In my search for effective data structures I stumbled across a patent for a quad liked list, and this sparked my interest enough to make me forg