data-structures Questions

13

Consider: Node reverse(Node head) { Node previous = null; Node current = head; Node forward; while (current != null) { forward = current.next; current.next = previous; previous = current; ...

3

Solved

Following is the Suffix array and LCP array information for string MISSISSIPPI. I know that LCP gives information about the lenght of the longest common prefix between str[i - 1] and str[i]. How Do...
Scratch asked 3/1, 2012 at 4:22

4

I'm looking for a set data structure to use in Excel VBA. What I found so far is Scripting.Dictionary which seems to be a map. Is there also something like a set in VBA? Basically I'm looking for...
Consistent asked 18/1, 2017 at 13:8

2

Solved

I have built a d dimensional KD-Tree. I want to do range search on this tree. Wikipedia mentions range search in KD-Trees, but doesn't talk about implementation/algorithm in any way. Can someone pl...
Multifoil asked 20/12, 2019 at 13:42

3

Solved

I'm implementing segment tree from an array of data, and I also want to maintaining the max/min of the tree while updating a range of data. Here is my initial approach following this tutorial http:...
Fcc asked 5/8, 2012 at 6:21

5

How can we prove that the update and query operations on a segment tree (http://letuskode.blogspot.in/2013/01/segtrees.html) (not to be confused with an interval tree) are O(log n)? I thought of a...
Otherworldly asked 28/11, 2014 at 9:1

8

Solved

We are used to saying that HashMap get/put operations are O(1). However it depends on the hash implementation. The default object hash is actually the internal address in the JVM heap. Are we sure ...
Elate asked 29/12, 2010 at 11:22

22

Solved

I have a data structure which essentially amounts to a nested dictionary. Let's say it looks like this: {'new jersey': {'mercer county': {'plumbers': 3, 'programmers': 81}, 'middlesex county': {...

9

Solved

I want to append characters to a string, but want to make sure all the letters in the final list are unique. Example: "aaabcabccd" → "abcd" Now of course I have two solutions in my mind. One is u...
Pervade asked 16/12, 2012 at 15:33

29

Solved

Say you have a linked list structure in Java. It's made up of Nodes: class Node { Node next; // some user data } and each Node points to the next node, except for the last Node, which has null...
Stickseed asked 18/4, 2010 at 17:8

7

Solved

This is an interesting question that I came across in a coding challenge: There are k cities and n days. A travel agent is going to show you city k on day n. You're supposed to find the minimum nu...
Order asked 29/10, 2017 at 13:49

13

Solved

I am thinking about poker hand (5 cards) evaluation in Java. Now I am looking for simplicity and clarity rather than performance and efficiency. I probably can write a "naive" algorithm but it requ...
Soidisant asked 28/4, 2012 at 13:27

11

How can one check if a key/value pair exists in a Dictionary<TKey,TValue>? I'm able to check if a key or value exist, using ContainsKey and ContainsValue, but I'm unsure of how to check if a ...
Lsd asked 10/3, 2012 at 21:33

13

Solved

I'm baffled that I can't find a quick answer to this. I'm essentially looking for a datastructure in Java which implements the java.util.List interface, but which stores its members in a sorted ord...
Melinite asked 27/10, 2010 at 9:12

4

I am trying to implement a scenegraph-like data structure in Rust. I would like an equivalent to this C++ code expressed in safe Rust: struct Node { Node* parent; // should be mutable, and nullab...
Danby asked 22/3, 2016 at 23:32

6

AVL and Red-black trees are both self-balancing except Red and black color in the nodes. What's the main reason for choosing Red black trees instead of AVL trees? What are the applications of Red b...
Cointon asked 13/12, 2012 at 4:17

7

Solved

What are some of the uses of circular buffer? What are the benefits of using a circular buffer? is it an alternative to double linked list?
Hexapod asked 31/3, 2010 at 14:13

8

Solved

I can't seem to find a definitive answer for this, I'm trying to do some elementary proofs on heaps but here's what's throwing me off a little bit: Is an empty tree valid? If so, what is its heigh...
Viridissa asked 5/2, 2010 at 19:24

3

Solved

Why is mergesort considered "the way to go" when sorting lists and not quicksort? I heard this in a lecture that I watched online, and saw it in a couple of websites.
Subsidize asked 2/10, 2011 at 23:23

5

Solved

get() removes and returns an item from Queue in Python. import queue q = queue.Queue() # Here q.put("Apple") q.put("Orange") q.put("Banana") print(q.get()) print(q....
Kendre asked 22/5, 2013 at 7:49

3

If I have a data structure like this: struct Point { x: i32, y: i32, } impl Point { fn setX(&mut self, x: i32) -> &mut Point { self.x = x; self } } Is it possible to iterate t...
Lignocellulose asked 22/5, 2015 at 22:56

3

Solved

In python there's a built-in heapq algorithm that gives you push, pop, nlargest, nsmallest... etc that you can apply to lists. However, there's also the queue.PriorityQueue class that seems to supp...
Gamut asked 2/5, 2016 at 21:6

8

Solved

I need a Stack data structure for my use case. I should be able to push items into the data structure and I only want to retrieve the last item from the Stack. The JavaDoc for Stack says : A mor...
Benedikt asked 21/9, 2012 at 5:38

10

Solved

How is an AVL tree different from a B-tree?
Draftee asked 29/4, 2010 at 4:0

14

Solved

Can anyone please explain the difference between binary tree and binary search tree with an example?
Burnie asked 17/6, 2011 at 0:42

© 2022 - 2024 — McMap. All rights reserved.