data-structures Questions

14

Solved

A frozen set is a frozenset. A frozen list could be a tuple. What would a frozen dict be? An immutable, hashable dict. I guess it could be something like collections.namedtuple, but that is m...
Fahlband asked 24/4, 2010 at 7:19

7

What are some possible ways to implement a linked list in MATLAB? Note: I am asking this question for pedagogical value, not practical value. I realize that if you're actually rolling your own lin...
Ramah asked 12/9, 2009 at 0:31

5

This question can be easily solved in O(n + m) per query, however is this possible to answer such queries in better complexity with preprocessing better than O(n²) ? In tree it can be easily done...

33

Solved

What is the best way to implement a Stack and a Queue in JavaScript? I'm looking to do the shunting-yard algorithm and I'm going to need these data-structures.
Sestet asked 19/10, 2009 at 18:15

5

Solved

Is there a formula to calculate what the maximum and minimum height for an AVL tree, given a certain number of nodes? For example: Textbook question: What is the maximum/minimum height for an AVL ...
Hasbeen asked 11/6, 2015 at 0:2

4

Solved

I tried to find a graph data structure to reuse in C# without any success. Of course, I can borrow from data structure books but I want it to be more commercially practical(?) Also I would ap...
Decarbonize asked 23/9, 2011 at 17:42

3

Solved

I am trying to write java code to return list of Nodes in a tree. The tree looks like Node class is class Node{ String label; List<Node> children; } I am trying this way. But not able...
Respective asked 31/10, 2011 at 10:31

12

Solved

I just came around this weird discovery, in normal maths, n*logn would be lesser than n, because log n is usually less than 1. So why is O(nlog(n)) greater than O(n)? (ie why is nlogn considered to...
Lintwhite asked 8/6, 2019 at 12:34

15

Solved

I have an unsorted array, what is the best method to remove all the duplicates of an element if present? e.g: a[1,5,2,6,8,9,1,1,10,3,2,4,1,3,11,3] so after that operation the array should look ...
Liver asked 28/7, 2010 at 7:12

4

Solved

I know that one can detect cycles in direct graphs using DFS and BFS. I want to know whether we can detect cycles in directed graphs using Union-Find or not? If yes, then how? and If we can't, th...

5

Solved

I tried the following : 1) DFS, keeping track of level of each vertex in my DFS tree 2) Each time a back edge (x,y) is seen, I calculate cycle length = level[x] - level[y] + 1, and save it if it ...
Quartan asked 30/12, 2013 at 20:59

9

Solved

I heard the only difference between dynamic programming and back tracking is DP allows overlapping of sub problems, e.g. fib(n) = fib(n-1) + fib (n-2) Is it right? Are there any other difference...
Spiller asked 28/8, 2010 at 23:43

9

Solved

I need a data structure that always holds the n largest items inserted so far (in no particular order). So, if n is 3, we could have the following session where I insert a few numbers and the con...

4

Solved

How to check a deque's length in python? I don't see they provide deque.length in Python... http://docs.python.org/tutorial/datastructures.html from collections import deque queue = deque(["Er...
Mound asked 22/9, 2012 at 23:22

3

Solved

I encountered a problem and have tried many solutions, but none have worked. Given an array of numbers [3, 2, 16, 16, 15, 1, 2, 16, 16, 16, 15, 1, 2], I would like to discover the repeated sequence...

5

Solved

Binomial Heap has quite special design. Personally I don't think this design is intuitive. Although posts such as What is the difference between binary heaps and binomial heaps? talks about diff a...
Isoclinal asked 20/11, 2013 at 12:32

6

Solved

Has anyone of you ever implemented a Fibonacci-Heap? I did so a few years back, but it was several orders of magnitude slower than using array-based BinHeaps. Back then, I thought of it as a valua...

20

How can I implement a general tree in Python? Is there a built-in data structure for this?
Meadowlark asked 1/3, 2010 at 18:24

2

Solved

I just read the Rope article, and didn't find any balance condition for the rope. Does it means, that any binary tree with short strings in leaves, is a rope?
Contreras asked 30/3, 2012 at 12:27

6

Solved

The past few weeks I have been learning about iterators. I still do not understand the main difference between iterating through a link list and traversing through one. I know that traversing means...
Esdraelon asked 1/5, 2013 at 22:24

5

Suppose that there is a list with n elements, i.e. x = [23,25,3,45,67,89,67,45,4,6,...n]. What data structure and/or program would be most suitable for converting x to a list of sublists, with each...
Doud asked 29/12, 2023 at 4:53

5

Solved

As far as I know the time complexity between AVL trees and Binary Search Trees are the same in average case, with AVLs beating BSTs in worst case scenarios. This gives me a hint that AVLs are alway...

5

Solved

Here is an exercise in the Algorithm Design Manual. Consider the problem of determining whether a given undirected graph G = (V, E) contains a triangle or cycle of length 3. (a) Give an O(|V...
Single asked 17/4, 2012 at 14:30

4

Solved

I have a std::vector<std::string> m_vPaths; I iterate over this vector and call ::DeleteFile(strPath) as I go. If I successfully delete the file, I remove it from the vector. My questio...
Erhart asked 22/10, 2009 at 1:37

3

Solved

If we have a Type[], we can only store Type or its subtypes in it. The same goes for ArrayList. So why is it said that one is homogeneous while the other is not?
Microtome asked 18/4, 2016 at 17:24

© 2022 - 2024 — McMap. All rights reserved.