Skip to main content

Posts

13.interface

File: /home/student/saiesh/ADS/Assignment No 13/ads13_2A.java package pack; interface ip { public public public public } void void void void add(int sub(int mul(int div(int a, a, a, a, int int int int b); b); b); b); public class A implements ip { public void add(int a, int b) { System.out.println("Addition is\t\t: "+(a+b)); } public void sub(int a,int b) { System.out.println("Substraction is\t\t: "+(a-b)); } public void mul(int a, int b) { System.out.println("Multiplication is\t: "+(a*b)); } public void div(int a, int b) { System.out.println("Division is\t\t: "+(a/b)); } } Page 1 of 1 ....................... File: /home/student/saiesh/ADS/Assignment No 13/ads13_2B.java package mypack; import pack.*; import java.util.Scanner; public class B { public static void main(String arg[]) { A obj= new A(); Scanner sc=new Scanner(System.in); System.out.println("\nEnter first number\t: "); int a=sc.nextInt(); System.out.println("\nEnter
Recent posts

12.SCOP rules and class specifiers

File: /home/saiesh/ADS/Assignment No 12/ads12_1.java //Instance Variable import java.io.*; public class ads12_1 { public String name; private double salary; public ads12_1 (String empName) { name=empName; } public void setSalary(double empSal) { salary=empSal; } public void printEmp() { System.out.println("Name\t: "+name); System.out.println("Salary\t: "+salary); } public static void main(String[] args) { ads12_1 empOne=new ads12_1("Saiesh"); empOne.setSalary(10000); empOne.printEmp(); } } /* saiesh@saiesh :~$ javac ads12_1.java saiesh@saiesh :~$ java ads12_1 Name : Saiesh Salary : 10000.0 saiesh@saiesh :~$ */ OUTPUT Page 1 of 1 .................... File: /home/saiesh/ADS/Assignment No 12/ads12_2.java Page 1 of 1 //Static Variable import java.io.*; public class ads12_2 { private static double salary; public static final String DEPARTMENT = "Development"; public static void main(String args[]) { salary=1000; System.out.println(DEPARTMENT+"

11.java_heap

File: /home/saiesh/ADS/Assignment No 11/ads11.java Page 1 of 2 import java.util.Scanner; public class ads11 { private static int N; public static void sort(int arr[]) { heapify(arr); for(int i=N;i>0;i--) { swap(arr,0,i); N=N-1; maxheap(arr,0); } } public static void heapify(int arr[]) { N=arr.length-1; for(int i=N/2;i>=0;i--) maxheap(arr,i); } public static void maxheap(int arr[],int i) { int left=2*i; int right=2*i+1; int max=i; if(left<=N&&arr[left]>arr[i]) max=left; if(right<=N&&arr[right]>arr[max]) max=right; if(max!=i) { swap(arr,i,max); maxheap(arr,max); } } public static void swap(int arr[],int i,int j) { int temp; temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.println("\t\tHeap Sort Test"); int i,n; System.out.print("\nEnter number of integer elements\t:"); n=scan.nextInt(); int arr[]=new int[n]; System.out.print("Enter "+n+"

10.file

File: /home/saiesh/ADS/Assignment No 10/ads10.cpp Page 1 of 5 #include<iostream> #include<iomanip> #include<cstring> #include<fstream> #include<stdlib.h> using namespace std; class empclass { typedef struct employee { int empid; int salary; char name[30]; }rec; typedef struct index { int empid; int position; }indrec; rec records; indrec indrecords; public: empclass(); void create(); void display(); void addrec(); void delrec(); void modrec(); }; empclass::empclass() { strcpy(records.name,"-"); records.empid=-1; records.salary=-1; } void empclass::create() { int i,n; char ans; fstream seqfile; fstream indexfile; seqfile.open("emp.dat",ios::in|ios::out|ios::binary); indexfile.open("ind.dat",ios::in|ios::out|ios::binary); indexfile.seekg(0,ios::beg); seqfile.seekg(0,ios::beg); cout<<"\nHow many records do you want to enter? "; cin>>n; for(i=0;i<n;i++) { cout<<"\nID\t: "; cin>>record

MP Practicals

1.Positive Negative 2.overlapping Non overlaping 3.HEX To BCD 4.Successive Addition method/Add-and-Shift method 6.GDTR (Global Descriptor Table Register)/IDTR (Interrupt Descriptor Table Register 7.BUBBLE SORT 8.Commands ----- ;1. Copy ;2. Type ;3. Delete 9.Factorial Program 11.Mean is ;Standard Deviation is ;Variance is  

9.heap

File: /home/saiesh/ADS/Assignment No 9/ads9.cpp #include<iostream> #include<stdlib.h> using namespace std; class heap { int i,j,temp; public: void accept(int a[20],int n); void display(int *a,int n); void build_maxheap(int *a,int n); void build_minheap(int *a,int n); void max_heapify(int *a,int i,int n); void min_heapify(int *a,int i,int n); }; void heap::accept(int marks[20],int n) { for(i=1;i<=n;i++) { cout<<"Enter the marks for roll number "<<i<<"\t: "; cin>>marks[i]; } cout<<"\nEntered marks are\t\t\t: "; for(i=1;i<=n;i++) { cout<<marks[i]<<"\t"; } } void heap::build_maxheap(int *a,int n) { for(i=n/2;i>=1;i--) { max_heapify(a,i,n); } } void heap::build_minheap(int *a,int n) { for(i=n/2;i>=1;i--) { min_heapify(a,i,n); } } void heap::max_heapify(int *a,int i,int n) { temp=a[i]; j=2*i; while(j<=n) { if(j<n&&a[j+1]>a[j]) j=j+1; if(temp>a[j]) break; else if(temp

8.AVL

File: /home/saiesh/ADS/Assignment No 8/ads8.cpp #include<iostream> #include<stdlib.h> #include<string.h> using namespace std; typedef struct node { char word[30]; char meaning[50]; node *left, *right; }avlnode; avlnode *root; class avltree { public: avltree() { root=NULL; } avlnode* getnode(); int height(avlnode*); int diff(avlnode *T); avlnode *rr(avlnode *T); avlnode *ll(avlnode *T); avlnode *lr(avlnode *T); avlnode *rl(avlnode *T); avlnode *balance(avlnode *T); avlnode *insert(avlnode *root,avlnode *T); void display(avlnode*, int); void comparison(avlnode *root); void update(avlnode *root); }; avlnode*avltree::getnode() { avlnode *temp; temp=new avlnode; cout<<"\nEnter the word:\t\t"; cin>>temp->word; cout<<"Enter the meaning:\t"; cin>>temp->meaning; temp->left=temp->right=NULL; return temp; } int avltree::height(avlnode *temp) { int h=0,l,r,maxh; if(temp!=NULL) { l=height(temp->left); r=height(temp->ri