C Code for Selection Sort

Searching and sorting have been popular operations in elementry data structures. Although now a days many advanced sorting techniques are used to sort a set of data, the basic sorting methods are still popular and are the used frequently. Here C code for selection sort is given. The algorithm for selection sort is quite simple. In the first iteration, 1st element is compared against all the other elements (from array index 1 to array index n). In the second iteration 2nd element is compared with the elements from array index 2 to n. This process is repeated n-1 times.

The C code is as follows :


#include "stdio.h"

void main( )
{
	int arr[5] = { 25, 17, 31, 13, 2 } ;
	int i, j, temp ;
	for ( i = 0 ; i <= 3 ; i++ )
	{
		for ( j = i + 1 ; j <= 4 ; j++ )
		{
			if ( arr[i] > arr[j] )
			{
				temp = arr[i] ;
				arr[i] = arr[j] ;
				arr[j] = temp ;
			}
		}
	}

	printf ( "\n\nArray after sorting:\n") ;

	for ( i = 0 ; i <= 4 ; i++ )
		printf ( "%d\t", arr[i] ) ;
}

  • Share/Bookmark

ROILA, a New Spoken Language Designed for Robots

Eindhoven University of Technology researchers are developing the Robot Interaction Language (ROILA), a spoken language for robots that is meant to be easy for people to learn and easy for robots to understand. ROILA features simple, regular grammar and includes nouns, verbs, adverbs, adjectives, and pronouns.

Programming Geeks : ROILA a New Spoken Language Designed for Robots

ROILA uses an algorithm-generated vocabulary of about 850 words, which look like a combination of African languages, Dutch, and English. It has no irregularities, so word markers are used to indicate past and present tense.

The researchers say ROILA combines parts of the most successful natural and artificial languages. ROILA words are composed of phonemes that are shared among most human languages, and the word-creation algorithm makes the words sound as different from each other as possible.
View Full Article

  • Share/Bookmark

C code for Insertion Sort

Writing programs for sorting of a given set of numbers is one of the common programming tasks. Various types of sorting techniques like selection sort, inserting sort and quick sort are quite popular. Here C code for Insertion sort is being presented. The program is quite simple. Here, in each iteration, the elements are placed in their correct position. The algorithm has the complexity of O(n²)

#include "stdio.h"

void main( )
{
	int arr[5] = { 25, 17, 31, 13, 2 } ;
	int i, j, k, temp ;

	printf ( "Insertion sort.\n" ) ;
	printf ( "\nArray before sorting:\n") ;

	for ( i = 0 ; i <= 4 ; i++ )
		printf ( "%d\t", arr[i] ) ;

	for ( i = 1 ; i <= 4 ; i++ )
	{
		for ( j = 0 ; j < i ; j++ )
		{
			if ( arr[j] > arr[i] )
			{
				temp = arr[j] ;
				arr[j] = arr[i] ;

				for ( k = i ; k > j ; k-- )
					arr[k] = arr[k - 1] ;

				arr[k + 1] = temp ;
			}
		}
	}

	printf ( "\n\nArray after sorting:\n") ;

	for ( i = 0 ; i <= 4 ; i++ )
		printf ( "%d\t", arr[i] ) ;

}

  • Share/Bookmark

Google’s Do-It-Yourself App Creation Software

Google is bringing Android software development to the masses.

The company will offer a software tool, starting Monday, that is intended to make it easy for people to write applications for its Android smartphones.

The free software, called Google App Inventor for Android (http://appinventor.googlelabs.com/about/), has been under development for a year. User testing has been done mainly in schools with groups that included sixth graders, high school girls, nursing students and university undergraduates who are not computer science majors.

The thinking behind the initiative, Google said, is that as cellphones increasingly become the computers that people rely on most, users should be able to make applications themselves.

“The goal is to enable people to become creators, not just consumers, in this mobile world,” said Harold Abelson, a computer scientist at the Massachusetts Institute of Technology, who is on sabbatical at Google and led the project.
View Full Article

  • Share/Bookmark

Sorting algo with complexity O(n)

der ws a question in one of the competitive examinations…

where there was asked to insert an integer array and sort it using an algorithm whose complexity was O(n)…

help?

SOLUTION :
This might help : Radix Sort

  • Share/Bookmark
| Shop Free Cellular Phones at Bestincellphones.com. | Thanks to Best CD Rates, iCellPhoneDeals.com Offers Best Cell Phone Deals. and Incinerador De Grasa