Data Structures Algorithms Notes - KTUNOTES PDF
Document Details

Uploaded by FunBouzouki7591
SNGCE
Tags
Summary
These are notes on various data structure algorithms. It covers sorting techniques like quicksort and mergesort, heap implementations, and hash tables. The document also discusses hash functions and collision resolution techniques.
Full Transcript
1. While data[too_big_index] data[pivot] --too_small_index 3. If too_big_index < too_small_index swap data[too_big_index] and data[too_small_index] 4. While too_small_index > too_big_index, go to 1. 5. Swap data[too_small_index] and data[pivot_index]...
1. While data[too_big_index] data[pivot] --too_small_index 3. If too_big_index < too_small_index swap data[too_big_index] and data[too_small_index] 4. While too_small_index > too_big_index, go to 1. 5. Swap data[too_small_index] and data[pivot_index] pivot_index = 0 2 4 10 12 13 50 57 63 100 data[pivot] Downloaded from Ktunotes.in 1. #include 17. while(array[index1] array[pivotIndex] 7. int pivotIndex, temp, index1, ) index2; 22. { 8. if(firstIndex < lastIndex) 23. index2--; 9. { 24. } 10. //assigning first element index as pivot element 25. if(index1 b ) 15. end while 5. add b to the end of c 16. while ( b has elements ) 6. remove b from b 17. add b to the end of c 7. else 18. remove b from b 8. add a to the end of c 19. end while 9. remove a from a 20. return c 10. end if 21. end procedure Downloaded from Ktunotes.in Example Partition into lists of size n/2 [10, 4, 6, 3, 8, 2, 5, 7] [10, 4, 6, 3] [8, 2, 5, 7] [10, 4] [6, 3] [8, 2] [5, 7] Downloaded from Ktunotes.in Example Cont’d Merge [2, 3, 4, 5, 6, 7, 8, 10 ] [3, 4, 6, 10] [2, 5, 7, 8] [4, 10] [3, 6] [2, 8] [5, 7] Downloaded from Ktunotes.in Merge Sort 1. #include 11. b[i] = a[l2++]; 2. #define max 10 12. } 3. int a = { 10, 14, 19, 26, 27, 31, 33,13. while(l1