├── Unit_1 ├── Unit-1_1.pdf └── Unit-1_2.pdf ├── Unit_2 ├── String_Ops │ ├── a.exe │ ├── concat.exe │ ├── str_copy.exe │ ├── concat_DMA.exe │ ├── Length_of_str.exe │ ├── reversing_normal.exe │ ├── Comparing_a_string.exe │ ├── Str_len_recursion.exe │ ├── reversing_pointers.exe │ ├── length_of_str_sentence.exe │ ├── Str_len_recursion.c │ ├── Length_of_str.c │ ├── strlen_input.c │ ├── reversing_normal.c │ ├── reversing_pointers.c │ ├── str_copy.c │ ├── concat.c │ ├── concat_DMA.c │ └── Comparing_a_string.c ├── Notes │ ├── UNIT-2_1.pdf │ ├── Unit-2_2.pdf │ ├── Unit-2_3.pdf │ ├── Unit-2_4.pdf │ ├── Unit-2_5.pdf │ ├── Unit-2_5_1.pdf │ ├── Class_1_Insertion Sorting.pdf │ └── Class2_Asymptotic Notations.pdf ├── Searching_Techniques │ ├── Binary_Search.exe │ ├── Linear_Search.exe │ ├── Linear_Search.c │ └── Binary_Search.c └── Sorting_Algorithms │ ├── insertion_sort.c │ ├── bubble_sort.c │ ├── selection_sort.c │ ├── quick_sort.c │ ├── Heap_Sort.c │ └── merge_sort.c ├── .idea ├── DSC-CSVTU-Sem2.iml ├── vcs.xml ├── .gitignore └── modules.xml ├── Quizzes └── Question_2024_04_04__05_55_QZ_Data Structure _Test1.pdf ├── Lab_Files ├── Lab_2 │ ├── contents │ ├── Linear_Search.c │ └── Binary_search.c └── Lab_1 │ ├── Finding_length.c │ ├── String_copy.c │ ├── Contents │ ├── reversing_a_string.c │ ├── concatenating_Strings.c │ ├── Finding_occurences.c │ └── checking_for_palindrome.c ├── .vscode └── tasks.json └── README.md /Unit_1/Unit-1_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_1/Unit-1_1.pdf -------------------------------------------------------------------------------- /Unit_1/Unit-1_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_1/Unit-1_2.pdf -------------------------------------------------------------------------------- /Unit_2/String_Ops/a.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/String_Ops/a.exe -------------------------------------------------------------------------------- /Unit_2/Notes/UNIT-2_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/Notes/UNIT-2_1.pdf -------------------------------------------------------------------------------- /Unit_2/Notes/Unit-2_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/Notes/Unit-2_2.pdf -------------------------------------------------------------------------------- /Unit_2/Notes/Unit-2_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/Notes/Unit-2_3.pdf -------------------------------------------------------------------------------- /Unit_2/Notes/Unit-2_4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/Notes/Unit-2_4.pdf -------------------------------------------------------------------------------- /Unit_2/Notes/Unit-2_5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/Notes/Unit-2_5.pdf -------------------------------------------------------------------------------- /Unit_2/Notes/Unit-2_5_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/Notes/Unit-2_5_1.pdf -------------------------------------------------------------------------------- /Unit_2/String_Ops/concat.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/String_Ops/concat.exe -------------------------------------------------------------------------------- /.idea/DSC-CSVTU-Sem2.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unit_2/String_Ops/str_copy.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/String_Ops/str_copy.exe -------------------------------------------------------------------------------- /Unit_2/String_Ops/concat_DMA.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/String_Ops/concat_DMA.exe -------------------------------------------------------------------------------- /Unit_2/String_Ops/Length_of_str.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/String_Ops/Length_of_str.exe -------------------------------------------------------------------------------- /Unit_2/String_Ops/reversing_normal.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/String_Ops/reversing_normal.exe -------------------------------------------------------------------------------- /Unit_2/String_Ops/Comparing_a_string.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/String_Ops/Comparing_a_string.exe -------------------------------------------------------------------------------- /Unit_2/String_Ops/Str_len_recursion.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/String_Ops/Str_len_recursion.exe -------------------------------------------------------------------------------- /Unit_2/String_Ops/reversing_pointers.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/String_Ops/reversing_pointers.exe -------------------------------------------------------------------------------- /Unit_2/Notes/Class_1_Insertion Sorting.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/Notes/Class_1_Insertion Sorting.pdf -------------------------------------------------------------------------------- /Unit_2/Notes/Class2_Asymptotic Notations.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/Notes/Class2_Asymptotic Notations.pdf -------------------------------------------------------------------------------- /Unit_2/Searching_Techniques/Binary_Search.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/Searching_Techniques/Binary_Search.exe -------------------------------------------------------------------------------- /Unit_2/Searching_Techniques/Linear_Search.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/Searching_Techniques/Linear_Search.exe -------------------------------------------------------------------------------- /Unit_2/String_Ops/length_of_str_sentence.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Unit_2/String_Ops/length_of_str_sentence.exe -------------------------------------------------------------------------------- /Quizzes/Question_2024_04_04__05_55_QZ_Data Structure _Test1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxprogrammer007/DSC-CSVTU-Sem2/main/Quizzes/Question_2024_04_04__05_55_QZ_Data Structure _Test1.pdf -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /Lab_Files/Lab_2/contents: -------------------------------------------------------------------------------- 1 | Implement the following 2 | 3 | 1) Searching and Sorting methods: Searching: Sequential/Linear Search and Binary Search. 4 | 2) Sorting: Bubble Sort , Insertion Sort, Selection Sort, Merge Sort, Heap Sort and Quick Sort -------------------------------------------------------------------------------- /Lab_Files/Lab_1/Finding_length.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char str[] = "hello"; 5 | int length; 6 | 7 | // Calculating length 8 | for (length = 0; str[length] != '\0'; length++); 9 | 10 | printf("Length of String: %d\n", length); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Lab_Files/Lab_1/String_copy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char src[] = "hello"; 5 | char dest[100]; 6 | int i; 7 | 8 | // Copying the string 9 | for (i = 0; src[i] != '\0'; i++) { 10 | dest[i] = src[i]; 11 | } 12 | dest[i] = '\0'; 13 | 14 | printf("Copied String: %s\n", dest); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Unit_2/String_Ops/Str_len_recursion.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int str_len(char *string); 4 | 5 | int main(){ 6 | char string1[] = "abcde"; 7 | int string1_length = str_len(string1); 8 | printf("The length of the given string is %d", string1_length); 9 | return 0; 10 | } 11 | 12 | int str_len(char *string) 13 | { 14 | if( * string == '\0') return 0; 15 | else return 1 + str_len(string + 1); 16 | } -------------------------------------------------------------------------------- /Unit_2/String_Ops/Length_of_str.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int str_len(char *string); 4 | 5 | int main() { 6 | char *s1 ="This is the string"; 7 | int our_length = str_len(s1); 8 | 9 | printf("Our Length : %d \n",our_length); 10 | 11 | return 0; 12 | } 13 | 14 | int str_len(char *string){ 15 | int length = 0; 16 | while(string[length] != '\0') 17 | { 18 | length++; 19 | } 20 | return length; 21 | } -------------------------------------------------------------------------------- /Lab_Files/Lab_1/Contents: -------------------------------------------------------------------------------- 1 | String Operations in C 2 | 3 | >> String Copy: Copies one string into another. 4 | >> Finding Length: Determines the length of a string. 5 | >> Reversing a String: Reverses the order of characters in a string. 6 | >> Checking for Palindrome: Checks if a string is the same when read forwards and backwards. 7 | >> Concatenating Strings: Combines two strings end to end. 8 | >> Finding the Occurrence of a Sub-string: Searches for a sub-string within a larger string. -------------------------------------------------------------------------------- /Unit_2/String_Ops/strlen_input.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int stringLength(char *str) { 5 | int length = 0; 6 | 7 | while (*str != '\0') { 8 | length++; 9 | str++; 10 | } 11 | return length; 12 | } 13 | 14 | int main() { 15 | char str[100]; 16 | printf("Enter a string: "); 17 | scanf("%s", str); 18 | 19 | int length = stringLength(str); 20 | printf("Length of string: %d\n", length); 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /Lab_Files/Lab_1/reversing_a_string.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char str[] = "hello"; 5 | char reversed[100]; 6 | int length, i; 7 | 8 | // Finding the length of the string 9 | for (length = 0; str[length] != '\0'; length++); 10 | 11 | // Reversing the string 12 | for (i = 0; i < length; i++) { 13 | reversed[i] = str[length - 1 - i]; 14 | } 15 | reversed[length] = '\0'; 16 | 17 | printf("Reversed String: %s\n", reversed); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Unit_2/String_Ops/reversing_normal.c: -------------------------------------------------------------------------------- 1 | #include 2 | void reverse(char *string){ 3 | int length = strlen(string); 4 | int middle = length/2; 5 | 6 | char temp; 7 | for(int i = 0; i < middle; i++){ 8 | temp = string[i]; 9 | string[i] = string[length -i-1]; 10 | string[length - i - 1] = temp; 11 | } 12 | } 13 | int main() { 14 | 15 | char test[] = "Hello_This_is_string"; 16 | 17 | reverse(test); 18 | 19 | printf("%s",test); 20 | 21 | return 0; 22 | 23 | } -------------------------------------------------------------------------------- /Unit_2/Sorting_Algorithms/insertion_sort.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Administrator on 11-Apr-24. 3 | // 4 | #include 5 | 6 | int main(void){ 7 | int a[] = {5, 2, 4, 6, 1, 3}; 8 | int n = 6; 9 | int i, j, key; 10 | 11 | for(i = 1; i < n; i++){ 12 | key = a[i]; 13 | j = i - 1; 14 | while(j >= 0 && a[j] > key){ 15 | a[j + 1] = a[j]; 16 | j = j - 1; 17 | } 18 | a[j + 1] = key; 19 | } 20 | 21 | for(i = 0; i < n; i++){ 22 | printf("%d ", a[i]); 23 | } 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Unit_2/Sorting_Algorithms/bubble_sort.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Administrator on 11-Apr-24. 3 | // 4 | 5 | #include 6 | int main(void){ 7 | int a[] = {5, 2, 4, 6, 1, 3}; 8 | int n = 6; 9 | int i, j, temp; 10 | 11 | for(i = 0; i < n; i++){ 12 | for(j = 0; j < n - i - 1; j++){ 13 | if(a[j] > a[j + 1]){ 14 | temp = a[j]; 15 | a[j] = a[j + 1]; 16 | a[j + 1] = temp; 17 | } 18 | } 19 | } 20 | 21 | for(i = 0; i < n; i++){ 22 | printf("%d ", a[i]); 23 | } 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Lab_Files/Lab_1/concatenating_Strings.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char first[] = "hello"; 5 | char second[] = " world"; 6 | char concatenated[200]; 7 | int i, j; 8 | 9 | // Copying the first string 10 | for (i = 0; first[i] != '\0'; i++) { 11 | concatenated[i] = first[i]; 12 | } 13 | 14 | // Concatenating the second string 15 | for (j = 0; second[j] != '\0'; j++, i++) { 16 | concatenated[i] = second[j]; 17 | } 18 | concatenated[i] = '\0'; 19 | 20 | printf("Concatenated String: %s\n", concatenated); 21 | return 0; 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /Unit_2/Sorting_Algorithms/selection_sort.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Administrator on 11-Apr-24. 3 | // 4 | #include 5 | 6 | int main(void){ 7 | int a[] = {5, 2, 4, 6, 1, 3}; 8 | int n = 6; 9 | int i, j, temp, min; 10 | 11 | for(i = 0; i < n - 1; i++){ 12 | min = i; 13 | for(j = i + 1; j < n; j++){ 14 | if(a[j] < a[min]){ 15 | min = j; 16 | } 17 | } 18 | temp = a[i]; 19 | a[i] = a[min]; 20 | a[min] = temp; 21 | } 22 | 23 | for(i = 0; i < n; i++){ 24 | printf("%d ", a[i]); 25 | } 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Unit_2/String_Ops/reversing_pointers.c: -------------------------------------------------------------------------------- 1 | #include 2 | void reverse(char *string) 3 | { 4 | if(string == NULL) return ; 5 | char *end = string; 6 | 7 | if(*end == '\0') return ; 8 | 9 | while(*end != '\0'){ 10 | end++; 11 | } 12 | end--; 13 | 14 | 15 | char *start = string; 16 | char temp ; 17 | while(start < end){ 18 | temp = *start; 19 | *start = *end; 20 | *end = temp; 21 | 22 | start++; 23 | end--; 24 | } 25 | } 26 | int main() 27 | { 28 | char string[] = "abcde"; 29 | reverse(string); 30 | printf("%s",string); 31 | 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Unit_2/String_Ops/str_copy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *str_cpy1(char *dest, const char *source) 5 | { 6 | if(dest == NULL) return NULL; 7 | 8 | 9 | int i = 0; 10 | while(source[i] != '\0'){ 11 | dest[i] = source[i]; 12 | i++; 13 | } 14 | dest[i] = '\0'; 15 | 16 | return dest; 17 | } 18 | int main() 19 | { 20 | char src[] = "Copy This"; 21 | char dest[100]; 22 | 23 | char *dest_ptr = str_cpy1(dest,src); 24 | 25 | printf(" src : %s \n",src); 26 | printf(" dest: %s\n",dest); 27 | printf("dest_ptr : %s\n", dest_ptr); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Lab_Files/Lab_1/Finding_occurences.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char str[] = "hello world"; 5 | char substr[] = "world"; 6 | int i, j, found = -1; 7 | 8 | // Searching for the sub-string 9 | for (i = 0; str[i] != '\0' && found == -1; i++) { 10 | for (j = 0; substr[j] != '\0'; j++) { 11 | if (str[i + j] != substr[j]) break; 12 | } 13 | if (substr[j] == '\0') found = i; 14 | } 15 | 16 | if (found != -1) { 17 | printf("Sub-string found at position: %d\n", found); 18 | } else { 19 | printf("Sub-string not found.\n"); 20 | } 21 | 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Unit_2/String_Ops/concat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *_strcat(char *dest, const char *source); 5 | 6 | int main() 7 | { 8 | char dest[1024] = "first"; 9 | char source[] = "second"; 10 | 11 | _strcat(dest,source); 12 | printf("Result: %s \n", dest); 13 | } 14 | 15 | char *_strcat(char *dest, const char *source) 16 | { 17 | int i = 0, j = 0; 18 | 19 | while (dest[i] != '\0') 20 | { 21 | i++; 22 | } 23 | 24 | while(source[j] != '\0') 25 | { 26 | dest[i] = source[j]; 27 | i++; 28 | j++; 29 | } 30 | dest[i] = '\0'; 31 | 32 | return dest; 33 | 34 | 35 | } -------------------------------------------------------------------------------- /Lab_Files/Lab_1/checking_for_palindrome.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() { 5 | char str[] = "radar"; 6 | int length, i, isPalindrome = 1; 7 | 8 | // Finding the length of the string 9 | for (length = 0; str[length] != '\0'; length++); 10 | 11 | // Checking for palindrome 12 | for (i = 0; i < length / 2; i++) { 13 | if (str[i] != str[length - 1 - i]) { 14 | isPalindrome = 0; 15 | break; 16 | } 17 | } 18 | 19 | if (isPalindrome) { 20 | printf("The string is a palindrome.\n"); 21 | } else { 22 | printf("The string is not a palindrome.\n"); 23 | } 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Lab_Files/Lab_2/Linear_Search.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int linearSearch(int arr[], int size, int target) { 4 | for (int i = 0; i < size; i++) { 5 | if (arr[i] == target) { 6 | return i; // Target found at index i 7 | } 8 | } 9 | return -1; // Target not found 10 | } 11 | 12 | int main() { 13 | int array[] = {2, 4, 5, 7, 9, 12, 14}; 14 | int target = 9; 15 | int size = sizeof(array) / sizeof(array[0]); 16 | int result = linearSearch(array, size, target); 17 | if (result != -1) { 18 | printf("Element found at index: %d\n", result); 19 | } else { 20 | printf("Element not found in the array\n"); 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /Unit_2/String_Ops/concat_DMA.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | char *str_cat(char *s1 , char *s2); 5 | 6 | int main() { 7 | char s1[] = "abc"; 8 | char s2[] = "wxcv"; 9 | printf("%s",str_cat(s1 , s2)); 10 | 11 | return 0; 12 | } 13 | 14 | char *str_cat(char *s1 , char *s2){ 15 | int s1_length = strlen(s1); 16 | int s2_length = strlen(s2); 17 | int size = s1_length + s2_length + 1; 18 | 19 | char *s = calloc(size, sizeof(char)); 20 | 21 | for(int i = 0 ; i < s1_length ; i++){ 22 | s[i] = s1[i]; 23 | } 24 | 25 | for(int i = 0 ; i < s2_length ;i++){ 26 | s[s1_length + i] = s2[i]; 27 | } 28 | s[size - 1] = '\0'; 29 | free(s); 30 | 31 | return s; 32 | } -------------------------------------------------------------------------------- /Unit_2/String_Ops/Comparing_a_string.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int compare(char str1[], char str2[]) 5 | { 6 | int i = 0; 7 | int cmp=0; 8 | 9 | while(str1[i] != '\0' && str2[i] != '\0') 10 | { 11 | if(str1[i] != str2[i]){ 12 | cmp = 1; 13 | break; 14 | } 15 | i++; 16 | } 17 | 18 | if(cmp == 0 && str1[i] == '\0' && str2[i] == '\0'){ 19 | return 1; 20 | 21 | } 22 | else 23 | return 0; 24 | } 25 | 26 | int main() 27 | { 28 | char name1[20], name2[20]; 29 | gets(name1); 30 | gets(name2); 31 | 32 | compare(name1, name2); 33 | 34 | if(compare(name1,name2) == 1 ){ 35 | printf("same"); 36 | } 37 | 38 | else 39 | printf("Not same"); 40 | 41 | return 0; 42 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "type": "cppbuild", 5 | "label": "C/C++: gcc.exe build active file", 6 | "command": "C:\\msys64\\ucrt64\\bin\\gcc.exe", 7 | "args": [ 8 | "-fdiagnostics-color=always", 9 | "-g", 10 | "${file}", 11 | "-o", 12 | "${fileDirname}\\${fileBasenameNoExtension}.exe" 13 | ], 14 | "options": { 15 | "cwd": "${fileDirname}" 16 | }, 17 | "problemMatcher": [ 18 | "$gcc" 19 | ], 20 | "group": { 21 | "kind": "build", 22 | "isDefault": true 23 | }, 24 | "detail": "Task generated by Debugger." 25 | } 26 | ], 27 | "version": "2.0.0" 28 | } -------------------------------------------------------------------------------- /Unit_2/Searching_Techniques/Linear_Search.c: -------------------------------------------------------------------------------- 1 | // Implementing Linear Search in C 2 | #include 3 | 4 | int linearSearch(int arr[], int size, int target) { 5 | for (int i = 0; i < size; i++) { 6 | if (arr[i] == target) { 7 | return i; // Target found at index i 8 | } 9 | } 10 | return -1; // Target not found 11 | } 12 | 13 | int main() { 14 | int n; 15 | printf("Enter the size of the array: "); 16 | scanf("%d", &n); 17 | int array[n]; 18 | printf("Enter the elements of the array: "); 19 | for (int i = 0; i < n; i++) { 20 | scanf("%d", &array[i]); 21 | } 22 | int target; 23 | printf("Enter the target element: "); 24 | scanf("%d", &target); 25 | 26 | int size = sizeof(array) / sizeof(array[0]); 27 | int result = linearSearch(array, size, target); 28 | if (result != -1) { 29 | printf("Element found at index: %d\n", result); 30 | } else { 31 | printf("Element not found in the array\n"); 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Unit_2/Sorting_Algorithms/quick_sort.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Administrator on 16-Apr-24. 3 | // 4 | 5 | #include 6 | 7 | void swap(int *a, int *b){ 8 | int temp = *a; 9 | *a = *b; 10 | *b = temp; 11 | } 12 | 13 | int partition(int a[], int low, int high){ 14 | int pivot = a[high]; 15 | int i = low - 1; 16 | int j; 17 | 18 | for(j = low; j <= high - 1; j++){ 19 | if(a[j] < pivot){ 20 | i++; 21 | swap(&a[i], &a[j]); 22 | } 23 | } 24 | 25 | swap(&a[i + 1], &a[high]); 26 | 27 | return i + 1; 28 | } 29 | 30 | void quick_sort(int a[], int low, int high){ 31 | if(low < high){ 32 | int pi = partition(a, low, high); 33 | 34 | quick_sort(a, low, pi - 1); 35 | quick_sort(a, pi + 1, high); 36 | } 37 | } 38 | 39 | int main(void){ 40 | int a[] = {5, 2, 4, 6, 1, 3}; 41 | int n = 6; 42 | int i; 43 | 44 | quick_sort(a, 0, n - 1); 45 | 46 | for(i = 0; i < n; i++){ 47 | printf("%d ", a[i]); 48 | } 49 | 50 | return 0; 51 | } -------------------------------------------------------------------------------- /Lab_Files/Lab_2/Binary_search.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int binarySearch(int arr[], int left, int right, int target) { 4 | while (left <= right) { 5 | int mid = left + (right - left) / 2; 6 | 7 | // Check if target is present at mid 8 | if (arr[mid] == target) { 9 | return mid; 10 | } 11 | 12 | // If target greater, ignore left half 13 | if (arr[mid] < target) { 14 | left = mid + 1; 15 | } 16 | // If target is smaller, ignore right half 17 | else { 18 | right = mid - 1; 19 | } 20 | } 21 | 22 | // Target not found 23 | return -1; 24 | } 25 | 26 | int main() { 27 | int array[] = {2, 4, 5, 7, 9, 12, 14}; 28 | int target = 9; 29 | int size = sizeof(array) / sizeof(array[0]); 30 | int result = binarySearch(array, 0, size - 1, target); 31 | if (result != -1) { 32 | printf("Element found at index: %d\n", result); 33 | } else { 34 | printf("Element not found in the array\n"); 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /Unit_2/Sorting_Algorithms/Heap_Sort.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Administrator on 11-Apr-24. 3 | // 4 | #include 5 | 6 | void heapify(int a[], int n, int i){ 7 | int largest = i; 8 | int left = 2 * i + 1; 9 | int right = 2 * i + 2; 10 | int temp; 11 | 12 | if(left < n && a[left] > a[largest]){ 13 | largest = left; 14 | } 15 | 16 | if(right < n && a[right] > a[largest]){ 17 | largest = right; 18 | } 19 | 20 | if(largest != i){ 21 | temp = a[i]; 22 | a[i] = a[largest]; 23 | a[largest] = temp; 24 | heapify(a, n, largest); 25 | } 26 | } 27 | 28 | void heap_sort(int a[], int n){ 29 | int i, temp; 30 | 31 | for(i = n / 2 - 1; i >= 0; i--){ 32 | heapify(a, n, i); 33 | } 34 | 35 | for(i = n - 1; i >= 0; i--){ 36 | temp = a[0]; 37 | a[0] = a[i]; 38 | a[i] = temp; 39 | heapify(a, i, 0); 40 | } 41 | } 42 | 43 | int main(void){ 44 | int a[] = {5, 2, 4, 6, 1, 3}; 45 | int n = 6; 46 | int i; 47 | 48 | heap_sort(a, n); 49 | 50 | for(i = 0; i < n; i++){ 51 | printf("%d ", a[i]); 52 | } 53 | 54 | return 0; 55 | } -------------------------------------------------------------------------------- /Unit_2/Sorting_Algorithms/merge_sort.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Administrator on 13-Apr-24. 3 | // 4 | 5 | #include 6 | 7 | void merge(int a[], int l, int m, int r){ 8 | int i, j, k; 9 | int n1 = m - l + 1; 10 | int n2 = r - m; 11 | int L[n1], R[n2]; 12 | 13 | for(i = 0; i < n1; i++){ 14 | L[i] = a[l + i]; 15 | } 16 | 17 | for(j = 0; j < n2; j++){ 18 | R[j] = a[m + 1 + j]; 19 | } 20 | 21 | i = 0; 22 | j = 0; 23 | k = l; 24 | 25 | while(i < n1 && j < n2){ 26 | if(L[i] <= R[j]){ 27 | a[k] = L[i]; 28 | i++; 29 | }else{ 30 | a[k] = R[j]; 31 | j++; 32 | } 33 | k++; 34 | } 35 | 36 | while(i < n1){ 37 | a[k] = L[i]; 38 | i++; 39 | k++; 40 | } 41 | 42 | while(j < n2){ 43 | a[k] = R[j]; 44 | j++; 45 | k++; 46 | } 47 | } 48 | 49 | void merge_sort(int a[], int l, int r){ 50 | if(l < r){ 51 | int m = l + (r - l) / 2; 52 | 53 | merge_sort(a, l, m); 54 | merge_sort(a, m + 1, r); 55 | 56 | merge(a, l, m, r); 57 | } 58 | } 59 | 60 | int main(void){ 61 | int a[] = {5, 2, 4, 6, 1, 3}; 62 | int n = 6; 63 | int i; 64 | 65 | merge_sort(a, 0, n - 1); 66 | 67 | for(i = 0; i < n; i++){ 68 | printf("%d ", a[i]); 69 | } 70 | 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |

Data Structures with C

3 | 4 | 5 |

Welcome to the repository for the Data Structures with C course at UTD-CSVTU ! Here, you'll find resources, lab files, class codes, and more to help you excel in your studies of data structures.

6 | 7 | 8 | 9 | 10 | 11 | ## Table of Contents 12 | - [Folders](#folders) 13 | - [Lab Files](#lab-files) 14 | - [Unit-wise Folders](#unit-wise-folders) 15 | - [Quizzes](#quizzes) 16 | - [Faculties](#faculties) 17 | - [Lectures](#lectures) 18 | - [Labs](#labs) 19 | 20 | 21 | ## Folders 22 | 23 | ### Lab Files 24 | In this folder, you'll find all the lab files and codes related to the practical sessions conducted in our labs. These resources are invaluable for hands-on learning and experimentation. 25 | 26 | ### Unit-wise Folders 27 | Here, you'll discover unit-specific notes, class codes, and concept implementations organized neatly into individual folders. These materials will aid in your understanding and mastery of each topic covered in the course. 28 | 29 | ### Quizzes 30 | Prepare for casual class tests by accessing question papers uploaded here. These quizzes, provided by our esteemed faculty, offer an opportunity to assess your knowledge and comprehension of the subject matter. 31 | 32 | 33 | ## Faculties 34 | 35 | ### Lectures 36 | - **Dr. JP Patra**\ 37 | Dr. Patra leads the lectures for this course, bringing a wealth of knowledge and experience to the classroom. His expertise ensures that you receive comprehensive instruction and guidance throughout your learning journey. 38 | 39 | ### Labs 40 | - **Mr. Abhinaw Jagtap**\ 41 | Mr. Jagtap oversees the practical sessions in the lab, offering valuable insights and assistance as you engage with data structures firsthand. His support ensures a conducive environment for exploration and learning. 42 | 43 | -------------------------------------------------------------------------------- /Unit_2/Searching_Techniques/Binary_Search.c: -------------------------------------------------------------------------------- 1 | // Implementing binary search in C 2 | 3 | #include 4 | 5 | int binarySearch(int arr[], int size, int target) { 6 | int left = 0; 7 | int right = size - 1; 8 | while (left <= right) { 9 | int mid = left + (right - left) / 2; 10 | if (arr[mid] == target) { 11 | return mid; 12 | } 13 | if (arr[mid] < target) { 14 | left = mid + 1; 15 | } else { 16 | right = mid - 1; 17 | } 18 | } 19 | return -1; 20 | } 21 | 22 | int main() { 23 | int array[] = {2, 4, 5, 7, 9, 12, 14}; 24 | int target = 9; 25 | int size = sizeof(array) / sizeof(array[0]); 26 | int result = binarySearch(array, size, target); 27 | if (result != -1) { 28 | printf("Element found at index: %d\n", result); 29 | } else { 30 | printf("Element not found in the array\n"); 31 | } 32 | return 0; 33 | } 34 | 35 | // another way to implement binary search 36 | // #include 37 | 38 | // int binarySearch(int arr[], int left, int right, int target) { 39 | // while (left <= right) { 40 | // int mid = left + (right - left) / 2; 41 | 42 | // // Check if target is present at mid 43 | // if (arr[mid] == target) { 44 | // return mid; 45 | // } 46 | 47 | // // If target greater, ignore left half 48 | // if (arr[mid] < target) { 49 | // left = mid + 1; 50 | // } 51 | // // If target is smaller, ignore right half 52 | // else { 53 | // right = mid - 1; 54 | // } 55 | // } 56 | 57 | // // Target not found 58 | // return -1; 59 | // } 60 | 61 | // int main() { 62 | // int n; 63 | // printf("Enter the size of the array: "); 64 | // scanf("%d", &n); 65 | // int array[n]; 66 | // printf("Enter the elements of the array: "); 67 | // for (int i = 0; i < n; i++) { 68 | // scanf("%d", &array[i]); 69 | // } 70 | // int target; 71 | // printf("Enter the target element: "); 72 | // scanf("%d", &target); 73 | 74 | // int size = sizeof(array) / sizeof(array[0]); 75 | // int result = binarySearch(array, 0, size - 1, target); 76 | // if (result != -1) { 77 | // printf("Element found at index: %d\n", result); 78 | // } else { 79 | // printf("Element not found in the array\n"); 80 | // } 81 | // return 0; 82 | // } 83 | 84 | // another way to implement binary search 85 | // #include 86 | 87 | // int binarySearch(int arr[], int size, int target) { 88 | // int left = 0; 89 | // int right = size - 1; 90 | // while (left <= right) { 91 | // int mid = left + (right - left) / 2; 92 | // if (arr[mid] == target) { 93 | // return mid; 94 | // } 95 | // if (arr[mid] < target) { 96 | // left = mid + 1; 97 | // } else { 98 | // right = mid - 1; 99 | // } 100 | // } 101 | // return -1; 102 | // } 103 | 104 | // int main() { 105 | // int array[] = {2, 4, 5, 7, 9, 12, 14}; 106 | // int target = 9; 107 | // int size = sizeof(array) / sizeof(array[0]); 108 | // int result = binarySearch(array, size, target); 109 | // if (result != -1) { 110 | // printf("Element found at index: %d\n", result); 111 | // } else { 112 | // printf("Element not found in the array\n"); 113 | // } 114 | // return 0; 115 | // } 116 | --------------------------------------------------------------------------------