A set is a collection in which no element is repeated, which may be able to enumerate its elements according to an ordering criterion (an "ordered set") or retain no order (an "unordered set").

learn more… | top users | synonyms

2
votes
2answers
59 views

Find combination of sets which sum up to a specified result

Example input : A) 1, 2 B) 2, 8 C) 7, 8 Required Result : 8, 10 The output from the program with this input should be A + C. Few notes : We can only combine 2 sets. There must ...
3
votes
1answer
54 views

Return “support count” for a given itemset after searching a large list of transactions

Not having found a satisfactory association rules implementation in Python, I set out to code my own. The code below runs reasonably quickly, but the groceries dataset used for testing is peanuts ...
0
votes
2answers
57 views

Generate powerset in JS

I came across a mock interview question in which the candidate is asked to generate the powerset of a given set. The input set is represented as a unique array of integers. There was no solution ...
1
vote
1answer
112 views

Printing the power set of a given set of elements

Input: Set of elements (String) Output: Printing the elements of the power set of the given set ...
2
votes
3answers
136 views

Sorting a list by the modulus of 3

The input is an unsorted array of integers. The output should be an array of integers sorted based on the modulus of 3 (or any other number). It begins with all integers conforming to Integer % 3 == ...
2
votes
1answer
192 views

IEnumerable and Predicate sets in .NET

GitHub Repository Previously: Countable and uncountable sets in .NET (clean version). Thesis There is a full featured support of countable sets in .NET: ...
1
vote
0answers
58 views

Countable and uncountable sets in .NET (set operators, demo)

Up-to-date version: IEnumerable and Predicate Sets in .NET (Complete, Explained). Previously: Countable and uncountable sets in .NET (clean version). Disclaimer: Please do not interpret my attempts ...
7
votes
5answers
761 views

An ordered set in C#

I need a generic data structure that ensures that its elements are unique. C# has HashSet<T>, great! As it turns out, the elements have to stay in the order ...
2
votes
1answer
88 views

Countable and uncountable sets in .NET (clean version)

Sorry, it used to be some retired garbage in Countable and uncountable sets. Now and here it is clean. P.S. I would not like to say that this stuff is about to replace functional programming :) No, ...
3
votes
2answers
132 views

Countable and uncountable sets in .NET (IEnumerable and Predicate)

There is a full featured support of countable sets in .NET: IEnumerable<T>. What about uncountable sets; sets defined by predicate? How can they be ...
2
votes
1answer
47 views

DisjointSet with O(1) find and O(1) amortised union

Does this code outperform the common implementation with path-compression and union-by-rank? I'm still okay with a review. GitHub ...
3
votes
2answers
112 views

Determining if two Strings have common subtrings of a given length in Java

Problem: Given 2 strings, consider all the substrings within them of length len. Len will be 1 or more. Returns true if there are any such substrings which appear in both strings. Compute this ...
1
vote
0answers
105 views

Union Find implementation

I am trying to complete this challenge. The user should enter a sequence of instructions, = to link two numbers, and ? to query ...
4
votes
1answer
176 views

VERY simple C# Set implementation

This is not meant to solve any insane real world problems. I just want to make sure my Set logic is right and the code looks okay. It feels weird implementing it with a ...
3
votes
0answers
127 views

Conways Game of Life using unordered set of coordinates

Previously I had been using an array of bool(dead/live) to represent cells. I looked on code review to see how other people have implemented Conway's Game of Life. Someone in the comments of a post ...
1
vote
1answer
40 views

Haskell union list implementation pt 2

This is my revision from another post ...
3
votes
1answer
170 views

List union implementation

I'm trying to implement union from the standard Data.List library. I know it's reinventing the wheel, but reimplementing ...
3
votes
1answer
71 views

Improving Speeds of Tokenisation of large word list for distinct combinations

I'm having trouble with a current algorithm I'm writing that takes a corpa, a list of characters in sets (1 one or larger) with a frequency number attached to it. Against another list of character ...
2
votes
0answers
159 views

An AVL-tree based order statistic tree in Java

I have this java.util.Set implementation that is based on AVL-trees, which implies that the set is sorted. However, it provides two additional operations: ...
1
vote
0answers
69 views

Persistent set (Red black tree) - follow up

Follow up of this question Things I changed: Fixed some typos Renamed variables and method to more descriptive names.(Eliminated 1 letter variables) Added static method ...
2
votes
1answer
141 views

Persistent set (Red black tree)

This is a partially persistent data structure using a red black tree. It will copy \$O(lg(n))\$ items for each remove or add operation. ...
8
votes
3answers
929 views
3
votes
2answers
233 views

Get missing letters - TopCoder challenge

I'm working on a TopCoder problem which seeks to find the letters preventing an input sentence from being a pangram in all caps, alphabetical order. MissingLetters.h ...
3
votes
1answer
199 views

Duplicate integers in an array

Code shows duplicate values of integers in an array with indexes and the number of occurrences. Can you please critique my code and provide your thoughts on where I should improve my code? ...
5
votes
2answers
264 views

Find the rarest in a map

Write a method rarest that accepts a map whose keys are strings and whose values are integers as a parameter and returns the integer value that occurs the fewest times in the map. If there is a ...
2
votes
2answers
105 views

Immutable subclass of a Set class

If I'm creating an immutable class from an existing class, should I override methods that mutate the property or have an instance of it and write my own methods to read from the property? I have an ...
5
votes
3answers
610 views

Duplicate words in a text

Here is a simplified implementation to obtain the duplicate words in a text using lambda expressions. ...
3
votes
1answer
624 views

Calculate pairs in a Set (“Sherlock and Pairs” HackerRank challenge)

I have started reading clean code and want to improve my coding practices. Here is my attempt at solving an online puzzle. Please review the code and let me know how could I have written it better in ...
5
votes
1answer
603 views

Implementation of Set data type in Haskell

I'm an advanced beginner Haskell programmer. I implemented a set data type in Haskell and I wanted to find out if I made correct choices when writing it. Would there be a way to improve some of the ...
11
votes
3answers
376 views

“AI” chat program

I've thrown together this simple chat program, and while it works. I think it could certainly use some improvement. Here's how it works. Obtain user input by removing all punctuation from the input ...
6
votes
2answers
2k views

Sudoku Puzzle Solver

I have written a program to solve Sudoku puzzles as a (fun?) way to learn Python. It solves puzzles as a human would, using reasoning algorithms rather than brute force/backtracking, as I thought it ...
4
votes
4answers
125 views

Increase performance of a method which finds the element removed from an array

Imagine that you have a TreeSet of numbers, and you copy them into an array, but you remove one element of it. You want to know the element removed. ...
2
votes
1answer
86 views

Populate the list based on which datacenter code is running on

This is a follow on to : Efficiently detect datacenter based on server hostname and return the full path. I have a library which is running in different datacenters in production. I have three ...
2
votes
1answer
343 views

Off-line minimum using disjoint sets

The off-line minimum problem asks us to maintain a dynamic set T of elements from the domain (1..n) under the operation INSERT and EXTRACT-MIN. We are give a sequence S of n INSERT and m EXTRACT-...
2
votes
1answer
109 views

Dealing with input and output in Matlab

I just wrote a program which performed some elementary set operations as you can see below. It's the first time I have used input and output of text files so I am mainly looking for critique on that, ...
3
votes
3answers
827 views

Set Class Implementation ADT

Is the following functions implemented correctly for the set class? Please let me know if any changes need to be made. ...
12
votes
1answer
237 views

Chack miy spellang pleez

For my CS2 project, I am supposed to implement a spell-checker. It is supposed to follow the following: Prompt the user for the name of the file containing the dictionary of correctly ...
2
votes
2answers
203 views

A set of names and a request with asterisks

I have a set of names and a request with asterisks. An asterisk can be replaced with any letter. For example, there is a set of names: hasad, ahmed, fizo. And there are a few sample requests: hasad, ...
6
votes
3answers
740 views

“Set” your expectations low for this ADT

For my third assignment in CS2, I was given the following: A set is a special bag that does not allow duplicates. Specify each operation for a set of objects by stating its purpose, by describing ...
6
votes
1answer
67 views

Designing a Variable Set

In my application, I need to allow the user to store variables. Variables can only be of specific types, but I effectively handle all variables the same way no matter the type. I would also like to ...
6
votes
5answers
6k views

Number of distinct elements in an array

This is my solution to find the Number of distinct elements in an array. Is there away fast way to do this? It run-time is O(N). ...
8
votes
3answers
577 views

Two sets came to an intersection

Challenge: Print set intersections. Specifications: Your program should accept as its first argument a path to a filename. Each line in the file is a test case. Each test case contain two ...
2
votes
2answers
167 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): ...
0
votes
1answer
109 views

Java class: for getOrder, getData, updateData operation

Problem Statement : Design a class for three operations for given set of integers : ...
3
votes
1answer
89 views

Calculating set difference of lists with or without intermediate variables

Which form of the method do you find more readable? Version with local variables: ...
5
votes
4answers
328 views

Faster Way of Comparing Generic Sets

The following extension method is the limiting factor in the performance of an application I am developing, according to Visual Studio 2012 Performance Analysis profiler. Is there a faster way to ...
1
vote
1answer
67 views

Multiset implementation in Ruby -Take 2

This is a follow up to question. I fixed the issues mentioned in the answer as far as my understanding. The union and intersection now return new object instances with new implementation. I also wrote ...
2
votes
1answer
153 views

Multiset implementation in Ruby

I am trying to implement the Wikipedia definition of a MultiSet and need feedback on the implementation. ...
2
votes
1answer
597 views

Finding the subsets of a set

I am trying to write a procedure that finds the power set of a list, that is, the set of 2n subsets (where n is the number of elements in the list). I simply quite find all the subsets. I feel my code ...
2
votes
1answer
86 views

Iterate over items in a set of dicts

I'm using the following code to initialise 8 I/O-ports (i.e. GPIO pins on a Raspberry Pi). That's 4 x 2 pins, each duo controls a switch, A to D, and each duo consists of a pin for On and a pin for ...