Sorting 50+-digit numbers in array

I have array of strings containing 50+-digit numbers. I need to convert them to real-world integers and order them in asceding. It works when I have numbers with different size number of digits, but in this case where all numbers having same size num...
more »

2017-02-21 22:02 (3) Answers

Algorithm to create subgroups of people

we are looking for an algorithm that could help us creating subgroups of people. I'll explain it better with an example: We have a group of 5 students, let's call them A, B, C, D, E. Given a number (call it n) smaller than the number of students (&l...
more »

2017-02-21 07:02 (1) Answers

Sort List of Lists of Lists Python

I have a List of Lists of Lists in python. I need to sort the highest level of lists based on one of the values in the lowest levels. For a toy model, my list is created first with list small, which is a list containing lists with three items each:...
more »

2017-02-20 21:02 (1) Answers

Counting the number of inversions in merge sort

I have implemented a merge sort and, as well as sorting, I would like it to compute the number of inversions in the original array. Below is my attempt at implementing it, which for some reason doesn't compute the number of inversions correctly. F...
more »

2017-02-19 16:02 (2) Answers

Bubblesort algorithm with Function Pointers in C

I need a code that sorts an array of structs in ascending order by name or age using the bubblesort algorithm. I read all the elements and I understand the part of sorting. The problem is that I should only declare one bubblesort algorithm to be abl...
more »

2017-02-19 11:02 (3) Answers

Sorting arraylist with mergesort vs custom sort

I am writing a program which has to be able to sort up to 1 billion random Squares. I wrote a small example program below that creates a random ArrayList of Squares and then sorts it with two different methods. When I was looking for an efficient me...
more »

2017-02-16 12:02 (3) Answers

Exact amount of comparisions in Insertion Sort

I want to get number of permutations of {1, ..., n} for which Insertion Sort does exactly n(n-1)/2 comparisions. For example, for {1, 2, 3, 4} we got (4, 3, 2, 1), (3, 4, 2, 1), (4, 2, 3, 1) etc. - for all of them InsertionSort does 4*3/2 = 6 compari...
more »

2017-02-14 16:02 (2) Answers

Incorrect PageRank calculation result

I referred to PageRank - Wikipedia and computed PageRank algebraically with the following equation, but I got the different result from nx.pagerank_numpy. For instance (image from Wikipedia), I got, # 'A', 'B', 'C', 'D', 'E', 'F' [[ 0.028] [...
more »

2017-02-14 11:02 (1) Answers

Create a cache for DNS system using B -TREES

I've created a D.N.S cache using B-Trees , and in every node the value I keep is the I.P , list of authorities and the TTL . Now I want to delete from B-Tree the value which TTL expires , while continuously caching. So what do you think is the best i...
more »

2017-02-13 22:02 (0) Answers

How to sort binary array in linear time?

http://www.techiedelight.com/sort-binary-array-linear-time/ Linear time means that we have to traverse the array only one time but according to the solution here, we will first traverse the array to find the number of zeros, and then we traverse it ...
more »

2017-02-12 14:02 (6) Answers

What is wrong with my QuickSort Implementation

I tried implementing QuickSort off the top of my head for practice but I am getting out of bounds exception: 6 during compilation. I thought I properly used the setter method to assign array but it seems something is still wrong... Below is my code:...
more »

2017-02-11 01:02 (1) Answers

cache aware compare and rank algorithm

A coworker has been optimizing a compare and rank algorithm that works with 256-byte data structures. Using C++, he says he can compare 100 million billion such 256-byte structures per second on his 3.x ghz workstation - but he can't do anything with...
more »

2017-02-09 23:02 (0) Answers

Sort in multi-dimensional arrays in javascript

I have a multi array object in javascript [["A","F","A","H","F","F"],["F","A","A","F","F","H"]] I want obtain the following using some sorting algorithm [["A","A","A","H","A","F"],["F","F","F","F","F","H"]] The letters that are not in "A" and "...
more »

2017-02-09 11:02 (4) Answers

Lempel-Ziv-Welch decompression non-existent index

I have an implementation off the LZW compression/decompression algorithm and for the most part have it squared away. However, I have encountered a problem with one of the files that I am testing. Below is the text for said file #include "bits.h" in...
more »

2017-02-09 08:02 (1) Answers

php password_hash (problems when store in db)

I've been reading about password hash functions and it's said: use a salt to make harder the hacker's work, use a height cost algorithm, etc I've found this password_hash function but... it returns this (letters are an example to explain) AAAACCCSSS...
more »

2017-02-08 09:02 (3) Answers

How to partition linked list around minimum value

I am trying to perform a selection sort on a linked list using recursion and I am having some trouble partitioning my linked list around the node with the smallest value on each pass through my recursive sort function. I am trying to get the node wit...
more »

2017-02-07 16:02 (1) Answers

Implementing minimax algorithm in Javascript

As a personal exercise I'm trying to implement a minimax based tic-tac-toe game. I've been studying examples in a variety of languages I have found online. My implementation is at a point where it seems like its working but then the AI loses in certa...
more »

2017-02-06 08:02 (1) Answers