| Current Path : /var/www/html/mmishra/profile1/test/CURRENT_one/new/ |
| Current File : /var/www/html/mmishra/profile1/test/CURRENT_one/new/wp.txt |
Sorting
Internal Sorting: the entire sort can be done in main memory, so that the number of elements is relatively small (less than a million). Sorts that cannot be performed in main memory and must be done on disk or tape .
1-There are several easy algorithms to sort in O(n2), such as insertion sort.
2-There is an algorithm, Shellsort, that is very simple to code, runs in o(n2), and is efficient in practice.
3-There are slightly more complicated O(nlog n) sorting algorithms.
4-Any general-purpose sorting algorithm requires Omega(nlog n) comparisons.
1-Insertion Sort:
Insertion sort consists of n - 1 passes. For pass p = 2 through n, insertion sort ensures that the elements in positions 1 through p are in sorted order.
Insertion sort makes use of the fact that elements in positions 1 through p - 1 are already known to be in sorted order.
Original 34 8 64 51 32 21 Positions Moved
----------------------------------------------------------
After p = 2 8 34 64 51 32 21 1
After p = 3 8 34 64 51 32 21 0
After p = 4 8 34 51 64 32 21 1
After p = 5 8 32 34 51 64 21 3
After p = 6 8 21 32 34 51 64 4
void insertion(int arr[],int n)
{
int j,key;
for(int i=1;i<n;++i)
{
key=arr[i];
for(j=i; key <arr[j-1] && j>0; j--)
{
arr[j]=arr[j-1];
}
arr[j]=key;
}
}
Because of the nested loops, each of which can take n iterations, insertion sort is O(n2). Furthermore, this bound is tight, because input in reverse order can actually achieve this bound.
On the other hand, if the input is presorted, the running time is O(n), because the test in the inner for loop always fails immediately. Indeed,
if the input is almost sorted insertion sort will run quickly.
___________________________________________
int temp = array[999999];
if( temp == value )
return (999999);
else
array[999999] = value;
for( i=0; array[i] != value; i++) ;
array[999999] = temp;
if( i == 999999) return -1;
return i;
User Management
/etc/group User account information.
/etc/passwd
/etc/shadow
/etc/bashrc bash system wide and per user init files.
/etc/profile
$HOME/.bashrc
$HOME/.bash_profile tcsh system wide and per user init files.
/etc/csh.cshrc
/etc/csh.login
$HOME/.cshrc
$HOME/.tcshrc
$HOME/.login
/etc/skel template files for new users.
/etc/default default for certain commands.
/etc/redhat-release
/etc/SuSE-release version (uname -a)