We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 8
10.
Case Studies
1 Generation of Fibonacci Number #include <stdio.h> #define SER 20 int main() {int f[100]; int i=2; f[0]=0; f[1]=1; /* f0 and f1 predefined*/ printf(“f0=%d\tf1=%d\t”, f[0], f[1]);
Finding Kth smallest element in a given set of numbers A set of numbers is given here, and required to find the Kth smallest element. The numbers can be arranged in ascending order in an array, then the Kth smallest element is the (K-1)th element in the array, since the 0th element is the first smallest element, the 1st element and so on.
Finding Kth smallest element in a given set of numbers (contd.) Step 1: Get the numbers. Step 2: Sort them in ascending order. Step 3: Ask for the K value. Step 4: Print (K-1)st value.
Study example 51. Array is sent to find the
k th smallest element in the called function find ()
Sorting by Insertion The algorithm for the insertion Sort is given below: Int I, j, x, a[n]; for(I=1; I<=n-1; I++) { x=a[1]; j=I; while (x<a [j-1]) && (j>0) {a[j]=a[j-1]; j=j-1; } a[j]=x } Study the example given in page nos. 175-178 and example 52
means 1. Thus all elements will be sorted. Algorithm for shell sort for(sep=n/2; sep>0; sep=sep/2) for(I=sep; I<n; I++) for(j=I-sep; j>=0; j=j-sep) { while (a[j]>a[j+sep]) exchange}
Introduction to Public Relations Strategic Digital and Socially Responsible Communication 2nd Edition by Janis Teruggi Page, Lawrence J Parnell ISBN 9781544392028 - Quickly download the ebook to read anytime, anywhere