Archive for May, 2009

File Structure ( FS ) Lab Program 12 ( 6th Semester Information Science)

// May 31st, 2009 // Comments // Old

Program 12 : Write a C++ program to reclaim the free space resulting from the deletion of records using linked lists.

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream.h>
#include<fstream.h>
#include<new.h>

class node
{
public: char name[20];
char usn[20];
node *link;
};

node *first=NULL;

void writeFile()
{
node *p;
char buffer[100];
fstream out;
out.open(“student.txt”, ios::out);
if(!out)
{
cout<<“n Unable to open the file student.txt in out mode”;
getch();
exit(0);
}
p=first;
while(p!=NULL)
{
strcpy(buffer,p->name);
strcat(buffer,”|”);
strcat(buffer,p->usn);
strcat(buffer,”n”);
out<<buffer;
p=p->link;
}
}

void display()
{
node *p;
if(first==NULL)
{
cout<<“nList is empty”;
return;
}
p=first;
while(p!=NULL)
{
cout<<“|”<<p->name<<” “<<p->usn<<“|”<<“->”;
p=p->link;
}
}

void Insert()    //Insert the record at the rear end
{
char name[20],usn[15];
node *p,*q;
cout<<“n Enter name = “; cin>>name;
cout<<“nEnter usn   = “; cin>>usn;
p=new node;
strcpy(p->name,name);
strcpy(p->usn,usn);
p->link=NULL;
if(first==NULL)
{
first=p;
writeFile();
display();    //display the record on the screen
return;
}
for(q=first; q->link!=NULL; q=q->link)
{
;
}
q->link=p;
writeFile(); //writing the record to the file
display();   //display the records to the screen.
}

void Delete()
{
char usn[15];
node *curr,*prev,*del;
if(first==NULL)
{
printf(“nThe list is empty. Deletion is not possible”);
return;
}
cout<<“nEnter the usn to be deleted = “; cin>>usn;
if(strcmp(first->usn,usn)==0)
{
cout<<“n Record deleted”;
del = first;
delete del;
first=first->link;
writeFile();
return;
}
prev=NULL;
curr=first;
while( ( strcmp(curr->usn,usn) != 0 ) && curr!=NULL)
{
prev=curr;
curr=curr->link;
}
if(curr == NULL)
{
cout<<“nThe student with usn “<<usn<<” is not present”;
return;
}
prev->link = curr->link;
writeFile();
display();   //display the records to the screen
}

void main()
{
int ch;
clrscr();
for(;;)
{
cout<<“n 1-Insert_rear n 2-Delete_id n 3-Exit n Enter choice”;
cin>>ch;
switch(ch)
{
case 1:  Insert();
break;
case 2:  Delete();
break;
case 3:  exit(0);
default: cout<<“n Invalid option”;
break;
}
}
}

File Structure ( FS ) Lab Program 11 ( 6th Semester Information Science)

// May 30th, 2009 // Comments // Old

Program 11 : Write a C++ program to store and retrieve student data from file using hashing. Use any collision resolution technique

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<fstream.h>
#include<iostream.h>

//Record specification

class node
{
public: char name[15],usn[15];
node *link;
};

node *h[29];    //Array of record pointers equal to size of hash keys – 29

void insert()
{
char name[15], usn[15], buffer[50];
fstream out;
out.open(“student.txt”,ios::app); //opening student.txt in append mode
if(!out)
{
cout<<“nUnable to open the file in append mode”;
getch();
return;
}

cout<<“nEnter the name = “; cin>>name;
cout<<“n Enter the usn = “; cin>>usn;

strcpy(buffer,name); //Packing the record onto the file using ‘|’ as a delimiter
strcat(buffer,”|”);
strcat(buffer,usn);
strcat(buffer,”n”); // n delimiter for the record
out<<buffer;         // appending the packed record onto the file
out.close();
}

//Insert record into the hash table
void hash_insert(char name1[], char usn1[], int hash_key)
{
node *p,*prev,*curr;
p = new node;       //dynamically allocate space using ‘new’
strcpy(p->name,name1);
strcpy(p->usn,usn1);
p->link=NULL;
prev=NULL;
curr=h[hash_key];
if(curr==NULL)     //getting the hash pointer location Case: No collision
{
h[hash_key]=p;
return;
}
while(curr!=NULL)     // Case : On collision – Insert at rear end
{
prev=curr;
curr=curr->link;
}
prev->link=p;
}

void retrive()
{
fstream in;
char name[15],usn[15];
int j,count;
node *curr;
in.open(“student.txt”,ios::in); // open the record file in input mode
if(!in)
{
cout<<“n Unable to open the file in input mode”;
getch();
exit(0);
}
while(!in.eof())
{
in.getline(name,15,’|’);  //unpacking the record
in.getline(usn,15,’n’);
count=0;
for(j=0; j<strlen(usn); j++)  //Calculate sum of ascii values of USN
{
count=count+usn[j];
}
count=count%29;               //Hash Key = ASCII count% 29
hash_insert(name,usn,count);
}
cout<<“n Enter the usn =  “;    cin>>usn;
count=0;
for(j=0; j<strlen(usn); j++)        // Calculating Hash Key
count=count+usn[j];
count=count%29;
curr=h[count];
if(curr == NULL)
{
cout<<“nRecord not found”;
getch();
return;
}
do
{
if(strcmp(curr->usn,usn)==0)   //When the record is found, retrieve
{
cout<<“nRecord found : “<<curr->usn<<” “<<curr->name;
getch();
return;
}
else
{
curr=curr->link;
}
}while(curr!=NULL);               //Search till end of list

if(curr==NULL) //End of list reached with no record found
{
cout<<“nRecord not found”;
getch();
return;
}
}

void main()
{
int choice;
clrscr();
fstream out;
out.open(“student.txt”,ios::out);
if(!out)
{
cout<<“nUnable to open the file in out mode”;
getch();
exit(0);
}
for(;;)
{
cout<<“n1:insertn 2: retrive n3:exit nEnter the choice – “;
cin>>choice;
switch(choice)
{
case 1:  insert();
break;
case 2:  retrive();
break;
case 3:  exit(0);
default: cout<<“nInvalid option”;
}
}
}

File Structure ( FS ) Lab Program 10 ( 6th Semester Information Science)

// May 29th, 2009 // Comments // Old

Program 10 : Write a C++ program to implement B-Tree for a given set of integers and its operations insert ( ) and search ( ). Display the tree.

#include<iostream>
#include<cmath>

using namespace std;

struct node{
int ele[4];
int child[4];
node *next;
};

class bptree{
public:
node *tree[10][10];
int count[10];
int leaf;
int path[10];
node *head;

bptree();
node* create_node();
void insert(int);
void main_search(int);
void display_tree();
void insert_node(node*,int);
void search(int);
int search_node(node*,int);
int nodefull(node*);
void split(node*);
};

bptree::bptree()
{
leaf=-1;
for(int i=0;i<10;i++)
{
count[i]=-1;
path[i]=-1;
}
}

node* bptree::create_node()
{
node* n;
n=new node;
for(int i=0;i<4;i++)
{
n->ele[i]=-1;
n->child[i]=-1;
}
n->next=NULL;
return n;
}

void bptree::insert(int key)
{
int n,parent;
node *first_node;
if(leaf==-1)
{
first_node=create_node();
tree[0][0]=first_node;
leaf++;
count[0]++;
first_node->ele[0]=key;
head=first_node;
}
else if(leaf==0)
{
if(nodefull(tree[0][0]))
{
path[leaf]=0;
split(tree[0][0]);
insert(key);
}
else
insert_node(tree[0][0],key);
}
else
{
search(key);
n=path[leaf];
parent=path[leaf-1];
if((nodefull(tree[leaf][n])))
{
split(tree[leaf][n]);
insert(key);
}
else
insert_node(tree[leaf][n],key);
}
}

void bptree::main_search(int key)
{
int flag=0,i;
node *node1;
search(key);
node1=tree[leaf][path[leaf]];
for(i=0;node1->ele[i]!=-1;i++)
if(node1->ele[i]==key)
{
flag=1;
break;
}
cout<<“n The path traversed is:”;
for(i=0;path[i]!=-1;i++)
cout<<path[i]<<“->”;
if(flag)
cout<<“nnElement found”;
else
cout<<“nnNot Found”;
}

void bptree::display_tree()
{
int i,j,k;
for(i=0;i<=leaf;i++)
{
cout<<“nnLevel——“<<i<<“n”;
for(j=0;j<=count[i];j++)
{
if(i!=leaf) k=1;
else         k=0;
for(;tree[i][j]->ele[k]!=-1;k++)
cout<<”  “<<tree[i][j]->ele[k]<<“t”;
}
}
}

void bptree::search(int key)
{
int i,j,temp;
path[0]=0;
if(leaf)
{
j=0;
for(i=0;i<leaf;i++)
{
temp=search_node(tree[i][j],key);
path[i+1]=temp;
j=temp;
}
}
}

int bptree::search_node(node *node1,int key)
{
if(key<=node1->ele[0])
return node1->child[0];
for(int i=1;i<4;i++)
{
if((key>=node1->ele[i]) && (key<node1->ele[i+1]))
return node1->child[i];
else if(node1->ele[i+1]==-1)
return node1->child[i];
}
}

int bptree::nodefull(node* node1)
{
if(node1->ele[3]!=-1)return 1;
else     return 0;
}

void bptree::insert_node(node *node1,int key)
{
int flag=0,count=-1,i,j,x,y,l;
node *newnode,*parent;
for(i=0;i<4;i++)
if(node1->ele[i]!=-1)
++count;
i=0;
while(!flag&&node1->ele[i]!=-1)
{
if(node1->ele[i]>key)
{
flag=1;
for(int j=count;j>=i;j–)
node1->ele[j+1]=node1->ele[j];
node1->ele[i]=key;
}
i++;
}
if(!flag)
node1->ele[count+1]=key;
if(node1->ele[0]==key)
{
for(i=leaf-1;i>=0;i–)
{
x=path[i+1];
if(tree[i][path[i]]->ele[x]>key)
tree[i][path[i]]->ele[x]=key;
else
insert_node(tree[i][x],key);
}
}

for(i=0;i<=count+1;i++)
cout<<“tt”<<node1->ele[i];
}

void bptree::split(node *oldnode)
{
node *newnode,*parent,*n1,*n2;
int i,j,k,n,t,x,y,pos;
newnode=create_node();
newnode->ele[0]=oldnode->ele[2];
newnode->ele[1]=oldnode->ele[3];
oldnode->ele[2]=-1;
oldnode->ele[3]=-1;
t=count[leaf];
n=path[leaf];
for(i=t,j=t+1;i>n;i–,j–)
tree[leaf][j]=tree[leaf][i];
newnode->next=tree[leaf][n]->next;
tree[leaf][n]->next=newnode;
tree[leaf][n+1]=newnode;
count[leaf]++;
x=leaf;
if(count[leaf]+1==1) t=1;
else
t=log(count[leaf]+1)/log(2);
if(t!=leaf)
{
++leaf;
count[leaf]=count[x];
for(i=0;i<=count[leaf];i++)
std::swap(tree[leaf][i],tree[x][i]);
}
for(i=leaf-1;i>=0;i–) count[i]=-1;
for(i=t,j=i-1;i>0;i–,j–)
{
for(k=0;k<=(count[i])/3;k++)
{
n1=tree[i][2*k];
n2=tree[i][(2*k)+1];

newnode=create_node();
count[j]++;
tree[j][count[j]]=newnode;
newnode->ele[0]=n1->ele[0];
newnode->child[0]=2*k;
newnode->ele[1]=n2->ele[0];
newnode->child[1]=(2*k)+1;
}
if(count[i]!=1 && count[i]%2==0)
{
n2=tree[i][count[i]];
for(y=0;n2->ele[y]!=-1;y++);
newnode->ele[2]=n2->ele[0];
newnode->child[2]=count[i];
}
}
}
int main()
{
bptree bt;
int choice,key;
while(1)
{
cout<<“nnnMain Menun———–n1:Insertn2:Searchn3:Display treen4:ExitnnEnter your choice :”;
cin>>choice;
switch(choice)
{
case 1:cout<<“nnEnter the element: “;
cin>>key;
bt.insert(key);
break;
case 2: cout<<“nEnter the key: “;
cin>>key;
bt.main_search(key);
break;
case 3: bt.display_tree();
break;
case 4: return 0;
default: cout<<“nnEnter valid Choice”;
}
}
}

File Structure ( FS ) Lab Program 9 ( 6th Semester Information Science)

// May 28th, 2009 // Comments // Old

Program 9 : Write a C++ program to implement B-Tree for a given set of integers and its operations insert ( ) and search ( ). Display the tree.

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<alloc.h>

const int MAX = 4 ;
const int MIN = 2 ;

struct btnode
{
int count;
int value[MAX + 1];
btnode *child[MAX + 1];
};

class btree
{
private : btnode *root ;
public : btree( ) ;
void insert(int val) ;
int setval(int val, btnode *n, int *p, btnode **c);
static btnode *search (int val, btnode *root, int *pos);
static int searchnode(int val, btnode *n, int *pos);
void iskeypresent( int val) ;
void fillnode( int val, btnode *c, btnode *n, int k );
void split( int val, btnode *c, btnode *n, int k, int *y, btnode **newnode );
void clear( btnode *root, int k );
void copysucc( btnode *root, int i );
void merge( int k ) ;
void show( );
static void display( btnode *root );
static void deltree( btnode *root );
~btree( );
};

// initialises data member
btree :: btree( )
{
root=NULL;
}

// searches a key and checks whether it is present or not
void btree :: iskeypresent(int val)
{
int i ;
if( searchnode ( val, root, &i ) )
cout<< “Key found “<<endl;
else
cout<< “Key Not found “<<endl;
}

// inserts a value in the B-tree
void btree :: insert ( int val )
{
int i ;
btnode *c, *n ;
int flag ;
flag = setval( val, root, &i, &c ) ;
if( flag )
{
n = new btnode ;
n -> count = 1 ;
n -> value[1] = i ;
n -> child[0] = root ;
n -> child[1] = c ;
root = n ;
}
}

// sets the value in the node
int btree :: setval ( int val, btnode *n, int *p, btnode **c)
{
int k ;
if ( n == NULL )
{
*p = val ;
*c = NULL ;
return 1 ;
}
else
{
if( searchnode ( val, n, &k ) )
{
cout << endl << “Key value already exists”;
return 0 ;
}
if ( setval ( val, n -> child[k], p, c ) )
{
if ( n -> count < MAX )
{
fillnode ( *p, *c, n, k ) ;
return 0 ;
}
else
{
split ( *p, *c, n, k, p, c ) ;
return 1 ;
}
}
return(0);
}
}

// searches value in the node
btnode * btree :: search ( int val, btnode *root, int *pos )
{
if ( root == NULL ) return NULL ;
else
{
if ( searchnode ( val, root, pos ) )
return root ;
else
return search ( val, root -> child[*pos], pos ) ;
}
}

// searches for the node
int btree :: searchnode ( int val, btnode *n, int *pos )
{
//this condition is used to decide the traversal
if ( val < n -> value[1] )
{
*pos = 0 ;
return 0 ;
}
else
{
*pos = n -> count ;
while ( ( val < n -> value[*pos] ) && *pos > 1 )
(*pos)– ;
if ( val == n -> value[*pos] )
return 1 ;
else
return 0 ;
}
}

// adjusts the value of the node
void btree :: fillnode ( int val, btnode *c, btnode *n, int k )
{
int i ;
for ( i = n -> count ; i > k ; i– )
{
n -> value[i + 1] = n -> value[i] ;
n -> child[i + 1] = n -> child[i] ;
}
n -> value[k + 1] = val ;
n -> child[k + 1] = c ;
n -> count++ ;
}

// splits the node
void btree :: split ( int val, btnode *c, btnode *n, int k, int *y, btnode **newnode )
{
int i, mid ;
if ( k <= MIN )
mid = MIN ;
else
mid = MIN + 1 ;
*newnode = new btnode ;
for ( i = mid + 1 ; i <= MAX ; i++ )
{
( *newnode ) -> value[i – mid] = n -> value[i] ;
( *newnode ) -> child[i – mid] = n -> child[i] ;
}
( *newnode ) -> count = MAX – mid ;
n -> count = mid ;
if ( k <= MIN )
fillnode ( val, c, n, k ) ;
else
fillnode ( val, c, *newnode, k – mid ) ;
*y = n -> value[n -> count] ;
( *newnode ) -> child[0] = n -> child[n -> count] ;
n -> count– ;
}

// removes the value from the node and adjusts the values
void btree :: clear ( btnode *root, int k )
{
int i ;
for ( i = k + 1 ; i <= root -> count ; i++ )
{
root -> value[i – 1] = root -> value[i] ;
root -> child[i – 1] = root -> child[i] ;
}
root -> count– ;
}

// copies the successor of the value that is to be deleted
void btree :: copysucc ( btnode *root, int i )
{
btnode *temp = root -> child[i] ;
while ( temp -> child[0] )
temp = temp -> child[0] ;
root -> value[i] = temp -> value[1] ;
}

// merges two nodes
void btree :: merge ( int k )
{
btnode *temp1, *temp2 ;
temp1 = root -> child[k] ;
temp2 = root -> child[k – 1] ;
temp2 -> count++ ;
temp2 -> value[temp2 -> count] = root -> value[k] ;
temp2 -> child [temp2 -> count] = root -> child[0] ;
for ( int i = 1 ; i <= temp1 -> count ; i++ )
{
temp2 -> count++ ;
temp2 -> value[temp2 -> count] = temp1 -> value[i] ;
temp2 -> child[temp2 -> count] = temp1 -> child[i] ;
}
for ( i = k ; i < root -> count ; i++ )
{
root -> value[i] = root -> value[i + 1] ;
root -> child[i] = root -> child[i + 1] ;
}
root -> count– ;
delete temp1 ;
}

// calls display( )
void btree :: show( )
{
display ( root ) ;
}

// displays the B-tree
void btree :: display ( btnode *root )
{
if ( root != NULL )
{
for ( int i = 0 ; i < root -> count ; i++)
{
display ( root -> child[i] ) ;
cout << root -> value[i + 1] << “t”;
}
display ( root -> child [i] ) ;
}
}

// deallocates memory
void btree :: deltree ( btnode *root )
{
if ( root != NULL )
{
for ( int i = 0 ; i < root -> count ; i++)
{
deltree ( root -> child [i] ) ;
delete ( root -> child[i] ) ;
}
deltree ( root -> child[i] ) ;
delete ( root -> child[i] ) ;
}
}

btree :: ~btree( )
{
deltree ( root ) ;
}

void main( )
{
btree b ;
clrscr();
int num;
int choice=0;
while (choice!=4)
{
cout<<endl<<“l – Insert”<<endl;
cout<<“2 – Search”<<endl;
cout<<“3 – Display”<<endl;
cout<<“4 – Exit”<<endl;
cout<<“Enter your choice”<<endl;
cin>>choice;
switch(choice)
{
case 1:  cout<<“nEnter the elements to be inseretd into b tree n”;
cin>>num;
b.insert ( num ) ;
break;
case 2:  cout<<“nEnter the elements to be searched in b tree n”;
cin>>num;
b.iskeypresent ( num ) ;
break;
case 3:  b.show( ) ;
break;
case 4:  exit(0);
default: cout<<“nInvalid Option n”;
}
}
}

File Structure ( FS ) Lab Program 8 ( 6th Semester Information Science)

// May 28th, 2009 // Comments // Old

Program 8 :Write a C++ program to read k Lists of names and merge them using kway merge algorithm with k = 8.

#include<iostream.h>
#include<fstream.h>
#include<string.h>

// Record specification

class record
{
public: char name[20];
char usn[20];

}rec[20];

int no;

fstream file[8];

//The first 8 files

char fname[8][8] = {“l.txt”,”2.txt”,”3.txt”,”4.txt”,”5.txt”,”6.txt”,”7.txt”,”8.txt”};

void merge_file(char* file1, char* file2, char* filename)
{
record recrd[20];
int k; k=0;
fstream f1,f2;
f1.open(file1,ios::in);   //open the first file
f2.open(file2,ios::in);   //open the second file
while(!f1.eof()) //Unpack and retrieve first file
{
f1.getline(recrd[k].name,20,’|’);
f1.getline(recrd[k++].usn,20,’n’);
}
while(!f2.eof()) //Unpack and retrieve second file
{
f2.getline(recrd[k].name,20,’|’);
f2.getline(recrd [k++].usn, 20,’n’);
}
record temp;
int t,y;
for(t=0;t<k-2;t++) //Sort the retrieved records
for(y=0;y<k-t-2;y++)
if(strcmp(recrd[y].name,recrd[y+1].name)>0)
{
temp=recrd[y];
recrd[y]=recrd[y+1];
recrd[y+1]=temp;
}
fstream temp1;
temp1.open(filename,ios::out);      //Open the file to be packed into
for(t=1;t<k-1;t++) //Pack the sorted records onto the file
temp1<<recrd[t].name<<“|”<<recrd[t].usn<<“n”;
f1.close();
f2.close();
temp1.close();
return;
}
void kwaymerge()
{
char filename[7][20]={“ll.txt”,”22.txt”,”33.txt”,”44.txt”,”lll.txtw”,”222.txt”,”llll.txr”};
int i;
int k;
k=0;
for(i=0;i<8;i+=2) //Merge and sort the 8 original files onto
{ //the four files indicated {ll.txt,22.txt….}
merge_file(fname[i],fname[i+1],filename[k++]);
}
k=4;
for(i=0;i<4;i+=2) //Merge and sort the four files onto lll.txt and 222.txt
{
merge_file(filename[i],filename[i+1],filename[k++]);
}
//Merge and sort the two files onto the llll.txt file
merge_file(filename[4],filename[5],filename[6]);
return;
}

int main()
{
int i;
cout<<“Enter the no. of records : “;
cin>>no;
cout<<“nEnter the details : n”;
for(i=0;i<8;i++) //Create 8 files to store the split data
file[i].open(fname[i],ios::out);
for(i=0;i<no;i++) //Split and pack data onto the files
{
cout<<“Name :”; cin>>rec[i].name;
cout<<“USN  : “;cin>>rec[i].usn;
file[i%8]<<rec[i].name<<‘|'<<rec[i].usn<<“n”;
}
for(i=0;i<8;i++)
file[i].close();
kwaymerge(); //Merge
fstream result;
result.open(“llll.txt”,ios::in);
cout<<“nSorted Records : n”;
char name[20],usn[20];
for(i=0;i<no;i++) //Unpack the sorted records and dispL
{
result.getline(name,20,’|’);
result.getline(usn,20,’n’);
cout<<“nName   : “<<name<<“nUSN : “<<usn<<“n”;
}
return 0;
}

File Structure ( FS ) Lab Program 7 ( 6th Semester Information Science)

// May 27th, 2009 // Comments // Old

Program 7 : Write a C++ program to read two lists of names and then match the names in the two lists using Cosequential Match based on a single loop. Output the names common to both the lists.

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<fstream.h>
#include<iostream.h>

void writeLists()
{
fstream out1,out2;
int i,m,n;
char name[20];

out1.open(“file1.txt”,ios::out);
out2.open(“file2.txt”,ios::out);

if( (!out1) || (!out2) )
{
cout<<“Unable to open one of the list files”;
getch();
exit(0);
}

cout<<“Enter no. of names you want to enter in file1”; cin>>m;
cout<<“nEnter the names in ascending ordern”;
for(i-0;i<m;i++)
{
cin>>name;
out1<<name;
out1<<‘n’;
}

cout<<“Enter no. of names you want to enter in file2”; cin>>n;
cout<<“nEnter the names in ascending order n”;
for(i=0;i<n;i++)
{
cin>>name;
out2<<name;
out2<<‘n’;
}
out1.close();
out2.close();
}

void main()
{
char list1[100][20], list2[100][20];
int i,j,m,n;
clrscr();
fstream out1,out2,out3;

writeLists();

out1.open(“file1.txt”,ios::in);
out2.open(“file2.txt”,ios::in);
out3.open(“file3.txt”,ios::out);

if( (!out3) || (!out1) || (!out2) )
{
printf(“Unable to open one of the file”);
getch();
exit(0);
}

clrscr();
m=0;
n=0;
while(!out1.eof())
{
out1.getline(list1[m],20,’n’);
cout<<list1[m];
m++;
}
while(!out2.eof())
{
out2.getline(list2[n],20,’n’);
cout<<list2[n];
n++;
}
m–;
n–;
i=0;
j=0;

cout<<“nElements common to both files are: n “;
while(i<m && j<n)
{
if( strcmp(list1[i],list2[j]) == 0 )
{
out3<<list1[i];
cout<<list1[i]<<“n”;
out3<<‘n’;
i++;
j++;
}
else if( strcmp(list1[i],list2[j]) < 0 )
i++;
else
j++;
}
getch();
}

File Structure ( FS ) Lab Program 6 ( 6th Semester Information Science)

// May 26th, 2009 // Comments // Old

Program 6 : Write a C++ program to implement index on secondary key, the name, for a file of student objects. Implement add ( ), search ( ), delete ( ) using the secondary index

#include<iostream.h>
#include<string.h>
#include<fstream.h>
#include<stdlib.h>

//using namespace std;

class record
{
public: char age[5];
char usn[20],name[20],branch[5]; char sem[2];
}rec[20],found[20];

char st_no[5],rt_name[20];
int no;

void sort_records()
{
int i,j;
record temp;
for(i=0;i<no-1;i++)
for(j=0;j<no-i-1;j++)
if(strcmp(rec[j].name, rec[j+1].name) > 0)
{
temp=rec[j];
rec[j]=rec[j+1];
rec[j+1]=temp;
}
}

void create_indexfile()
{
fstream index,index2;
int i;
index.open(“secindex.txt”,ios::out);
index2.open(“record.txt”,ios::out);
for(i=0;i<no;i++)
{
index<<rec[i].name<<“|”
<<rec[i].usn<<“|”<<i<<“n”;
index2<<i<<“|”<<rec[i].usn<<“|”<<rec[i].name<<“|”<<rec[i].age<<“|”
<<rec[i].sem<<“|”<<rec[i].branch<<“n”;
}
}

void retrieve_record(char* index)
{
fstream file;
int i;
char ind[2],usn[20],name[20],age[3],sem[3],branch[10];
file.open(“record.txt”,ios::in);
for(i=0;i<no;i++)
{
file.getline(ind,4,’|’);
file.getline(usn,20,’|’);
file.getline(name,20,’|’);
file.getline(age,4,’|’);
file.getline(sem,4,’|’);
file.getline(branch,5,’n’);
if(strcmp(index,ind) == 0)
cout<<“nUSN: “<<usn
<<“nName: “<<name
<<“nAge: “<<age
<<“nSem: “<<sem
<<“nBranch: “<<branch;
}
file.close();
return;
}

void retrieve_details()
{
int k=0,i;
char name[20],usn[20],ind[2];
char chusn[20];
char index[20][20];
fstream file;
file.open(“secindex.txt”,ios::in);
for(i=0;i<no;i++)
{
file.getline(name,20,’|’);
file.getline(usn,20,’|’);
file.getline(ind,4,’n’);
if(strcmp(name,rt_name) == 0)
{
strcpy(found[k].name,name);
strcpy(found[k].usn,usn);
strcpy(index[k],ind);
k++;
}
}
file.close();
if(k==1)
{
retrieve_record(index[0]);
return;
}
else
{
cout<<“Please choose the candidate’s USN: n”;
for(i=0;i<k;i++)
cout<<“Name: “<<found[i].name<<” USN: “<<found[i].usn<<endl;
}
cin>>chusn;
for(i=0;i<k;i++)
{
if(strcmp(chusn,found[i].usn) == 0)
{
retrieve_record(index[i]);
return;
}
}
cout<<“Invalid Entry! n”;
return;
}

void delete_record(char indx[])
{
int i;
fstream file1,file2;
char age[5],sem[5],branch[5],usn[20],name[20],ind[5];
char index[20][20];
file2.open(“record.txt”,ios::in);
for(i=0;i<no;i++)
{
file2.getline(ind,4,’|’);
file2.getline(usn,20,’|’);
file2.getline(name,20,’|’);
file2.getline(age,5,’|’);
file2.getline(sem,5,’|’);
file2.getline(branch,8,’n’);
strcpy(index[i],ind);
strcpy(rec[i].usn,usn);
strcpy(rec[i].name,name);
strcpy(rec[i].age,age);
strcpy(rec[i].sem,sem);
strcpy(rec[i].branch,branch);
}
int flag=-1;
for(i=0;i<no;i++)
{
if(strcmp(index[i],indx) == 0)
flag=i;
}
if(flag==-1)
{
cout<<“Error!n”;
return;
}
if(flag==(no-1))
{
no–;
cout<<“Deleted!n”;
return;
}
for(i=flag;i<no;i++)
{
rec[i]=rec[i+1];
}
no–;
cout<<“Deleted!n”;
file2.close();
file1.open(“secindex.txt”,ios::out);
file2.open(“record.txt”,ios::out);
for(i=0;i<no;i++)
{
file1<<rec[i].name<<“|”<<rec[i].usn<<“|”<<i<<“n”;

file2<<i<<“|”<<rec[i].usn<<“|”<<rec[i].name<<“|”
<<rec[i].age<<“|”<<rec[i].sem<<“|”<<rec[i].branch<<“n”;
}
file1.close();
file2.close();
return;
}

void delete_index(char* nam)
{
fstream file;
int i;
int k=0;
char name[20],usn[20],ind[5],index[20][20],chusn[20];
file.open(“secindex.txt”,ios::in);
for(i=0;i<no;i++)
{
file.getline(name,20,’|’);
file.getline(usn,20,’|’);
file.getline(ind,4,’n’);
if(strcmp(nam,name)==0)
{
strcpy(found[k].name,name);
strcpy(found[k].usn,usn);
strcpy(index[k],ind);
k++;
}
}
file.close();
if(k==1)
{
delete_record(index[0]);
return;
}
else
{
cout<<“Please choose the candidate’s USN: n”;
for(i=0;i<k;i++)
{
cout<<“Name: “<<found[i].name<<” USN: “<<found[i].usn<<endl;
}
}
cin>>chusn;
for(i=0;i<k;i++)
{
if(strcmp(chusn,found[i].usn)==0)
{
delete_record(index[i]);
return;
}
}
cout<<“Invalid Entry!n”;
return;
}

int main()
{
fstream file1,file2;
int ch;
char rt_usn[20],st_name[20],st_usn[20];
char ind[2],name[20],age[2],sem[5],branch[5];
int i,flag,flag1;
file1.open(“index.txt”,ios::out);
file2.open(“record.txt”,ios::out);
if(!file1 || !file2)
{
cout<<“File creation Error!n”;
exit(0);
}
for(;;)
{
cout<<“nl:Add Recordn 2:Search Record”
<<“n3:Delete Recordn 4:Display Recordn”;
cin>>ch;
switch(ch)
{
case 1: cout<<“Enter the no. of students : “; cin>>no;
cout<<“Enter the details :n”;
for(i=0;i<no;i++)
{
cout<<“nName : “; cin>>rec[i].name;
cout<<“Age : “;    cin>>rec[i].age;
cout<<“USN : “;    cin>>rec[i].usn;
cout<<“Sem : “;    cin>>rec[i].sem;
cout<<“Branch : “; cin>>rec[i].branch;
}
sort_records();
create_indexfile();
file1.close ();
file2.close();
break;

case 2: cout<<“Enter name of the student whose record is to be displayedn”;
cin>>st_name;
file1.open(“secindex.txt”,ios::in);
if(!file1)
{
cout<<“Error !n”;
exit(0);
}
flag1=0;
for(i=0;i<no;i++)
{
file1.getline(rt_name,20,’|’);
file1.getline(rt_usn,20,’|’);
file1.getline(st_no,4,’n’);

if(strcmp(st_name,rt_name)==0)
{
retrieve_details();
flag1=1;
goto one;
}
}
one: if(!flag1)
cout<<“Record search failed !n”;
file1.close();
break;

case 3: cout<<“Enter name of student whose record is to be deletedn”;
cin>>st_name;
file1.open(“secindex.txt”,ios::in);
if(!file1)
{
cout<<“Error !n”;
exit(0);
}
flag=0;
for(i=0;i<no;i++)
{
file1.getline(rt_name,20,’|’);
file1.getline(rt_usn,20,’|’);
file1.getline(ind,4,’n’);

if(strcmp(st_name,rt_name) == 0)
{
delete_index(rt_name);
flag=1;
}
}
if(!flag)
cout<<“Deletion failed !n”;
file1.close();
break;

case 4: for(i=0;i<no;i++)
{
cout<<“nnUSN : “<<rec[i].usn
<<“nName: “<<rec[i].name
<<“nAge : “<<rec[i].age
<<“nSem : “<<rec[i].sem
<<“nBranch : “<<rec[i].branch<<“n”;
}
break;

default: cout<<“Invalid option !n”;
exit(0);
break;
}
}
return 0;
}

Belgaum techies come aboard and meet

// May 23rd, 2009 // Comments // Old

Belgaum Techies working in the IT and ITeS fields have concurred the same thought as of this blog and in response to Collective effort to develop IT & ITeS in Belgaum, they had their first meeting on Saturday 23rd May at Ajanta Café which went on in a informal but very assertive manner.

dotCORD IT Solutions Pvt. Ltd.

dotCORD IT Solutions Pvt. Ltd.

R K Patil of Vayavyalabs, Swapneel Patnekar from eTH1 Network Solutions, Aadil Bandukwala of Leading Minds, Ameet Patil of Spundhan, Harshad Joglekar a freelancer, Sandeep Tekriwal of Starnet computers, Sandeep Hegde & Manoj from DotCord, Vinod Chavan & Vishal Kulkarni from 3iGlobal were present.

Belgaum IT Meet

Belgaum IT Group

A formal round of introduction happened and all shared the idea of collaborating. They all thanked AllAboutBelgaum for talking this initiative and getting the It & ITeS related people closer in a group. Each one expressed their own problems and success stories and agreed to collaborate with each other. An e-Group has already been created for this and in some time a website will also be primed with all the details of the companies, Jobs etc.

Casual Discussions @ Belgaum IT Meet

Me(Left) , Vishal Kulkarni(middle), R.K.Pakil (Right)

A need was felt by all that as a group they should approach colleges and companies and promote themselves as well as Belgaum as a Brand. Reaching out to the clientele is the biggest challenge many said and this kind of a platform will enable and aid all of them to achieve their goals. As all are startups a need was felt to share the ideas and also share professional knowledge with each other on various topics which
will include taxation, company formation and govt legalities.

Belgaum IT meet

Networking @ Belgaum IT Meet

This is just a beginning and monthly meets will follow and the base of companies will also be added to the group so that all the It & ITeS companies based in Belgaum will come under a single banner for the benefit of Belgaum.

Source : AllAboutBelgaum.com

Due to lack of time in my hectic schedule, the content is copy pasted from http://allaboutbelgaum.com/business/belgaum-techies-come-aboard-and-meet-%E2%80%93-allaboutbelgaum-impact/

NetApp TeXhibit – An All India Technical Paper Presentation Contest

// May 12th, 2009 // Comments // Old

Unlock the best in you !
Here is your opportunity to share your ideas on networking & storage technology innovations through TeXhibit.
TeXhibit is an All India Online Technical Paper Presentation Contest that provides a creative platform to all the young & vibrant Engineering and Science students to take their ground-breaking ideas to the next level.

TeXhibit your noesis!
NetApp – the world leader in networking & storage solutions, has set the stage for young minds to engage and portray the next generation ideas in networking & storage domain.

Exhibit & unleash the tech geek in you!
Inviting your innovations on –

* Operating Systems
* File Systems
* Compilers
* Multi-core architecture and its implications to software
* Server and Storage Virtualization
* Data Compression
* Web 2.0 applications like social networking
* Flash and related persistent storage technologies
* Disk storage and related technologies

LAST DATE FOR SUBMITTING ABSTRACTS
25TH MAY, 2009


texhibit

Evaluation Criteria:

All submissions will be judged by a thorough review process by the Technical Judges Panel from NetApp & CareerNet. The abstracts & technical presentations will win purely on the basis of technical merit and relevance to the topics being chosen by the participants   Mentioned below is the weightage (key for the participants to score more!!) for each parameter

Abstract (Weight 25%)
Problem Approach 10
Analysis Methodology 05
Innovative Approach of the work 05
Theoretical Fundamentals Weight 15
Adequate Handling of Theoretical basis 08
Correct Development of selected Methodology 07
Total- Abstract 50
Paper Presentation (Weight 50%)
Problem Approach 12
Analysis Methodology 10
Innovative Approach of the work 10
Theoretical Fundamentals Weight 20
Integral Documentation of Subject 08
Adequate Handling of Theoretical basis 15
Correct Development of selected Methodology 10
Achieved Conclusion 15
Total- Abstract 100
Telephonic Interview Round (Weight 25%)
Understanding of the topic 10
Theoretical Fundamentals 10
Explanation Capability 10
General awareness of the relevant technologies 05
Interviewer’s criterion 10
Communication Skills 05
Total-Interview 50

Grand Total 200

Guidelines:

You must be registered with www.campus-connect.com for participating in the challenge. Each participant is eligible to submit only one entry. Participant can choose any one of the given topics.

Preliminary Round:

After deciding the topic for your presentation, you are required to submit an abstract detailing the scope of work, methodology proposed and benefits that entail in the long run.

Format for abstract: Submit the Abstract in provided format only.Click here to download the Abstract Template.
Word limit for abstract: 300 words.
Content of abstract:
  • Title of Technical Paper
  • Candidate Name, College and Department
  • Contact Details – Phone number & Email Address
  • Problem Statement
  • Summary of the Solution Proposed
Document Formatting:
  • Font: Arial.
  • Document Font Size: 11.
  • Title Font Size: 14, Bold.
  • Line Spacing: 1.5.

Based on the abstracts submitted, participants would be shortlisted for next round in the challenge.

  • All shortlisted participants will be showcased on the TeXhibit’s website.
  • Final presentation must be submitted in MS PowerPoint Presentation format (.ppt).
  • Decision of judges will be considered as final in each stage of the competition.
  • All Submissions will be judged on their technical merit and their relevance to the chosen topic.
All the best !

Zoozoo: The new brand 'endorser' for Vodafone

// May 9th, 2009 // Comments // Old

Zoozoo: The new brand 'endorser' for Vodafone

Zoozoo: The new brand 'endorser' for Vodafone

Zoozoo: The new brand 'endorser' for Vodafone

Zoozoo: The new brand 'endorser' for Vodafone

No, they aren’t animated characters. They are human beings who were made to wear body suits. “The design of the characters is such that one gets fooled into thinking it is animation,” shrugs Rao, which was indeed the very illusion that had to be created. “In a sense, it is ‘live’ animation!” he quips, referring to the fact that it was all shot live.

Prakash Verma

Prakash Varma, ad filmmaker, Nirvana Films, has directed the commercials, and reveals that the Zoozoos were a big challenge to create. The practical aspects of how they will move, talk, gesticulate and emote were very important. Essentially, costume design and artwork were crucial elements.

“It took me three weeks of pre-production to understand how it will work,” says Varma. There were two fabrics that were considered for the body suits, and one was rejected for it had too many wrinkles and was shiny. The wrinkles would have shown when the characters moved, thereby shattering the illusion of animation. “So we chose the more practical, thicker fabric,” Varma explains.

The production team divided the outfit into two parts: the body and the head. The body part of the outfit was stuffed with foam in some places, while the head was attached separately. To make it look bigger than a human head, a harder material called Perspex was used, which in turn was stuffed with foam (with scope for ventilation).

If one wishes to understand the size of this head, here’s a fact: a human head would typically reach up to the mouth level of this giant Zoozoo head. “We kept the hands and legs thin, which is why we cast women – and occasionally children – wearing the costumes,” says Varma. The thin limbs, contrasted with big bellies and a bulbous head, all add to the illusion that these creatures are ‘smaller’ than humans. Sets were created to suit the size of the Zoozoos.

Cinematically, this ‘size’ was a trick: the creatures look smaller than they actually are on screen, to portray a different world of sorts. For this, the speed of shooting was altered: Nirvana shot it in a high-speed format to make them look the size that they do.

Furthermore, simple sets/backdrops were created and spray painted with neutral Greys – a colour of choice so that attention isn’t diverted from the main characters. For a supposedly ‘outdoor’ shot, even the shadow of a Zoozoo was kept ‘live’ and not done in post production: it was painted in a darker shade of grey on the ground. An even lighting was maintained throughout.
There was virtually no post production work done.

The films were shot by Nirvana in Cape Town , South Africa , with the help of a local production house there, called Platypus. Incidentally, the same combination of people also worked on the ‘Happy to Help’ series last year. When asked whether Cape Town is fast becoming a tourist spot for Vodafone and Nirvana, Varma laughs, saying, “Oh no! It’s just that we are very comfortable with the team there and know what sort of work to expect from them.”

Nagpal adds here that the production cost had to be minimal for unveiling such a large number of commercials. “Otherwise, our production costs would exceed media spends,” he quips.