A data structure is a way of organizing data in a fashion that allows particular properties of that data to be queried and/or updated efficiently.

learn more… | top users | synonyms (1)

2
votes
0answers
14 views

Trie Implementation in Java

I am trying to implement a Trie class in Java which just supports insertion and searching operation up until now. I think it works perfectly on the several examples ...
5
votes
0answers
26 views

Memory Segmentation Simulation

I recently have been working on a project to simulate segmentation in memory. I wanted to create everything from scratch; not use pre-built data structures. I create a memory object that allows for ...
2
votes
0answers
44 views

Linked list order reverse program efficiency

Here is my function which convert linked list in the following order: Example: Inputs: 1->2->3->4->5->6->7->8->NULL and k = 3 Output: 3->2->1->6->5->4->8->7->NULL. Code: ...
5
votes
3answers
77 views

Check if a binary tree is balanced

Looking for code-review, optimizations and best practices. This question is attributed to geeksforgeeks. NOTE: Please help me verify space complexity, as I am creating ...
-4
votes
0answers
22 views

How to draw a simple hollow asterisk rectangle of rows & column provided by the console in C#? [closed]

Could someone advise me on a simple way to implement Hollow Rectangles in C#? I have been able to make a rectangle and the hollow rectangle programs I've looked at either contained or arrays or were ...
0
votes
0answers
19 views

C++: Implement a Deque using a Doubly Linked List [closed]

My assignment is to implement a deque data structure through the use of a Doubly Linked List. For some reason an "unhandled exception" occurs in Visual Studio whenever I try to run it, and the output ...
2
votes
1answer
41 views

Improving time complexity of cheapest travel route algorithm

Below is the code to find the cheapest route for a passenger. stationsUnexplored is a Queue to which stations are added and ...
5
votes
0answers
41 views

BiDirectional Dictionary (and its Mutable friend can come too)

I've attempted to implement a 1-to-1 dictionary in Objective-C. I'm probably missing some convenient methods that one might commonly want to use. These are both declared in the same ...
2
votes
2answers
154 views

Is there some way of taking advantage of code reuse in this example?

I am implementing a set, using an array as the backend. Here is how I declared it (and some method implementations): ...
3
votes
1answer
33 views

Disjoint-set data structure in Python 3

Inspired by this question, I decided to implement a Disjoint-set data structure in Python 3. I mainly followed this description for understanding the algorithm (but did not do the optimizations for ...
2
votes
2answers
88 views

Bag data structure (a set that can store multiple copies of items)

I am trying to make my class a bit cleaner, especially some of its methods like Count, __add__, ...
1
vote
4answers
70 views

Coupon collector

This is a coupon collector code to analyze the running time. I need some suggestions on improving the running times of this code. I have used the data structure dictionary, but is there any other data ...
4
votes
2answers
82 views

Inefficient hash map operation provokes OutOfMemory: Java heap space error

I know I can increase the size of the heap but that seems like a poor solution. This program runs correctly on small files but when run on large data sets it crashes with the OutOfMemory: Java heap ...
2
votes
3answers
399 views

Finding duplicates in two sorted arrays

This is an interview question from here. Specifically, the second asked for a function that took in two sorted arrays of integers with no duplicate values within a single array and which returned an ...
5
votes
2answers
112 views

Data structure to count occurrences of entries

I would love to hear any thoughtful suggestions on how to improve my programming style in order to be more understandable. Listed below is a sample of my code which I wrote in Eclipse: ...
4
votes
1answer
58 views

Design/reiterate or code reuse for linked list

This is what my class hierarchy looks like. I have an abstract superclass, AbstractLinkedMyList, that contains common operations for both sorted and unsorted linked ...
15
votes
1answer
259 views

Order a delicious pie here

For a quick summary: I've created this internal web application, and I've hit a point where I can really see the mess I've made. I need some help separating the logic, the view, and the data. More ...
2
votes
1answer
58 views

Rewriting linked list function without a NULL variable

This is how my LinkedList class looks like in PHP. I am trying to figure out if I can rewrite my reverse_list_recursively() ...
3
votes
3answers
78 views

Implementing a singly LinkedList and IList interface

I have implemented a LinkedList in C#. What would you change/make better? What naming conventions are misused? What would you add? Some of my ideas are to make it ...
3
votes
1answer
56 views

Least common ancestor (LCA) in a binary tree

Find the LCA in binary tree, where a node is also its own ancestor. This question is attributed to GeeksForGeeks. I'm looking for code review, optimizations and best practices. ...
3
votes
1answer
78 views

Finding the shortest substring containing keywords

Problem: Write a function that takes a String document and a String[] keywords and returns the smallest substring of ...
7
votes
4answers
472 views

Recursive binary search tree - follow-up

This is a follow-up to Recursive binary search tree changes: Used raw pointers rather than std::unique_ptr const correctness Made variable names more beautiful implemented at() How can I improve ...
4
votes
3answers
449 views

Preorder, inorder, postorder for tree in C++11

Please review my code for preorder, inorder and postorder of a tree. I am using C++11 (or wanted to use), so let me know if anything is deviating from the C++11 standard. ...
1
vote
0answers
41 views

Hash Table Implemented by Javascript

I recently tried to implement a simple hash table using Javascript. Could anyone help me review my implementation? ...
2
votes
2answers
96 views

Counting a cycle

An interview question I got - Each element of an int array points to the another element, eventually creating a cycle. Starting at ...
4
votes
1answer
68 views

Circular linked list in C

Let me know if it seems right to you and if anything can be optimized. My concern is that I'm unsure if circular linked lists are supposed to have a tail. I've implemented it just using a head. Is ...
2
votes
2answers
62 views

Doubly linked list code in C

Let me know if it seems right to you and if anything can be optimized. ...
3
votes
1answer
80 views

Circular queue implementation using two regions

Inspired by the "bip buffer", I coded a fixed-size circular queue that uses two regions (two pairs of begin/end pointers) to account for the wrap-around. The main goal of this design was to simplify ...
3
votes
0answers
67 views

Binary heap with O(1) lookup and O(log n) change key

I needed a priority queue that allowed efficient searching and changing of keys. I tried std::priority_queue, but the interface was extremely limiting. Not being ...
5
votes
2answers
113 views

Find if a word with wildcard exists in dictionary [closed]

This is a question from a phone interview I had. The question was in 2 parts: a. find("cat") -> T/F suggest a data structure to find is if a word exists in a large dictionary, how will one node ...
8
votes
1answer
111 views

Networking in iOS Swift

This piece of code is working - It gives me a lot of JSON back, which I have yet to parse, but I'd like to show my code here first to get tips on how to improve what I already have: ...
2
votes
1answer
146 views

Graph implementation adjacency list 1.0

Please note the following: All edges are directed Removal of edges/nodges is not implemented yet A user of the class Graph can never (hopefully) access a ...
5
votes
1answer
97 views

Find all the paths of tree that add to a input value

This code is attributed to Stack Overflow itself here. The path which adds to the sum, which need not be starting from the root, not be ending at the leaf, i.e. a path can be between root and a leaf. ...
6
votes
3answers
83 views

Removing duplicates without using a temporary buffer

This question is from Cracking the Coding Interview and in this question they have asked to solve without using temporary buffer. I have used Iterator interface. Can I use it or need to re-implement ...
8
votes
2answers
111 views

Simple Linked Hash Map in JS (node/browser)

I needed a simple data structure to cache the most recent few directory contents for this project I was working on. I thought a Linked Hash Map would be the right approach since we will cache only one ...
6
votes
2answers
258 views

HashTable implementation

I have been trying to implement the Hash Table function in Java and here is what I came up with. I would just like to get an opinion on this work. Would there be a better way or any improvement to ...
0
votes
1answer
82 views

Implementing a stack using a simple array, dynamic array and linked list

I have implemented a stack using simple array, dynamic array and linked list. I am requesting a review of this code. Interface for stack: ...
3
votes
1answer
87 views

Deepest node in tree

I have written two classes, one to represent the tree and a Util class to get the deepest node from the tree. Can you please review the code? Below is the class ...
3
votes
1answer
73 views

AVL tree implementation in C

I have an assignment. I need to write an AVL tree. This is what I have written so far. It works on all of my tests, but suddenly fails in checking system with TL(time limit exceeded). Personally I ...
4
votes
3answers
179 views

Custom SkipList implementation in Java

I recently studied SkipList and thought i would create one on my own. This implementation uses a 2 layer Skip list where the size of the support list is roughly square root of the size of the original ...
2
votes
1answer
36 views

Manipulate JSON data from the client with JavaScript

I am making an application in which the user has the ability to add, remove, and edit JSON data through DOM interaction. I have created a working JavaScript-only prototype that accepts certain ...
3
votes
3answers
197 views

AVL tree for inserting and searching

I have made an AVL tree. It works and does what it needs to do. I only need it to insert and search. I am comparing how long it takes to load and search a dictionary file in relation to other various ...
3
votes
0answers
74 views

Djkistra shortest path implementation for adjacency list represented graph

Please review the implementation of Djkistra algorithms. Points on which I have doubt: My Graph doesn't have any ID for nodes. Nodes are accessed based on their ...
4
votes
1answer
114 views

School which registers students by preferred courses

The point of the application is to create a school, create courses for that school, create students and register them to the school, assigning them courses based off the courses they prefer. There ...
2
votes
1answer
84 views

File input and sorting averages with movies

So far I have Java code that will: take in two .csv files store each line as a string in a string array split it into a 2D string array where a comma would act as the separator sum the number found ...
3
votes
0answers
69 views

Treap with implicit keys

I implemented an implicit treap and tested it a little. It works fine but I'd like to know if there are ways to improve/simplify things and/or if some parts are incorrect. Later, I'll augment code to ...
0
votes
1answer
67 views

Pure fixed length queue

I am modeling an infectious disease with a fixed incubation period. I chose a queue to keep track of when people become symptomatic. I imagined using some operations like so: ...
11
votes
3answers
533 views

Implementation of an Stack without Linked Lists in C

I'm a beginning C programmer. As an exercise, I have attempted to implement a stack of strings in C. This is my first real exercise working with pointers. I looked at some other similar posts on here, ...
2
votes
0answers
66 views

Binary Index tree optimization

I have written code for binary index tree. My problem is there are many functions based on the binary index tree the function stores the sum of element within a given range of binary index tree and my ...
0
votes
0answers
63 views

Freeing a binary tree data structure in C

I have this function that I hope to be a good alternative to the recursive (thus performance expensive) approach. ...