Sunday, April 25, 2010

Index Sequential Search

#include


#define MAX 24

void createIndex(int index[],int isize,int arr[],int asize)
{
int i,j;

for(i=0,j=0;i
{
index[j]= arr[i];
}
index[j] = arr[asize-1];
}

int indexSeqSearch(int val, int index[], int isize, int arr[], int asize)
{
int i=0,j=0,pos=0;
int high=0,low=0;
if(val > index[isize-1] && val < index[0])
return -1;

while(i
{
if(val == index[i])
{
pos = 8 * i;
return pos;
}

if(val < index[i])
{
low = 8 * (i-1);
high = 8 * i;
break;
}

else
{
low = 8 * i;
high = 8 * (i+1);
}
i++;
}

while(low < high)
{
if(val == arr[low])
return low;
else
low++;
}
return -1;
}



int main()
{
int arr[MAX]={ 8,14,26,38,72,115,306,321,329,387,409,512,540,567,583,592,602,611,618,741,798,811,814,876};

int index[(MAX/8)+1]={0};
createIndex(&index[0],(MAX/8)+1,&arr[0],MAX);
int opt=0,pos=0;
while(opt < MAX)
{
pos = indexSeqSearch(arr[opt],&index[0],(MAX/8)+1,&arr[0],MAX);
if( pos != -1)
{
printf("\n%d found at position %d",arr[opt],pos);
}
else
printf("\n%d not found.",arr[opt]);
opt++;

}
return 0;
}

PL Practical Exam Variation List

1. Perform Set operations using arrays


2. Perform Set operations using linked list

3. String operations without using standard library functions

4. Matrix operations : Add, Sub, Multiply, Saddle Point

5. Matrix operations : Add, Sub, Multiply, Transpose

6. Matrix operations : Add, Sub, Transpose, Check for Magic Square

7. Matrix operations : Multiplication, Transpose, Check for magic Square

8. Create a Database using array of structures and perform following operations

a. Add

b. Delete

c. Modify

d. Display

e. Search and

f. Sort

9. Create a Database using text files and perform following operations

a. Add

b. Delete

c. Modify

d. Display

e. Search and

f. Sort

10. Implement Sorting methods using functions

a. Bubble

b. Selection

11. Implement Sorting methods using functions

a. Bubble

b. Insertion

12. Implement Sorting methods using functions

a. Insertion

b. Selection

13. Implement Sorting methods using functions

a. Shell Sort

b. Bubble Sort

14. Implement Sorting methods using functions

a. Shell Sort

b. Selection

15. Implement Sorting methods using functions

a. Shell

b. Insertion

16. Implement sorting methods using recursion

a. Quick Sort

b. Merge Sort

17. Implement Searching Methods

a. Sequential Search

b. Binary Search

18. Implement Searching Methods

a. Indexed Sequential Search

b. Binary Search

19. Implement Searching Methods

a. Sequential Search

b. Fibonacci Search

20. Represent Polynomial using structures and write a menu driven program to perform addition, Multiplication and Evaluation

21. Represent Sparse matrix using array and perform matrix addition, simple and fast transpose

22. Create SLL and Write a menu driven program to perform operations on it like

a. insert an element: at start, In between, At end

b. Search

c. Delete

d. Reverse

e. Display

23. Create CLL and Write a menu driven program to perform operations on it like

a. insert an element : at start, In between, At end

b. Search

c. Delete

d. Reverse

e. Display

24. Create DLL and Write a menu driven program to perform operations on it like

a. insert an element: at start, In between, At end

b. Search

c. Delete

d. Reverse

e. Display

25. Create CDLL and Write a menu driven program to perform operations on it like

a. insert an element: at start, In between, At end

b. Search

c. Delete

d. Reverse

e. Display

26. Create two SLLs, sort one after creation and one while creation using pointer manipulation. Merge these two lists into one list without creating a new node or swapping of the data

27. Create two DLLs, sort one after creation and one while creation using pointer manipulation. Merge these two lists into one list without creating a new node or swapping of the data

28. Represent Polynomial using CLL and write a menu driven program to perform addition, Multiplication and Evaluation

29. Implement stack as an ADT using array. Use this ADT to perform expression conversion and evaluation- Prefix to postfix

30. Implement stack as an ADT using array. Use this ADT to perform expression conversion and evaluation- Postfix to Prefix

31. Implement stack as an ADT using array. Use this ADT to check the correctness of parenthesized expression e.g. (a))-wrong, (a+b)+c-correct

32. Represent a circular queue using linked list and write a program to perform operations like Insert, Delete, finding front and rear element

33. Create a Database using linked list and perform following operations

a. Add

b. Delete

c. Modify

d. Display

e. Search and

f. Sort