Generating Random Numbers is quite simple. Just use the class Random and method nextInt as :
new Random().nextInt(10);
This will generate a unique random number between 0 and 9 (both inclusive). Similarly if you want to generate a unique random number between a fixed length, say 10 to 100, use can use a code something like [...]
Archive for the ‘Algorithms’ Category
Java Code for generating Unique Random Numbers
C code for the Latin square problem
A Latin square is an n × n table filled with n different symbols in such a way that each symbol occurs exactly once in each row and exactly once in each column. Here is an example:
1 2 3
2 3 1
3 1 2
The C code for the implementation of the Latin Square problem is given below.
#include “stdio.h”
#define n 8
int main()
[...]
C code for Prim’s Algorithm
Prim’s algorithm is one of the two commonly used algorithms for finding a Minimum Spanning Tree. The coding of the other one, Kruskal algorithm has already been presented here. Here the C code for implementing this algorithm has been presented . The code operates on the Input File which can be downloaded and must be [...]
Bell Algorithm for Permutation
This Permutation algorithm is pretty simple. We have to swap the items in such a way that the order of consecutive swaps forms a series of inverted and straight bells, as shown in the figure :
This can be better understood by taking an example.
Lets say we have to find all the permutations of the numbers [...]
Improved MST Algorithm
Tired of studying the same 2 algorithms (Prism and Kruskal) for developing a Minimum Spanning Tree..? Here you can try a new algorithm developed by a computer science student. Pretty straight forward and simple.
The algorithm presented here uses greedy approach to the problem, since at every stage, it makes a choice that looks best at [...]

Posted in
Tags: 
