Data Structures using C - Solved Data Structure Examples
![Data Structures Using C](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAXNOL3Q6j3fo8UksYT7FlWk3zQsyOuyQkhzjChcUED95s6bE2VhpKpTZA8Z_Nb5IiAjWnteEg6EBv3bnX4iCW54pAlqqWhdUQvBqR6PeEmmiLB9buHP4QNwm_jDRBrfoMaYXodU0FiWW6/s1600/Adobe_Post_20180715_201652.jpg)
Section I - Data structures using C
Assignment 1: Sorting Techniques (Non recursive)
Set A
- Sort a random array of n integers (accept the value of n from user) in ascending order by using bubble sort algorithm.
- Sort a random array of n integers (accept the value of n from user) in ascending order by using insertion sort algorithm.
Set B
- Read the data from the file “employee.txt” and sort on age using insertion sort / bubble sort.
- Read the data from the file “employee.txt” and sort on names in alphabetical order (use strcmp) using bubble sort / insertion sort.
Set C
- What modification is required to insertion sort to sort the integers in descending order ?
- What modifications are required to bubble sort to sort the integers in descending order ?
- What modifications are required to bubble sort to count the number of swaps?
- What modifications are required to insertion sort to count the number of key comparisons ?
- 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 ?
- 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 - What modifications are required to output the array contents after every pass of the sorting algorithm ?
Comments