Skip to main content

Posts

Showing posts from 2019

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

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

7.OBST

File: /home/saiesh/ADS/Assignment No 7/ads7.cpp Page 1 of 2 #include<iostream> #define MAX 10 using namespace std; char idnt[7][10]; int i,j,k,n,m,r[10][10]; float p[MAX],q[MAX],w[10][10],c[10][10]; int find(int i,int j) { int min=2000,m,l; for(m=i+1;m<=j;m++) if(c[i][m-1]+c[m][j]<min) { min=c[i][m-1]+c[m][j]; l=m; } return l; } void print(int i,int j) { if(i>=j) return; if(r[i][r[i][j]-1]!=0) cout<<"\nLeft child of "<<idnt[r[i][j]]<<" is\t: "<<idnt[r[i][r[i] [j]-1]]; if(r[r[i][j]][j]!=0) cout<<"\nRight child of "<<idnt[r[i][j]]<<" is\t: "<<idnt[r[r[i] [j]][j]]; print(i,r[i][j]-1); print(r[i][j],j); return; } int main() { cout<<"\n\tOptimal Binary Search Tree\n"; cout<<"\nEnter the number of identifiers\t\t: "; cin>>n; for(i=1;i<=n;i++) { cout<<"Enter identifier "<<i<<"\t\t\t: "; cin>>idnt[i]; } cout

6.hash_ditionary

File: /home/saiesh/ADS/Assignment No 6/ads6.cpp #include<iostream> #include<stdlib.h> #include<string.h> #define MAX 10 using namespace std; int count=0; struct ht { int id; char name[MAX]; } rec[MAX],temp,tmp; class hashtable { public: hashtable(); int hashing(int); int insert(struct ht); void display(); void find(); }; hashtable::hashtable() { int i; for(i=0;i<MAX;i++) { rec[i].id=-1; strcpy(rec[i].name,"-"); } } int hashtable::hashing(int no) { int hv; hv=no%MAX; return hv; } int hashtable::insert(struct ht h) { int i,k; k=hashing(h.id); if(rec[k].id==-1) { rec[k].id=h.id; strcpy(rec[k].name,h.name); count++; } else { for(i=(k+1)%MAX;i<MAX;i=(i+1)%MAX) { if(rec[i].id==-1) { rec[i].id=h.id; strcpy(rec[i].name,h.name); count++; break; } } } return count; } Page 1 of 5File: /home/saiesh/ADS/Assignment No 6/ads6.cpp void hashtable::display() { if(count!=0) { cout<<"\n HASH TABLE"; cout<<"\nIndex\tName\tID\n"; for(int i=0

5.hash_telephone

File: /home/saiesh/ADS/Assignment No 5/ads5.cpp #include<iostream> #include<stdlib.h> #include<string.h> #define MAX 10 using namespace std; int count=0; struct ht { long int phone; char name[MAX]; } rec[MAX],temp,tmp; class hashtable { public: hashtable(); int hashing(int); int insert(struct ht); void display(); void find(); }; hashtable::hashtable() { int i; for(i=0;i<MAX;i++) { rec[i].phone=-1; strcpy(rec[i].name,"-"); } } int hashtable::hashing(int no) { int hv; hv=no%MAX; return hv; } int hashtable::insert(struct ht h) { int i,k,p; k=hashing(h.phone); if(rec[k].phone==-1) { rec[k].phone=h.phone; strcpy(rec[k].name,h.name); count++; } else { for(i=(k+1)%MAX;i<MAX;i=(i+1)%MAX) { if(rec[i].phone==-1) { rec[i].phone=h.phone; strcpy(rec[i].name,h.name); count++; break; } } } return count; } Page 1 of 5File: /home/saiesh/ADS/Assignment No 5/ads5.cpp void hashtable::display() { if(count!=0) { cout<<"\n HASH TABLE"; cout<<"\nIn

4.dijektra

File: /home/saiesh/ADS/Assignment No 4/ads4.cpp #include<iostream> #include<string> #define IN 9999 #define N 6 using namespace std; int n; int dijktra(int cost[N][N], int source, int target); int dijktra(int cost[N][N], int source, int target) { int dist[N],prev[N],selected[N]={0},i,m,min,start,d,j; for(i=1;i<=n;i++) { dist[i]=IN; prev[i]=-1; } start=source; selected[start]=1; dist[start]=0; while(selected[target]==0) { min=IN; m=0; for(i=1;i<=n;i++) { d=dist[start]+cost[start][i]; if(d<dist[i]&&selected[i]==0) { dist[i]=d; prev[i]=start; } else dist[i]=dist[i]; if(min>dist[i]&&selected[i]==0) { min=dist[i]; m=i; } } start=m; selected[start]=1; } cout<<"\nShortest path is: "<<target; i=target; while(prev[i]!=source) { cout<<" -> "<<prev[i]; i=prev[i]; } cout<<" -> "<<source; return dist[target]; } int main() { int cost[N][N],i,j,w,ch,co; char ans; int source,target,x,y; cou

3.prims

File: /home/saiesh/ADS/Assignment No 3/ads3.cpp Page 1 of 3 #include<iostream> #include<stdlib.h> using namespace std; class prims { private: int nodes; int w[10][10]; int visited[10]; public: void accept(); void prim(); }; void prims::accept() { int i,j; cout<<"\nHow many number of nodes do you want to accept? "; cin>>nodes; for(i=0;i<nodes;i++) { for(j=i+1;j<nodes;j++) { cout<<"\nEnter the value of ["<<i<<"]["<<j<<"]:\t"; cin>>w[i][j]; w[j][i]=w[i][j]; } } for(i=0;i<nodes;i++) { for(j=0;j<nodes;j++) { if(i==j) w[i][j]=0; } } for(i=0;i<nodes;i++) { cout<<"\n"; for(j=0;j<nodes;j++) cout<<"\t"<<w[i][j]; } } void prims::prim() { int i,j,totalcost=0,min=9999,k,l,m,st; cout<<"\nEnter the starting vertex: "; cin>>st; for(i=0;i<nodes;i++) visited[i]=0; visited[st]=1; for(j=0;j<nodes;j++) { if(w[st][j]!=0&&

2.BST_dictionary

File: /home/saiesh/ADS/Assignment No 2/ads2.cpp #include<iostream> #include<stdlib.h> #include<string.h> using namespace std; typedef struct node { char word[30]; char meaning[50]; node *left,*right; }bstnode; bstnode *root; class BST { public: BST() { root=NULL; } bstnode *getnode(); void create(); void inorder(bstnode *T); void comparison(bstnode *root); void update(bstnode *root); bstnode *deletenode(bstnode *root,char word[30]); }; bstnode *BST::getnode() { bstnode *temp; temp=new bstnode; cout<<"\nEnter the word:\t\t"; cin>>temp->word; cout<<"Enter the meaning:\t"; cin>>temp->meaning; temp->left=temp->right=NULL; return temp; } void BST::create() { char ch; bstnode *temp, *ptr; do { temp=getnode(); if(root==NULL) root=temp; else { ptr=root; while(1) { if(strcmp(temp->word,ptr->word)<0) { if(ptr->left==NULL) { ptr->left=temp; break; } else ptr=ptr->left; } else Page 1 of 7File: /home/saiesh

1.BST_operations

File: /home/saiesh/ADS/Assignment No 1/ads1.cpp #include<iostream> #include<stdlib.h> using namespace std; typedef struct node { int data; node *left,*right; }bstnode; bstnode *root; class BST { public: BST() { root=NULL; } bstnode *getnode(); void create(); int maxdepth(bstnode *root); void min(bstnode *T); void change(bstnode *root); bstnode *find(int x); void inorder(bstnode *T); }; bstnode *BST::getnode() { bstnode *temp; temp=new bstnode; cout<<"\nEnter the data:\t"; cin>>temp->data; temp->left=temp->right=NULL; return temp; } void BST::create() { char ans; bstnode *temp,*ptr; do { temp=getnode(); if(root==NULL) root=temp; else { ptr=root; while(1) { if(temp->data<ptr->data) { if(ptr->left==NULL) { ptr->left=temp; break; } else ptr=ptr->left; } else { if(ptr->right==NULL) { ptr->right=temp; Page 1 of 6File: /home/saiesh/ADS/Assignment No 1/ads1.cpp Page 2 of 6 break; } else ptr=ptr->right; } } } cout<<&qu

EEE

EEE Unit-1 DC Machines MCQ's MULTIPLE CHOICE QUESTIONS ON UNIT 1: DC MACHINES Edit 1.The sole purpose of a Commutator in a dc generator is to------- ((A))increase output voltage ((B)) reduce sparking at brushes ((C)) provide smoother output ((D)) convert the induced ac into dc Hide ! Answer : D 2.In a dc generator, the generated emf is directly proportional to the------ ((A)) field current ((B)) pole flux ((C)) number of armature parallel paths ((D)) number of dummy coils Hide ! Answer:B 3.An ideal dc generator has .......... voltage regulation. ((A))low ((B))zero ((C))positive ((D))negative Hide ! Answer:B 4.Which generator may have poorest voltage regulation? ((A))series ((B))shunt((C))compound ((D))high Hide ! Answer:A 5.Voltage equation of a dc motor is----- ((A)) V = Eb + IaRa ((B)) Eb = V + IaRa ((C))V = Eb /IaRa ((D))V = Eb + Ia2Ra Hide ! Answer: A 6.Which of the following motor has the constant speed? ((A))Series motor ((B))Shunt motor ((C))Cumulatively compound motor ((D)