C Program to implement bucket sort

Write C program to implement bucket sort. The idea of Bucket Sort is to divide the interval [0, 1] into n equal-sized sub intervals, or buckets, and then distribute the n input numbers into the buckets. To produce the output, we simply sort the numbers in each bucket and then go through the buckets in …

C program to sort a string

C Strings: Write a C program to sort a string. In this program we sort the string using bubble sort technique. Bubble Sort is the simplest and easiest sorting technique. In this technique, the two successive items A[i] and A[i+1] are exchanged whenever A[i]>=A[i+1]. The larger values sink to the bottom of the array and …

C Program to implement address calculation sort.

Write a C Program to implement address calculation sort.Address calculation sort is the sorting method which sorts the given array by using insertion method.In this algorithm, a hash function is used and applied to the each key. Result of hash function is placed in the linked lists. The hash function must be a order preserving …

K&R C Programs Exercise 5-15

Exercise 5-15. Add the option -f to fold upper and lower case together, so that case distinctions are not made during sorting; for example, a and A compare equal. Add a fold flag. When set, the comparison function converts both characters to lowercase before comparing. The key: don’t modify the strings themselves — do the …

K&R C Programs Exercise 5-16

Exercise 5-16. Add the -d (directory order) option, which makes comparisons only on letters, numbers and blanks. Make sure it works in conjunction with -f. Directory order ignores punctuation and control characters — only alphanumeric characters and spaces are considered. The comparison function skips non-directory characters in both strings simultaneously, then compares the next significant …

K&R C Programs Exercise 5-14

Exercise 5-14. Modify the sort program to handle a -r flag, which indicates sorting in reverse (decreasing) order. Be sure that -r works with -n. The K&R sort from Section 5.11 calls qsort with a comparison function strcmp. Adding -r requires the comparison function to negate its result. The cleanest approach: add a global flag …