by Dinesh Thakur Category: array

Algorithm for Insertion Sort:

Here 'a' is an array of elements and 'n' represents the number of elements in the array 'a'

step 1: Initialize j= 1

step 2: repeat through step-8 while(j<n)

step 3: set item =a[j]

 
by Dinesh Thakur Category: array

Algorithm for Quick Sort:

Here 'a' is an array of elements and 'first' and 'last' represent the first index and last index of the array 'a' Perform the following steps only if(first<last).

step 1: Set i=first

step 2: Set j=last+l

step 3: Set k=first

 
by Dinesh Thakur Category: array

Algorithm for Bubble Sort:

step 1: read num

step 2: create an integer array a[] of size num

step 3: set flag =1

step 4: initialize i=0

step 5: repeat through step-11 while (i <n) and flag=l

step 6: Reset flag=0

 
by Dinesh Thakur Category: array

Algorithm for Removing duplicate elements from Array:

step 1: read y

step 2: create two integer array a[],b[] of size y

step 3: initialize c=0

step 4: repeat through step-6 while c less than a.length

step 5: read a[c]

step 6: c=c+1

step 7: initialize c=0

 
by Dinesh Thakur Category: array

Algorithm for Sum and Average the Elements:

step 1: set sum=0

step 2: read arr_size

step 3: create an integer array arr[] of size arr_size

step 4: initialize i=0

 
by Dinesh Thakur Category: array

Algorithm for Largest Number in an Array:

 

step 1: set big=0,small=0

step 2: read arr_size

step 3: create an integer array a[] of size arr_size

step 4: initialize x=0

step 5: repeat through step-7 while x less than a.length

step 6: read a[x]

 
by Dinesh Thakur Category: array

Algorithm for SortinganArray:

step 1: set temp=0

step 2: read arr_size

step 3: create an integer array a[] of size arr_size

step 4: initialize i=0

step 5: repeat through step-11 while i less than a.length

step 6: read a[i]

 
by Dinesh Thakur Category: array

Algorithm for Ones Present Inputted Array:

step 1: set arr_size,j, count as three static variables of integer type

step 2: read arr_size

step 3: create an integer array arr[] of size arr_size

step 4: initialize i=0 

 
by Dinesh Thakur Category: array

Here is the Java Example for Even-Odd pairs within that number:

 
by Dinesh Thakur Category: array

Explanation of Math.pow():

Pow()method is a static method of math class present in java.lang package.

This method takes two double type argument and returns the value if the 1st argument which is raised to the power of the 2nd argument.



 
by Dinesh Thakur Category: array

Algorithm for Convert Decimal integer to Binary Number:
step 1: set i=0
step 2: read num
step 3: create two integer arrays a[],b[] of size 20
step 4: repeat through step- 7 while num greater than 0

 
by Dinesh Thakur Category: array

Algorithm for Convert decimal integer to octal Number:

step 1: set r=0, i=0

step 2: create two integer arrays a[],b[] of size 10

step 3: read num

 
by Dinesh Thakur Category: array

Arrays Definition: Perhaps one of the most important of all concepts that you need to learn to be effective is the array. Until now, we have looked at variables that hold just one value – the ints hold one number and the strings hold one text string. Arrays are used when we want to hold two or more values, perhaps a list. Arrays can be thought as columns in a spreadsheet – a spreadsheet can have one, or it can have many columns.  

 
by Dinesh Thakur Category: array

Perhaps one of the most important of all concepts that you need to learn in order  to be effective is the array. Until now, we have looked at variables that hold just one  value – the ints hold one number and the strings hold one text string. Arrays are  used when we want to hold two or more values, perhaps a list. Arrays can be  thought as columns in a spreadsheet – a spreadsheet can have one or it can have  many columns.

 

Page 5 of 5



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles