Data Structures using C - Solved Data Structure Examples

Data Structures Using C

Section I - Data structures using C

Assignment 1: Sorting Techniques (Non recursive)

Set A

  1. Sort a random array of n integers (accept the value of n from user) in ascending order by using bubble sort algorithm.
  2. Sort a random array of n integers (accept the value of n from user) in ascending order by using insertion sort algorithm.

Set B

  1. Read the data from the file “employee.txt” and sort on age using insertion sort / bubble sort.
  2. Read the data from the file “employee.txt” and sort on names in alphabetical order (use strcmp) using bubble sort / insertion sort.

Set C



  1. What modification is required to insertion sort to sort the integers in descending order ?
  2. What modifications are required to bubble sort to sort the integers in descending order ?
  3. What modifications are required to bubble sort to count the number of swaps?
  4. What modifications are required to insertion sort to count the number of key comparisons ?
  5. What modifications are required to improve bubble sort to stop further passes if the file is already sorted that is when there are no more swaps ?
  6. Compare the system time taken by insertion sort and bubble sort by using 'time' command on a random file of size 10000 or more.
    $ time ./a.out
  7. What modifications are required to output the array contents after every pass of the sorting algorithm ?

Get Answers Here:

C Programming Questions On Sorting Techniques (Non Recursive)

Comments