IDXSQSCH - scanf"%d"&n printf"Enter the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<conio.h> # /* RISHI AGARWAL INDEXED SEQUENTIAL SEARCH ROLL NO 02 SE CMPN A */ * #define max 20 # void display(int a[],int n) { int i; printf("\nLIST\n"); for(i=0;i<n;i++) printf("%d ",a[i]); } void isort(int arr[],int n) { int i,j,x; for(i=1;i<=n-1;i++) { x=arr[i]; j=i; { arr[j]=arr[j-1]; j--; } arr[j]=x; } } void idxseqsrch(int a[],int key,int k[][2],int j) { int i,start,end; for(i=0;i<j&k[i][0]if(i!=0) start=k[i-1][1]; else start=k[i][1]; end=k[i][1]; for(i=start;i<end&a[i]if(a[i]==key) printf("The elment %d is found at position %d",a[i],i); else printf("Element Not Found"); } void main() { int n,i,j,k,key[10][2],arr[max];
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
clrscr(); printf("Enter the no of data:");
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: scanf("%d",&n); printf("Enter the nos"); for(i=0;i<n;i++) scanf("%d",&arr[i]); //Displaying List display(arr,n); //Insertion Sort isort(arr,n); //Displaying Sorted List display(arr,n); for(i=0,j=0;i<n;i+=3,j++) { key[j][0]=arr[i]; key[j][1]=i; } if(i-3<n-1) { key[j][0]=arr[n-1]; key[j][1]=n-1; j++; } printf("\nINDEX VALUE"); for(i=0;i<j;i++) { printf("\n %d) %d",i,key[i][0]); } printf("\nEnter the key:"); scanf("%d",&k); idxseqsrch(arr,k,key,j); getch(); } /* OUTPUT: Enter the no of data:6 Enter the nos2 89 44 72 56 31 LIST 2 89 44 72 56 31 LIST 2 31 44 56 72 89 Enter the key:72 The elment 72 is found at position 5 */...
View Full Document

This note was uploaded on 10/25/2010 for the course CMPN SEM4 taught by Professor Thakur during the Spring '07 term at University of Mumbai.

Page1 / 2

IDXSQSCH - scanf"%d"&n printf"Enter the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online