JS Study Group: Algorithms

• September 23, 2013 · 8:00 PM

Every other week we will be getting together to solve one large or a series of small algorithm puzzles in pairs or small groups. This is a highly interactive and supportive group to explore our understanding of Javascript and different algorithm concepts. We welcome all levels of JS experience!

Typical Agenda

8:00-8:10 - icebreaker/introduction/announcements
8:10-8:20 - present and discuss the algorithm(s)
8:20-9:15 - pair off and solve algorithm(s)
9:15-9:30ish - discuss solutions as a group

• A former member

Can we ask our own problems next week? Can keep it theoretical!

September 23, 2013

• Collen J.

QuickSort Sorting Algorithm: http://en.wikipedia.org/wiki/Quicksort

Here is working JavaScript code for the quickSort() algorithm:

var quickSort = function(data) { if(data.length <= 1) {
return data;
}

var pivot = data.splice(Math.floor(data.length / 2),1); var left = [], right = [];

data.forEach(function(value) {
(value < pivot ? left : right).push(value);
});

return quickSort(left).concat(pivot).concat(quickSort(right));
};

September 23, 2013

• Peter H.

var RadixSort = function (list) {
var getDigit = function(number, index) {
return (Math.floor(number / (Math.pow(10,index)) % 10));
} var generateBuckets = function() {
var buckets = [];
for (var i = 0; i < 10; i++) {
buckets.push([]);
} return buckets;
} var digit = 0;
var oldbuckets = generateBuckets();
var newbuckets = generateBuckets();
oldbuckets[1] = list; while (oldbuckets[0].length != list.length) {
for (var bucket = 0; bucket < 10; bucket++) {
for (var i = 0; i < oldbuckets[bucket].length; i++) {
var value = oldbuckets[bucket][i];
newbuckets[getDigit(value, digit)].push(value);
} } digit++;
oldbuckets = newbuckets;
newbuckets = generateBuckets();
} return oldbuckets[0];
};

September 23, 2013

• Peter H.

Selection Sort!

var SelectionSort = function (list) {
for (var i = 0; i < list.length - 1; i++) {
var min = list[i];
var mindex = i;
for (var j = i; j < list.length; j++) {
if (list[j] < min) {
min = list[j];
mindex = j;
} }
list[mindex] = list[i];
list[i] = min;
} return list;
};

September 23, 2013

• Gregory H.

If you are wait listed please come this week anyways!!

September 23, 2013

• A former member

Would love to discuss an open problem I have: How to deal cards from a deck in multiple simultaneous games without ever dealing a repeat. It's a N player game with some interesting constraints.

September 23, 2013

• A former member

I propose we revisit last week's stable marriage problem. It would be fun to come up with more solutions to the problem and compare them with visualization.

https://en.wikipedia.org/wiki/Stable_marriage_problem

September 10, 2013

38 went

• Sam
• A former member
• A former member
• A former member
• A former member
• A former member
• A former member
• A former member
• A former member

San Francisco, CA

Founded Feb 25, 2013

People in this Meetup are also in:

• Bay Area Software Engineers (BASE)

5,646 Software Engineers

2,211 Pythonistas

• Silicon Valley Entrepreneurs & Startups

18,765 Founders & Dreamers

• Meteor SF Bay Area

2,191 Meteorites

1,701 Flames

• The San Francisco Django Meetup Group

2,125 Djangonauts