├── .gitattributes
├── Algorithms
├── Algorithms.cbp
├── Algorithms.layout
├── bin
│ └── Debug
│ │ └── Algorithms
└── obj
│ └── Debug
│ └── test.o
├── LinearSearch.c
├── Sorting.c
├── line
├── sort
├── test
├── test.c
└── test.o
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/Algorithms/Algorithms.cbp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Algorithms/Algorithms.layout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Algorithms/bin/Debug/Algorithms:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teddyoweh/Algorithms-in-C/9c5ca2978b90ce7fbe3e2390cc2b4a2c4773c218/Algorithms/bin/Debug/Algorithms
--------------------------------------------------------------------------------
/Algorithms/obj/Debug/test.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teddyoweh/Algorithms-in-C/9c5ca2978b90ce7fbe3e2390cc2b4a2c4773c218/Algorithms/obj/Debug/test.o
--------------------------------------------------------------------------------
/LinearSearch.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #define MAX 20
4 |
5 |
6 | int intArray[MAX] = {1,2,3,4,6,7,9,11,12,14,15,16,17,19,33,34,43,45,55,66};
7 |
8 |
9 |
10 |
11 | int find(int data) {
12 |
13 | int comparisons = 0;
14 | int index = -1;
15 | int i;
16 |
17 |
18 | for(i = 0;i
2 |
3 | void swap(int *a, int *b)
4 | {
5 | int temp = *a;
6 | *a = *b;
7 | *b = temp;
8 | }
9 |
10 | void bubbleSort(int array[], int n)
11 | {
12 | int i, j;
13 | for (i = 0; i < n-1; i++)
14 | for (j = 0; j < n-i-1; j++) if (array[j] > array[j+1])
15 | swap(&array[j], &array[j+1]);
16 | }
17 | void printArray(int array[], int size)
18 | {
19 | int i;
20 | for (i=0; i < size; i++)
21 | printf("%d ", array[i]);
22 | printf("n");
23 | }
24 |
25 | int main()
26 | {
27 | int array[] = {89, 32, 20, 113, -15};
28 | int size = sizeof(array)/sizeof(array[0]);
29 | bubbleSort(array, size);
30 | printf("Sorted array: n");
31 | printArray(array, size);
32 | return 0;
33 | }
--------------------------------------------------------------------------------
/line:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teddyoweh/Algorithms-in-C/9c5ca2978b90ce7fbe3e2390cc2b4a2c4773c218/line
--------------------------------------------------------------------------------
/sort:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teddyoweh/Algorithms-in-C/9c5ca2978b90ce7fbe3e2390cc2b4a2c4773c218/sort
--------------------------------------------------------------------------------
/test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teddyoweh/Algorithms-in-C/9c5ca2978b90ce7fbe3e2390cc2b4a2c4773c218/test
--------------------------------------------------------------------------------
/test.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main()
4 | {
5 | //Initialize array
6 | int arr[] = {1, 2, 3, 4, 5};
7 | //Calculate length of array
8 | int length = sizeof(arr)/sizeof(arr[0]);
9 |
10 |
11 | //Loop through the array by incrementing value of i
12 | for (int i = 0; i < length; i++) {
13 | for( int k = `)
14 | }
15 |
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/test.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teddyoweh/Algorithms-in-C/9c5ca2978b90ce7fbe3e2390cc2b4a2c4773c218/test.o
--------------------------------------------------------------------------------