Skip to main content

Posts

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<<...

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)...