Popular Posts

Thursday, January 16, 2014

Short descriptions of algoritms

Some short descriptions on each of the algorithms:-

Bubble Sort:-
Exchange two adjacent elements if they are out of order. Repeat until array is sorted. This is a slow algorithm.

 Selection Sort:-
Find the largest element in the array, and put it in the proper place. Repeat until array is sorted. This is also slow.

 Insertion Sort:-
Scan successive elements for out of order item, then insert the item in the proper place. Sort small array fast, big array very slowly.

Quick sort:-
Partition array into two segments. The first segment all elements are less than or equal to the pivot value. The second segment all elements are greater or equal to the pivot value. Sort the two segments recursively. Quicksort is fastest on average, but sometimes unbalanced partitions can lead to very slow sorting.

Merge sort:-
Start from two sorted runs of length 1, merge into a single run of twice the length. Repeat until a single sorted run is left. Mergesort needs N/2 extra buffer. Performance is second place on average, with quite good speed on nearly sorted array. Mergesort is stable in that two elements that are equally ranked in the array will not have their relative positions flipped.

Heap sort:-
Form a tree with parent of the tree being larger than its children. Remove the parent from the tree successively. On average, Heapsort is third place in speed. Heapsort does not need extra buffer, and performance is not sensitive to initial distributions.

Shell sort:-
Sort every Nth element in an array using insertion sort. Repeat using smaller N values, until N = 1. On average, Shellsort is fourth place in speed. Shellsort may sort some distributions slowly.

Combo Sort:-
Sorting algorithms can be mixed and matched to yield the desired properties. We want fast average performance, good worst case performance, and no large extra storage requirement. We can achieve the goal by starting with the Quicksort (fastest on average). We modify Quicksort by sorting small partitions by using Insertion Sort (best with small partition). If we detect two partitions are badly balanced, we sort the larger partition by Heapsort (good worst case performance). Of course we cannot undo the bad partitions, but we can stop the possible degenerate case from continuing to generate bad partitions.

Monday, July 1, 2013

How Linux Boots


You now know the physical structure of a Linux system, what the kernel is, and how to work with processes. This chapter teaches you how the system starts (boots) — that is, how the kernel gets into memory and how the regular system processes get started.

As it turns out, there isn't much to the boot process:

  1. A boot loader finds the kernel image on the disk, loads it into memory, and starts it.
  2. The kernel initializes the devices and its drivers.
  3. The kernel mounts the root filesystem.
  4. The kernel starts a program called init.
  5. init sets the rest of the processes in motion.
  6. The last processes that init starts as part of the boot sequence allow you to log in.
Identifying each stage of the boot process is invaluable in fixing boot problems and understanding the system as a whole. To start, zero in on the boot loader, which is the initial screen or prompt you get after the computer does its power-on self-test, asking which operating system to run. After you make a choice, the boot loader runs the Linux kernel, handing control of the system to the kernel.
There is a detailed discussion of the kernel which explains the role of the kernel, and , but this chapter covers the kernel initialization stage, the stage when the kernel prints a bunch of messages about the hardware present on the system. The kernel starts init just after it displays a message proclaiming that the kernel has mounted the root filesystem:
VFS: Mounted root (ext2 filesystem) readonly.

Soon after, you will see a message about init starting, followed by system service startup messages, and finally you get a login prompt of some sort.
Note 
On Red Hat Linux, the init note is especially obvious, because it "welcomes" you to "Red Hat Linux." All messages thereafter show success or failure in brackets at the right-hand side of the screen.

Saturday, January 19, 2013

Linux Commands

Table A-1: File Management Commands
Command
Description
chgrp
Changes a file's group
chmod
Changes a file's permissions
chown
Changes a file's user ownership
cp
Copies a file
dd
Converts and copies
df
Displays disk usage statistics
du
Displays directory space usage
file
Identifies a file type
find
Searches for a file
ln
Creates a symbolic or hard link
ls
Lists files
mkdir
Creates a directory
mkfifo
Creates a named pipe
mknod
Creates a special file
mv
Renames or moves a file
rm
Removes a file
touch
Creates a file or updates a file's timestamp

IT JAM Syllabus 2013

IT JAM Computer Applications Syllabus 2013
IIT JAM syllabus for Computer Applications ( CA ) test paper comprises of Mathematics, Computer awareness and Analytical ability and General awareness and they will be in the ration 4 : 2 : 1.


IIT JAM Mathematics Syllabus
Algebra : Set theory and its simple applications. Basic concepts of groups, fields and vector spaces.
Matrices : Rank of a matrix. Existence and uniqueness of solution of a system of linear equations. Eigenvalues and Eigenvectors. Inverse of a matrix by elementary transformations.
Differential Calculus : Differentiation, Partial differentiation, Taylor series and approximate calculations. Maxima and minima of functions of one and two variables.
Integral Calculus : Single and multiple integration. Definite integrals, Change of order and change of variables. Applications to evaluation of area, surface and volume.

Differential Equations : First order differential equations, linear differential equations of higher order with constant coefficients.
Vector Algebra : Addition, subtraction, dot product, cross product, triple product and their applications.
Numerical Analysis : Solution of non – linear equations using iterative methods. Interpolation ( Lagrange’s formula and Newton’s formula for equidistant points ). Numerical differentiation and integration ( Trapezoidal and Simpson’s rules ).
Probability : Basic concepts of probability theory. Binomial and Poisson distributions.
Linear Programming : Formulation and its graphical solution for two variable problems.


IIT JAM Computer Awareness
Elements of computers. Number systems. Basic electronic gates. Boolean algebra. Flip – Flops. Algorithmic approach to solve problems. Fundamentals of C language.


Analytical Ability and General Awareness of IIT JAM
Simple questions will be asked to test the analytical ability and general awareness of candidates.

Eligibility Criteria for IT



Eligibility Criteria for IT :
1. Open only to the students with following degrees
- Category 1: BE / B Tech / ME / M Tech / MCA / M Sc (Computer Science / IT / Software Engg)
- Category 2: B Sc / BCA / M Sc (except Computer Science / IT / Software Engg)
2. Year of graduation: 2011 batch only
3. Consistent First Class (over 60%) in X, XII, UG and PG (if applicable)
4. No outstanding arrears
5. Candidates with degrees through correspondence/ part-time courses are not eligible to apply
6. Good interpersonal, analytical and communication skills

 
Eligibility Criteria for IT IS :
1. Open only to the students with following degrees
- BSC – Computer Science/Computer Technology/ IT /Maths/Statistics/Electronics and BCA
- MSC – Maths/Statistics/Electronics
2. Year of graduation: 2010 or 2011 batch only
3. Consistent First Class (over 60%) in X, XII, and UG
4. Candidates holding correspondence or part time degrees are not eligible to apply
5. Good interpersonal and excellent communication skills
6. Willingness to work in shifts (including night shifts)
7. Willing to work at any Cognizant location across India

 
Eligibility Criteria for BPO :
1. Any Arts & Science graduate except BSC – IT/CS, Electronics, Maths & Statistics
2. Hotel Management & MBA graduates are also eligible
3. Year of Graduation: 2010 or 2011 batch only
4. Consistency of 50% in X, XII, and UG
5. Good verbal and excellent communication skills
6. Willingness to work in shifts (including night shifts

Wednesday, October 3, 2012

Programs of C++



                                                                         INDEX

Sr.No
                                 Topic 
Signature
1.
Program for sorting list of array elements

2.
Program for searching list of elements

3.
Program for call by reference

4.
Program for arithmetic operator overloading

5.
Program for postfix increment operator overloading

6.
Program for function overloading

7.
Program for constructor with explicit call and implicit call

8.
Program to implement class and object

9.
Program for polymorphism

10.
Program for copy constructor


 Programs of C++ 



//Program for sorting list of elements

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[40],n,i,j,k,temp,min,p;
cout<<"Enter number of elements:";
cin>>n;
cout<<"Enter the elements one by one:";
for(i=1;i<=n;i++)
{
cin>>a[i];
}
cout<<"list of array is:\n";
for(i=1;i<=n;i++)
{
cout<<a[i]<<"\n";
}
for(k=1;k<=n-1;k++)
{
  min=a[k];
  p=k;
  for(i=k+1;i<=n;i++)
  {
  if(min>a[i])
   {
   min=a[i];
   p=i;
   }
  }
  if(p!=k)
  {
  temp=a[k];
  a[k]=a[p];
  a[p]=temp;
  }
}
cout<<"Sorted array is:";

for(i=1;i<=n;i++)
{
cout<<"\n"<<a[i];
}
getch();
}
Output:
Enter number of elements : 5
Enter the elements one by one : 23
34
54
655
67
List of array is:
23
34
54
655
67
Sorted array is:
23
34
54
67
655

 2.
//Program for searching list of array elements

#include<iostream.h>
#include<conio.h>
void main()
{
int i,n,a[10],search,loc;
clrscr();
cout<<"Enter number of elements:\n";
cin>>n;
cout<<"Enter array elements:\n";
for(i=1;i<=n;i++)
{
cin>>a[i];
}
cout<<"Enter the element to be searched:";
cin>>search;
i=1;
while(i<=n)
{
 if(a[i]==search)
 {
 loc=i;
 cout<<"Element is found at position:"<<loc;
 goto end;
 }
 else
 {
 i=i+1;
 }
 }
 cout<<"Element not found";
 end:
 getch();
 }

Output:
Enter number of elements:
4
Enter array elements:
3
4
76
7
Enter the element to be searched:3
Element is found at position:1
 
3.

//Program for call by reference

#include<iostream.h>
#include<conio.h>
void swap(int &x, int &y);
void main()
{
int a,b;
clrscr();
cout<<"Enter two values:\n" ;
cin>>a>>b;
cout<<"value before exchange:";
cout<<"\nvalue of A is:"<<a;
cout<<"\nvalue of B is:"<<b;
swap(a,b);
cout<<"\nThe exchanged value are:";
cout<<"\nvalue of A is:"<<a;
cout<<"\nvalue of B is:"<<b;
getch();
}
void swap(int &x,int &y)
{
int temp;
temp=x;
x=y;
y=temp;
}

Output:
Enter two values:
34
56
Value before exchange:
Value of A is: 34
Value of B is: 56
The exchanged value are:
Value of A is: 56
Value of B is: 34


4.

//Program for arithmetic operator overloading

#include<iostream.h>
#include<conio.h>
class sample
{
float a,b;
public:
sample() {};
sample(float x, float y)
{
a=x;
b=y;
}
sample operator+(sample);
void display(void)
{
cout<<"a="<<a<<"\n";
cout<<"b="<<b<<"\n";
}
};
sample sample :: operator+(sample c)
{
sample temp;
temp.a = a+c.a;
temp.b = b+c.b;
return(temp);
}
void main()
{
sample x,y,z;
x = sample(1.5 ,4.5);
y = sample(6.25 ,3.5);
clrscr();
z = x+y;
cout<<"first object \n";
x.display();
cout<<"second object\n";
y.display();
cout<<"sum of objects\n";
z.display();
getch();
}




Output:
first object
a = 1.5
b = 4.5
second object
a = 6.25
b = 3.5
sum of objects
a = 7.75
b = 8

 

5.

//Program for postfix increment operator

#include<iostream.h>
#include<conio.h>
class complex
{
int real,img;
public:
complex(){};
complex(int a,int b)
{
real=a;
img=b;
}
void display()
{
cout<<real<<"+"<<img<<"i\n";
}
complex operator++(int);
};
complex complex::operator++(int x)
{
real++;
img++;
return *this;
}
void main()
{
clrscr();
complex c(5,10);
c++;
c.display();
c++;
c.display();
getch();
}


Output:
6+11i
7+12i

6.

//Program to function overloading

#include<iostream.h>
#include<conio.h>
void mul(int);
void mul(int,int);
void main()
{
clrscr();
mul(10);
mul(10,20);
getch();
}
void mul(int a)
{
int i;
cout<<"table of 10 is:\n";
for (i=1;i<=10;i++)
{
cout<<i*a<<"\n";
}
}
void mul(int a,int b)
{
int z;
z=a*b;
cout<<"multiplication of 10 and 20 is:\n"<<z;
}


Output:
table of 10 is:
10
20
30
40
50
60
70
80
90
100
multiplication of 10 and 20 is:
200
 

7.

//Program to implement class and object

#include<iostream.h>
#include<conio.h>
class sample
{
 int a,b,c;
 public:
 void getdata()
 {
 cout<<"enter two numbers:";
 cin>>a>>b;
 }
 void sum()
 {
 c=a+b;
 }
 void putdata()
 {
 cout<<"\na="<<a;
 cout<<"\nb="<<b;
 cout<<"\nc="<<c;
 }
};
void main()
{
sample s1;
clrscr();
s1.getdata();
s1.sum();
s1.putdata();
getch();
}


Output:
Enter two number:23
43

a=23
b=43
c=66

8.

//Program for copy constructor

#include<iostream.h>
#include<conio.h>
class sample
{
int a,b;
public:
       sample()
       {
       a=0;
       b=0;
       }
       sample(sample &i);
       void display(void)
       {
       cout<<"a= " <<a<<"b= "<<b<<"\n";
       }
 };
 sample::sample(sample &i)
 {
 a=i.a;
 b=i.b;
 }
 void main()
 {
 sample s1,s2(s1);
 clrscr();
 cout<<"First object\n";
 s1.display();
 cout<<"Second object\n";
 s2.display();
 cout<<"Third object\n" ;
 sample s3=s2;
 s3.display();
 getch();
 }


Output:
First object
a=0 b=0
Second object
a=0 b=0
Third object
a=0 b=0
 

9.

//Program for polymorphism

#include<iostream.h>
#include<conio.h>
class sample
{
  int a;
 public:
  sample()
  {
  a=10;
  }
  virtual void display()
  {
   cout<<"a="<<a<<"\n";
  }
};
class derived :public sample
{
 int b;
public:
 derived()
 {
 b=20;
 }
 void display()
 {
  cout<<"b="<<b<<"\n";
 }
};
void main()
{
 sample s;
 derived*ptr;
 ptr=(derived*)&s;
 clrscr();
 ptr->display();

 derived d;
 ptr=&d;
 ptr->display();
 getch();
}

Output:
a=10
b=20

10.

//Program for constructor with implicit call and explicit call

#include<iostream.h>
#include<conio.h>
class sample
{
int a,b;
public:
sample(int i,int j);
void display(void);
}
sample :: sample(int i,int j)
{
a=i;
b=j;
}
void sample::display()
{
cout<<"a=" <<a<<" b="<<b<<"\n";
}
 void main()
 {
 sample c(5,10);
 clrscr();
 c.display();
 sample d=sample(3,9);
 d.display();
 getch();
}


Output:
a=5 b=10
a=3 b=9