Showing posts with label chennai anna university 2011. Show all posts
Showing posts with label chennai anna university 2011. Show all posts
Saturday, 17 December 2011
PASS2 OF DIRECTLINKING LOADER
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
struct exttable
{
char
csect[20],sname[20];
int padd,plen;
}estab[20];
struct objectcode
{
unsigned char
code[15];
int add;
}obcode[500];
void main()
PASS1 OF DIRECT LINKING LOADER
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct estab
{
char csname[10];
char extsym[10];
int address;
int length;
}es[20];
void main()
{
char
input[10],name[10],symbol[10],ch;
int
count=0,progaddr,csaddr,add,len;
FILE *fp1,*fp2;
clrscr();
fp1=fopen("LINP.DAT","r");
fp2=fopen("LOADMAP.DAT","w");
printf("\n\nEnter the address where the program has loaded:
");
scanf("%x",&progaddr);
csaddr=progaddr;
fprintf(fp2,"CS_NAME\tEXT_SYM_NAME\tADDRESS\tLENGTH\n");
fprintf(fp2,"------------------------------\n");
fscanf(fp1,"%s",input);
while(strcmp(input,"END")!=0)
Monday, 12 December 2011
MIDDLEWARE TECHNOLOGY Questions
INTERNAL TEST – I
ELECTIVE-I
MIDDLEWARE TECHNOLOGY
SEMESTER-VI
PART A (Answer All Questions) 5X 2 = 10
2.
Remote Procedure call (RPC) Explain?
3.
Explain HTTP and ODBC?
4.
What is Enterprise Java Bean (EJB)?
5.
Define Socket.
2.Discuss
the overview of EJB Software Architecture (16).
3.
Explain the Following:
(a) Three
tier Architecture (8).
HASH FUNCTION
Hashing
is the transformation of a string of characters into a usually shorter
fixed-length value or key that represents the original string. Hashing is used
to index and retrieve items in a database because it is faster to find the item
using the shorter hashed key than to find it using the original value. It is
also used in many encryption algorithms.
Hash Function:
A
Hash Function is a Unary Function that is used by Hashed Associative
Containers: it maps its argument to a result of type size_t. A Hash Function must be deterministic and
stateless. That is, the return value must depend only on the argument, and
equal arguments must yield equal results.
Hash functions
are mostly used in hash tables, to quickly locate a data record (for
example, a dictionarydefinition) given its search
key (the headword). Specifically, the hash function is used to map
the search key to the index of a slot in the table where the corresponding
record is supposedly stored.
Division Method:
Division Method:
Saturday, 10 December 2011
Radix sort
Radix sort
Let
a be an array of n numbers. Our aim is to sort this array in ascending order
using radix sort. The steps to be followed are
i)
Initialize ten queues namely q[0], q[1],
………, q[9]. That is set rear [i] = front [i] = NULL for all I = 0, 1, 2, ……,9.
ii)
Scan the array from left to right and
find the least significant digit for all array elements.
iii)
If it is 0, push the number in q[0]; if
it is 1, push the number in q[1],….., and if it is 9, push the number in q[9].
iv)
After pushing all the elements in the
respective queues, pop up the data from 0th queue to 9th
queue and restore in the array a.
v)
Again scan the array from left to right
and find the second least significant digit for all array elements.
vi)
Repeats steps (iii) and (iv)
The repetition of the
above process depends upon the width of the maximum element in the array. That is
if the maximum width of the array element is 3, then scan the array three times
and find the 1st least significant digit and 3rd least
significant digit.
Example
Merge sort
Merge sort
Let a be an
array of n numbers. Our aim is to sort this array in ascending order using
merge sort. The steps to be followed are
i)
Divide the array into n sub arrays with
size 1.
ii)
Merge adjacent pair of sub arrays [a[1]]
and [a[2]], [a[3]] and [a[4]], …….,
[a[n-1]] and [a[n]].
Now we will get a n/2 sorted sub arrays of size 2 or less.
iii)
Merge adjacent pairs of sub arrays
[a[1]] and [a[2]], [a[3]] and [a[4]], ……., [a[n-3]], [a[n-2]] and [a[n-1
iv)
Repeat this process until ther]], [a[n]].
Now we will get a n/4 sorted sub arrays of size 4 or less.e is only one sub
array of size n.
Now this array will be
in sorted order
Example
Merge
Merge
Merging
is a process of combining two or more sorted arrays into a single sorted array.
Explanation
Suppose
A[m] and B[n] are two sorted arrays. Merging is a process of combining these
two arrays into a single sorted array C[m+n]. Steps to be followed are
i)
Scan both arrays left to right
ii)
Compare A[1] with B[1]. If A[1] is less
than B[1] put A[1] as C[1] and compare A[2] with B[1] and so on, else put B[1]
as C[1] and compare A[1] with B[2] and so on.
iii)
Repeat step ii until any one array
becomes empty.
iv)
If A array becomes empty, store all the
remaining B array elements in the same order in the C array. Besides store all
the remaining A array elements in the same order in the B array.
Procedure
Selection sort
Selection
sort
Let
A be an array of n elements A[1], A[2], …., A[n]. Our aim is to sort the
numbers in the array in ascending order. The steps are as follows
1) Find
the smallest element position in the list A[1], A[2], …., A[n] say k1
and interchange the values A[1] and A[k1]
2) Find
the smallest element position in the list A[2], A[3], ….., A[n] say k2
and interchange the values A[2] and A[k2].
3) Find
the smallest element position in the list A[3], A[4], ….., A[n] say k3
and then interchange the values A[3] and A[k3]
4) Find
the smallest element position in the list A[n-1] and A[n] say kn-1 and
then interchange the values A[n] and A[kn-1].
Example - Sort
the array A using selection sort
A
= (43, 72, 10, 23, 80, 1, 75)
Insertion sort
Insertion
sort
Let
a be an array of numbers a[1], a[2] ….. a[n]. Our aim is to sort them in
ascending order using insertion sort.
Principle
Scan
the array a from a[1] to a[n] and find the smallest elements a[r], r = 1, 2 ……,
r and insert into its proper position in the previously sorted sub array a[1],
a[2] …. a[r]. This can be explained by
the following steps.
i)
For r = 1 the previously sorted such
array is empty therefore a[1] by itself is sorted.
ii)
For r =2 , a[2] is inserted into the
proper position in the previously sorted sub array a[1] i.e.; a[2] is inserted
after or before a[1].
iii)
For r = 3, a[3] is inserted into the
proper position in the previously sorted sub array a[1], a[2]. i.e.; a[3] is
inserted either before a[1] or after a[2] or in between a[1] and a[2].
The above steps are
repeated until the last element a[n] is inserted into its proper position in
the sorted sub array. Now the given array a is in sorted order.
Example
Bubble sort
Bubble
sort
Let
a be an array of n numbers. Our aim is to sort the numbers in the array in
ascending order. The principle is to scan the array sequentially n-1 times and
in each scan do the following steps.
Scan – 1
i)
Take the first element and compare it
with the second element. If it is small don’t interchange; or else interchange
the two elements.
ii)
Then compare the second element with the
third element. If it is small don’t interchange; or else interchange the two
elements.
iii)
This process is continued till (n-1)th
element is compared with the nth element.
iv)
At the end of the first scan, the
highest element comes to the nth position.
Scan – 2
SORTING
1
Sorting
General
Concepts
A file is an ordered collection of
items.Each item in the file is called a record. The records are named as r[1],
r[2],…..r[n], where n is the size of the file.
A key is associated with each record r[i]
and through this key only we can identify
the records in the file.
Subscribe to:
Posts (Atom)