• Algorithms, OOPs Lab Programs

    Posted on April 18th, 2011

    Written by Geek

    Tags

    ALGORITHM TO IMPLEMENT BINARY SEARCH TREE

    BINARY SEARCH TREE INSERTION ALGORITHM 1. t = newnode 2. t info = n breve 3. t left = t right = NULL breve breve 4. If (root = NULL) root = t return 5. ptr = root 6. Repeat step 7 until ptr = NULL 7. If (ptr info > n) breve If (ptr left [...]

    Print Friendly
  • Algorithms, OOPs Lab Programs

    Posted on April 18th, 2011

    Written by Geek

    Tags

    , , , ,

    ALGORITHM TO SORT ARRAY USING QUICK SORT

    1. low =1, high = h, key a[(l+h)/2] 2. Repeat through step 7 while (low <= high) 3. Repeat step 4 while (a[low] < key) 4. low = low +1 5. Repeat step 6 while (a[high] > key) 6. high = high- 1 7. If (low <= high) a) temp = a[low] b) a[low] = [...]

    Print Friendly
  • Algorithms, OOPs Lab Programs

    Posted on April 13th, 2011

    Written by Geek

    Tags

    ALGORITHM TO SEARCH AN ELEMENT USING BINARY SEARCH

    Steps to follow low = l ,high = n Repeat step 3 to 5 while low <= high mid = (low + high) If a[ mid] = x Print “found at mid” Return If (a[ mid] < x) low = mid + 1 Else High = mid – I Print “x not found” Exit // [...]

    Print Friendly
  • Algorithms, OOPs Lab Programs

    Posted on April 12th, 2011

    Written by Geek

    Tags

    ALGORITHM TO SEARCH AN ELEMENT USING LINEAR SEARCH

    Steps for Algorithm to search an element using linear search 1. Set k := 1 & loc : = 0 2. Repeat step 3 & 4 while loc: = 0 &k < = n 3. If (item = data[k]) loc: = k Else K= k + 1 4. If loc: = 0 ,then Print “no. [...]

    Print Friendly
  • OOPs Lab Programs

    Posted on April 7th, 2011

    Written by Geek

    Tags

    FIND THE TOTAL SCORE OF STUDENT USING PACKAGES

    //In file student.java   package pack1; import pack2.*; public class student implements sports { public int mark1,mark2,t; public void marks() { mark1=80; mark2=75; } public void total() { t=mark1+mark2+point; } public void display() { System.out.println("Mark1="+mark1); System.out.println("Mark2="+mark2); System.out.println("Score="+point); System.out.println("Total="+t); } }   //In file sports.java   package pack2; public interface sports { static int point=77; } [...]

    Print Friendly
  • OOPs Lab Programs

    Posted on April 7th, 2011

    Written by Geek

    Tags

    CALCULATE AREA OF RECTANGLE AND CIRCLE USING INTERFACES

    interface Area { final static float pi=3.14F; float compute(float x,float y); }   class Rectangle implements Area { public float compute(float x,float y) { return x*y; } }   class Circle implements Area { public float compute(float x,float y) {   return x*x*pi; } }   class Test { public static void main(String args[]) { [...]

    Print Friendly
  • OOPs Lab Programs

    Posted on April 7th, 2011

    Written by Geek

    Tags

    DISPLAY THE NUMBER OF DAYS USING OPERATOR OVERLOADING

      #include<iostream.h> #include<conio.h> class Date { public: int date,month,year; void getdate(int x, int y,int z) { date=x; month=y; year=z; } void display() { cout<<date<<"."<<month<<"."<<year; } int checkdate(); int operator-(Date); int senddate(int,int,int); int sendmonth(int,int); int sendyear(int); }; int Date::sendyear(int y) { if(y%4==0) return 366; else return 365; } int Date:: sendmonth(int m,int y) { if((m%2==1 && [...]

    Print Friendly
  • OOPs Lab Programs

    Posted on April 7th, 2011

    Written by Geek

    Tags

    ADDITION AND SUBTRACTION OF TWO POLYNOMIAL OBJECTS USING OPERATOR OVERLOADING

      #include<iostream.h> #include<conio.h> class polynomial { public: int order,ordinates[10]; polynomial(int,int a[]); polynomial(); friend polynomial sum(polynomial,polynomial); friend polynomial diff(polynomial,polynomial); friend ostream &operator <<(ostream&, polynomial&); }; ostream &operator <<(ostream &dout,polynomial &b) { int x=b.order; for(int i=0;i<b.order;i++) { if(b.ordinates[i]==0) goto l; if(b.ordinates[i]>0) dout<<"+"<<b.ordinates[i]; else dout<<b.ordinates[i]; dout<<"(x^"; cout<<(x-i); dout<<")"; l: } if(b.ordinates[x]==0) goto m; if(b.ordinates[x]>=0) dout<<"+"<<b.ordinates[x]; else dout<<b.ordinates[x]; m: [...]

    Print Friendly
  • OOPs Lab Programs

    Posted on April 7th, 2011

    Written by Geek

    Tags

    MANAGING BANK ACCOUNT USING INHERITANCE CONCEPT

      #include<iostream.h> #include<conio.h> class account { char *name; int acnum; int type; public: void getdata(char *s,int n,int t) { name=s; acnum=n; type=t; } void display_account() { cout<<"\n\tCustomer’s Name: "<<name; cout<<"\n\tCustomer’s Acc.no: "<<acnum; cout<<"\n\tCustomer Type: "<<type; if(type==1) cout<<" Current"; else cout<<" Savings"; } }; class current:public account { int bal,deposit,withdrawal; public: void get_bal(int x) { bal=x; [...]

    Print Friendly
  • OOPs Lab Programs

    Posted on April 7th, 2011

    Written by Geek

    Tags

    AREA OF TRIANGLE AND RECTANGLE USING INHERITANCE AND VIRTUAL FUNCTION

      #include<iostream.h> #include<conio.h> class shape { public: float x,y; void get_data(float a,float b) { x=a; y=b; } virtual void dispay_area() { } }; class triangle:public shape { float area1; public: void area() { area1=x*y/2; } void display_area() { cout<<"\tArea of triangle is: "< <area1; } }; class rectangle:public shape { float area2; public: void area() [...]

    Print Friendly
  • Older Posts Yeah! There are more posts, check them out.

    Newer Posts Yeah! There are more posts, check them out.

Switch to our mobile site

PHVsPjwvdWw+