├── data_structures_10_graph ├── GraphIncidenceMatrix │ ├── graph2.graph │ ├── main.c │ ├── graph.h │ └── graph.c ├── exercise3 │ ├── graph1.graph │ ├── main.c │ ├── graph.h │ ├── linked_list.h │ └── graph.c ├── GraphAdjLists │ ├── graph1.graph │ ├── main.c │ ├── graph.h │ ├── linked_list.h │ ├── graph.c │ └── linked_list.c ├── GraphAdjMatrix │ ├── graph1.graph │ ├── main.c │ ├── graph.h │ └── graph.c ├── exercise1.2 │ ├── graph1.graph │ ├── main.c │ ├── graph.h │ └── graph.c ├── exercise2 │ ├── graph1.graph │ ├── main.c │ ├── graph.h │ └── graph.c ├── exercise4 │ ├── graph1.graph │ ├── main.c │ ├── graph.h │ ├── linked_list.h │ └── graph.c ├── DS.10.graphs.pdf └── exercise1.1 │ ├── graph1.graph │ ├── main.c │ ├── graph.h │ └── graph.c ├── data_structures_11_disjoint_sets ├── exercise01 │ ├── graph1.graph │ ├── graph2.graph │ ├── graph.h │ ├── disjoint_sets.h │ ├── linked_list.h │ ├── main.c │ ├── graph.c │ └── disjoint_sets.c ├── DS.11.disjoint.sets.pdf ├── exercise02 │ ├── main.c │ ├── disjoint_sets.h │ ├── linked_list.h │ ├── disjoint_sets.c │ └── linked_list.c ├── exercise03 │ ├── main.c │ ├── disjoint_sets.h │ └── disjoint_sets.c ├── DisjointSets(LinkedLists) │ ├── main.c │ ├── disjoint_sets.h │ ├── linked_list.h │ ├── disjoint_sets.c │ └── linked_list.c └── DisjointSets(ReverseTrees) │ ├── main.c │ ├── disjoint_sets.h │ └── disjoint_sets.c ├── data_structures_9_avl ├── DS.9.pdf ├── DS.9(4sl).pdf ├── AVL.dev ├── tree.h └── main.c ├── data_structures_6_trees ├── DS.6.pdf ├── DS.6(4sl).pdf └── tree │ ├── main.c │ ├── tree.h │ └── tree.dev ├── data_structures_5_ll_variations ├── DS.5.pdf ├── DS.5(4sl).pdf ├── askisi3 │ ├── main.c │ ├── queue.h │ └── askisi3.dev ├── askisi1 │ ├── main.c │ ├── doubly_linked_list.h │ ├── askisi1.dev │ └── doubly_linked_list.c ├── askisi2 │ ├── main.c │ ├── circular_list.h │ └── askisi2.dev ├── circular_list │ ├── circular_list.h │ ├── main.c │ ├── circular_list.dev │ └── circular_list.c └── doubly_linked_list │ ├── doubly_linked_list.h │ ├── doubly_linked_list.dev │ ├── main.c │ └── doubly_linked_list.c ├── data_structures_4_linked_lists ├── DS.4.list.pdf ├── DS.4.list(4sl).pdf ├── askisi2 │ ├── main.c │ ├── stack.h │ ├── askisi2.dev │ └── stack.c ├── askisi3 │ ├── main.c │ └── queue.h ├── sequential_list │ ├── sequential_list.h │ ├── main.c │ ├── linked_list.dev │ └── sequential_list.c ├── linked_list │ ├── linked_list.h │ ├── linked_list.dev │ ├── main.c │ └── linked_list.c └── askisi1 │ ├── linked_list.h │ ├── askisi1.dev │ └── main.c ├── data_structures_2_stack ├── data_structures_in_C_lesson_2.pdf ├── data_structures_in_C_lesson_2(4sl).pdf ├── stack │ ├── stack.h │ ├── stack.c │ ├── stack_main.c │ └── stack.dev ├── efarmogi3 │ ├── efarmogi3_stack_main.c │ ├── efarmogi3_stack.h │ ├── efarmogi3_stack.c │ └── efarmogi3.dev ├── stack_char │ ├── stack_char.h │ ├── stack_char.c │ └── stack_main_char.c ├── efarmogi4 │ ├── efarmogi4_stack.h │ ├── efarmogi4_stack_main.c │ ├── efarmogi4_stack.c │ └── efarmogi4.dev ├── efarmogi2 │ ├── efarmogi2_stack.h │ ├── efarmogi2_stack.c │ ├── efarmogi2.dev │ └── efarmogi2_main.c └── efarmogi1 │ └── efarmogi1.dev ├── data_structures_3_queue ├── data_structures_in_C_lesson_3_queue.pdf ├── data_structures_in_C_lesson_3_queue(4sl).pdf ├── simple_queue │ ├── queue.h │ ├── main.c │ ├── queue.dev │ └── queue.c ├── efarmogi4 │ ├── stack.h │ ├── queue.h │ ├── stack.c │ ├── queue.c │ ├── circular.dev │ └── main.c ├── efarmogi1 │ ├── queue.h │ ├── circular.dev │ ├── queue.c │ └── main.c ├── efarmogi3 │ ├── queue.h │ ├── queue.c │ └── main.c ├── circular_queue │ ├── queue.h │ ├── circular.dev │ ├── main.c │ └── queue.c └── efarmogi2 │ ├── queue.h │ ├── circular.dev │ ├── main.c │ └── queue.c ├── data_structures_8_heaps ├── data_structures_in_C_lesson_8_heap_trees.pdf ├── data_structures_in_C_lesson_8_heap_trees(4sl).pdf └── tree │ ├── heap.h │ ├── tree.dev │ ├── heap.dev │ ├── main.c │ └── heap.c └── data_structures_7_binary_search_trees ├── data_structures_in_C_lesson_7_binary_search_trees.pdf ├── data_structures_in_C_lesson_7_binary_search_trees(4sl).pdf └── tree ├── heap.dev ├── tree.h └── main.c /data_structures_10_graph/GraphIncidenceMatrix/graph2.graph: -------------------------------------------------------------------------------- 1 | 4 4 2 | 0 3 3 | 0 1 4 | 0 2 5 | 1 2 -------------------------------------------------------------------------------- /data_structures_10_graph/exercise3/graph1.graph: -------------------------------------------------------------------------------- 1 | 5 2 | 0 1 3 | 0 3 4 | 0 4 5 | 1 3 6 | 1 4 7 | 2 4 8 | 3 4 -------------------------------------------------------------------------------- /data_structures_10_graph/GraphAdjLists/graph1.graph: -------------------------------------------------------------------------------- 1 | 5 2 | 0 1 3 | 0 3 4 | 0 4 5 | 1 3 6 | 1 4 7 | 2 4 8 | 3 4 -------------------------------------------------------------------------------- /data_structures_10_graph/GraphAdjMatrix/graph1.graph: -------------------------------------------------------------------------------- 1 | 5 2 | 0 1 3 | 0 3 4 | 0 4 5 | 1 3 6 | 1 4 7 | 2 4 8 | 3 4 -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise01/graph1.graph: -------------------------------------------------------------------------------- 1 | 5 2 | 0 1 3 | 0 3 4 | 0 4 5 | 1 3 6 | 1 4 7 | 2 4 8 | 3 4 -------------------------------------------------------------------------------- /data_structures_9_avl/DS.9.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_9_avl/DS.9.pdf -------------------------------------------------------------------------------- /data_structures_10_graph/exercise1.2/graph1.graph: -------------------------------------------------------------------------------- 1 | 5 2 | 0 1 2 3 | 0 3 8 4 | 0 4 4 5 | 1 3 1 6 | 1 4 4 7 | 2 4 6 8 | 3 4 1 -------------------------------------------------------------------------------- /data_structures_10_graph/exercise2/graph1.graph: -------------------------------------------------------------------------------- 1 | 5 2 | 0 1 2 3 | 0 3 8 4 | 0 4 4 5 | 1 3 1 6 | 1 4 4 7 | 2 4 6 8 | 3 4 1 -------------------------------------------------------------------------------- /data_structures_10_graph/exercise4/graph1.graph: -------------------------------------------------------------------------------- 1 | 5 2 | 0 1 5 3 | 0 3 3 4 | 0 4 2 5 | 1 3 1 6 | 1 4 4 7 | 2 4 9 8 | 3 4 3 -------------------------------------------------------------------------------- /data_structures_6_trees/DS.6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_6_trees/DS.6.pdf -------------------------------------------------------------------------------- /data_structures_9_avl/DS.9(4sl).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_9_avl/DS.9(4sl).pdf -------------------------------------------------------------------------------- /data_structures_6_trees/DS.6(4sl).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_6_trees/DS.6(4sl).pdf -------------------------------------------------------------------------------- /data_structures_10_graph/DS.10.graphs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_10_graph/DS.10.graphs.pdf -------------------------------------------------------------------------------- /data_structures_10_graph/exercise1.1/graph1.graph: -------------------------------------------------------------------------------- 1 | 5 2 | 0 1 3 | 0 3 4 | 0 4 5 | 1 3 6 | 1 4 7 | 2 1 8 | 2 4 9 | 3 4 10 | 4 0 -------------------------------------------------------------------------------- /data_structures_5_ll_variations/DS.5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_5_ll_variations/DS.5.pdf -------------------------------------------------------------------------------- /data_structures_4_linked_lists/DS.4.list.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_4_linked_lists/DS.4.list.pdf -------------------------------------------------------------------------------- /data_structures_5_ll_variations/DS.5(4sl).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_5_ll_variations/DS.5(4sl).pdf -------------------------------------------------------------------------------- /data_structures_4_linked_lists/DS.4.list(4sl).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_4_linked_lists/DS.4.list(4sl).pdf -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/DS.11.disjoint.sets.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_11_disjoint_sets/DS.11.disjoint.sets.pdf -------------------------------------------------------------------------------- /data_structures_2_stack/data_structures_in_C_lesson_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_2_stack/data_structures_in_C_lesson_2.pdf -------------------------------------------------------------------------------- /data_structures_2_stack/data_structures_in_C_lesson_2(4sl).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_2_stack/data_structures_in_C_lesson_2(4sl).pdf -------------------------------------------------------------------------------- /data_structures_3_queue/data_structures_in_C_lesson_3_queue.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_3_queue/data_structures_in_C_lesson_3_queue.pdf -------------------------------------------------------------------------------- /data_structures_3_queue/data_structures_in_C_lesson_3_queue(4sl).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_3_queue/data_structures_in_C_lesson_3_queue(4sl).pdf -------------------------------------------------------------------------------- /data_structures_8_heaps/data_structures_in_C_lesson_8_heap_trees.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_8_heaps/data_structures_in_C_lesson_8_heap_trees.pdf -------------------------------------------------------------------------------- /data_structures_8_heaps/data_structures_in_C_lesson_8_heap_trees(4sl).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_8_heaps/data_structures_in_C_lesson_8_heap_trees(4sl).pdf -------------------------------------------------------------------------------- /data_structures_7_binary_search_trees/data_structures_in_C_lesson_7_binary_search_trees.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_7_binary_search_trees/data_structures_in_C_lesson_7_binary_search_trees.pdf -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise01/graph2.graph: -------------------------------------------------------------------------------- 1 | 16 2 | 0 3 3 | 0 4 4 | 3 1 5 | 3 4 6 | 1 2 7 | 1 4 8 | 5 6 9 | 6 7 10 | 7 8 11 | 8 9 12 | 9 5 13 | 10 11 14 | 10 12 15 | 11 12 16 | 12 13 17 | 13 14 18 | 13 15 19 | 14 15 -------------------------------------------------------------------------------- /data_structures_7_binary_search_trees/data_structures_in_C_lesson_7_binary_search_trees(4sl).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psounis/C-Data-Structures/HEAD/data_structures_7_binary_search_trees/data_structures_in_C_lesson_7_binary_search_trees(4sl).pdf -------------------------------------------------------------------------------- /data_structures_10_graph/GraphAdjMatrix/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "graph.h" 3 | 4 | int main() 5 | { 6 | GRAPH g; 7 | 8 | GR_init_from_file(&g, "graph1.graph"); 9 | 10 | GR_print(g); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise1.1/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "graph.h" 3 | 4 | int main() 5 | { 6 | GRAPH g; 7 | 8 | GR_init_from_file(&g, "graph1.graph"); 9 | 10 | GR_print(g); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise1.2/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "graph.h" 3 | 4 | int main() 5 | { 6 | GRAPH g; 7 | 8 | GR_init_from_file(&g, "graph1.graph"); 9 | 10 | GR_print(g); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /data_structures_10_graph/GraphAdjLists/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "graph.h" 3 | 4 | int main() 5 | { 6 | GRAPH g; 7 | 8 | GR_init_from_file(&g, "graph1.graph"); 9 | GR_print(g); 10 | 11 | GR_destroy(g); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise4/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "graph.h" 3 | 4 | int main() 5 | { 6 | GRAPH g; 7 | 8 | GR_init_from_file(&g, "graph1.graph"); 9 | GR_print(g); 10 | 11 | GR_destroy(g); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /data_structures_10_graph/GraphIncidenceMatrix/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "graph.h" 3 | 4 | int main() 5 | { 6 | GRAPH g; 7 | int i,j; 8 | 9 | GR_init_from_file(&g, "graph2.graph"); 10 | 11 | GR_print(g); 12 | 13 | GR_destroy(g); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise2/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "graph.h" 3 | 4 | int main() 5 | { 6 | GRAPH g; 7 | 8 | GR_init_from_file(&g, "graph1.graph"); 9 | 10 | GR_print(g); 11 | printf("To plithos twn akmwn: %d", GR_edges(g)); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/askisi3/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "queue.h" 3 | 4 | main() 5 | { 6 | QUEUE q; 7 | elem x; 8 | 9 | QU_init(&q); 10 | 11 | QU_enqueue(&q, 1); 12 | QU_enqueue(&q, 2); 13 | 14 | QU_dequeue(&q, &x); 15 | printf("%d", x); 16 | QU_dequeue(&q, &x); 17 | printf("%d", x); 18 | 19 | QU_destroy(q); 20 | } 21 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/askisi2/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stack.h" 3 | 4 | main() 5 | { 6 | STACK s; 7 | elem x; 8 | 9 | ST_init(&s); 10 | 11 | ST_push(&s, 1); 12 | ST_push(&s, 2); 13 | ST_push(&s, 3); 14 | 15 | ST_print(s); 16 | 17 | ST_pop(&s, &x); 18 | printf("\n\nTo stoixeio: %d\n", x); 19 | ST_print(s); 20 | 21 | ST_destroy(&s); 22 | } 23 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/askisi1/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "doubly_linked_list.h" 3 | 4 | main() 5 | { 6 | LIST_PTR list; 7 | 8 | DLL_init(&list); 9 | 10 | DLL_insert_start(&list, 3); 11 | DLL_insert_start(&list, 2); 12 | DLL_insert_start(&list, 1); 13 | 14 | DLL_print(list); 15 | printf("\n"); 16 | DLL_print_reverse(list); 17 | 18 | DLL_destroy(&list); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise02/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "disjoint_sets.h" 3 | 4 | int main() 5 | { 6 | DISJOINT d; 7 | int i, n=10; 8 | 9 | DS_init(&d, 10); 10 | 11 | DS_print(d); 12 | 13 | for (i=n-1; i>=1; i--) 14 | { 15 | DS_union(&d, i, i-1); 16 | DS_print(d); 17 | printf("\n"); 18 | } 19 | 20 | DS_destroy(&d); 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/askisi2/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "circular_list.h" 3 | 4 | main() 5 | { 6 | LIST_PTR list; 7 | elem x; 8 | 9 | CL_init(&list); 10 | 11 | CL_insert_start(&list, 4); 12 | CL_insert_start(&list, 3); 13 | CL_insert_start(&list, 2); 14 | CL_insert_start(&list, 1); 15 | CL_print(list); 16 | 17 | CL_get_i(list, 13, &x); 18 | printf("To 13o stoixeio einai: %d", x); 19 | 20 | CL_destroy(&list); 21 | } 22 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise3/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "graph.h" 3 | 4 | int main() 5 | { 6 | GRAPH g; 7 | int i, length; 8 | int *elements; 9 | 10 | GR_init_from_file(&g, "graph1.graph"); 11 | GR_print(g); 12 | 13 | GR_neighbors(g, 4, &length, &elements); 14 | 15 | printf("Neighbors of 4: "); 16 | for (i=0; i 2 | #include "disjoint_sets.h" 3 | 4 | int main() 5 | { 6 | DISJOINT d; 7 | 8 | DS_init(&d, 7); 9 | 10 | DS_print(d); 11 | 12 | printf("\nUNION(1,3):\n"); 13 | DS_union(&d, 1, 3); 14 | DS_print(d); 15 | 16 | printf("\nUNION(2,4):\n"); 17 | DS_union(&d, 2, 4); 18 | DS_print(d); 19 | 20 | printf("\nUNION(2,5):\n"); 21 | DS_union(&d, 2, 5); 22 | DS_print(d); 23 | 24 | printf("\nUNION(3,5):\n"); 25 | DS_union(&d, 3, 5); 26 | DS_print(d); 27 | 28 | DS_destroy(&d); 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /data_structures_3_queue/simple_queue/queue.h: -------------------------------------------------------------------------------- 1 | /* queue.h : Dilwseis ouras */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | #define QUEUE_SIZE 10 /* Megethos pinaka ouras */ 7 | 8 | typedef int elem; /* typos dedomenwn ouras */ 9 | 10 | struct queue{ 11 | elem array[QUEUE_SIZE]; /* pinakas stoixeiwn */ 12 | int finish; /* telos tis ouras */ 13 | }; 14 | 15 | typedef struct queue QUEUE; /* Sinwnimo tis stoivas */ 16 | 17 | 18 | void QU_init(QUEUE *s); 19 | int QU_empty(QUEUE s); 20 | int QU_full(QUEUE s); 21 | int QU_enqueue(QUEUE *s, elem x); 22 | int QU_dequeue(QUEUE *s, elem *x); 23 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/DisjointSets(LinkedLists)/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "disjoint_sets.h" 3 | 4 | int main() 5 | { 6 | DISJOINT d; 7 | 8 | DS_init(&d, 7); 9 | 10 | DS_print(d); 11 | 12 | printf("UNION(1,3):\n"); 13 | DS_union(&d, 1, 3); 14 | DS_print(d); 15 | 16 | printf("UNION(2,4):\n"); 17 | DS_union(&d, 2, 4); 18 | DS_print(d); 19 | 20 | printf("UNION(2,5):\n"); 21 | DS_union(&d, 2, 5); 22 | DS_print(d); 23 | 24 | printf("UNION(3,5):\n"); 25 | DS_union(&d, 3, 5); 26 | DS_print(d); 27 | 28 | DS_destroy(&d); 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/DisjointSets(ReverseTrees)/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "disjoint_sets.h" 3 | 4 | int main() 5 | { 6 | DISJOINT d; 7 | 8 | DS_init(&d, 7); 9 | 10 | DS_print(d); 11 | 12 | printf("UNION(1,3):\n"); 13 | DS_union(&d, 1, 3); 14 | DS_print(d); 15 | 16 | printf("UNION(2,4):\n"); 17 | DS_union(&d, 2, 4); 18 | DS_print(d); 19 | 20 | printf("UNION(2,5):\n"); 21 | DS_union(&d, 2, 5); 22 | DS_print(d); 23 | 24 | printf("UNION(3,5):\n"); 25 | DS_union(&d, 3, 5); 26 | DS_print(d); 27 | 28 | DS_destroy(&d); 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /data_structures_2_stack/stack/stack.h: -------------------------------------------------------------------------------- 1 | /* stack.h : Dilwseis stoivas */ 2 | 3 | 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | #define STACK_SIZE 10 /* Megethos pinaka stoivas */ 9 | 10 | typedef int elem; /* typos dedomenwn stoivas */ 11 | 12 | struct stack{ 13 | elem array[STACK_SIZE]; /* pinakas stoixeiwn */ 14 | int top; /*koryfi tis stoivas */ 15 | }; 16 | 17 | typedef struct stack STACK; /* Sinwnimo tis stoivas */ 18 | 19 | 20 | void ST_init(STACK *s); 21 | int ST_empty(STACK s); 22 | int ST_full(STACK s); 23 | int ST_push(STACK *s, elem x); 24 | int ST_pop(STACK *s, elem *x); 25 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi3/efarmogi3_stack_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "efarmogi3_stack.h" 3 | 4 | main() 5 | { 6 | STACK st; 7 | int x; 8 | 9 | /* Diavasma tou akeraiou arithmou */ 10 | 11 | do{ 12 | printf("Dwse enan thetiko akeraio: "); 13 | scanf("%d",&x); 14 | } while (!(x>0)); 15 | 16 | /* Metatropi sto dyadiko */ 17 | ST_init(&st); 18 | 19 | while(x>=1) 20 | { 21 | ST_push(&st,x%2); 22 | x=x/2; 23 | } 24 | 25 | /* Ektypwsi tou arithmou */ 26 | 27 | printf("\n O dyadikos einai: "); 28 | while(!ST_empty(st)) 29 | { 30 | ST_pop(&st,&x); 31 | printf("%d",x); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi4/stack.h: -------------------------------------------------------------------------------- 1 | /* stack.h : Dilwseis stoivas */ 2 | 3 | 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | #define STACK_SIZE 10 /* Megethos pinaka stoivas */ 9 | 10 | typedef int elem; /* typos dedomenwn stoivas */ 11 | 12 | struct stack{ 13 | elem array[STACK_SIZE]; /* pinakas stoixeiwn */ 14 | int top; /*koryfi tis stoivas */ 15 | }; 16 | 17 | typedef struct stack STACK; /* Sinwnimo tis stoivas */ 18 | 19 | 20 | void ST_init(STACK *s); 21 | int ST_empty(STACK s); 22 | int ST_full(STACK s); 23 | int ST_push(STACK *s, elem x); 24 | int ST_pop(STACK *s, elem *x); 25 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise2/graph.h: -------------------------------------------------------------------------------- 1 | /* graph.h : Dilwseis grafou (pin.geitniasis) */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | struct graph /* Typos komvou listas */ 7 | { 8 | int **array; /* pin.geitniasis */ 9 | int N; /* Plithos komvwn */ 10 | }; 11 | 12 | typedef struct graph GRAPH; 13 | 14 | /* Basikes Prakseis */ 15 | void GR_init(GRAPH *g, int N); 16 | void GR_print(GRAPH g); 17 | void GR_add_edge(GRAPH g, int vertex1, int vertex2, int weight); 18 | void GR_destroy(GRAPH g); 19 | 20 | /* Deutereouses Prakseis */ 21 | void GR_init_from_file(GRAPH *g, char *filename); 22 | int GR_edges(GRAPH g); 23 | 24 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi3/efarmogi3_stack.h: -------------------------------------------------------------------------------- 1 | /* stack.h : Dilwseis stoivas */ 2 | 3 | 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | #define STACK_SIZE 10 /* Megethos pinaka stoivas */ 9 | 10 | typedef int elem; /* typos dedomenwn stoivas */ 11 | 12 | struct stack{ 13 | elem array[STACK_SIZE]; /* pinakas stoixeiwn */ 14 | int top; /*koryfi tis stoivas */ 15 | }; 16 | 17 | typedef struct stack STACK; /* Sinwnimo tis stoivas */ 18 | 19 | 20 | void ST_init(STACK *s); 21 | int ST_empty(STACK s); 22 | int ST_full(STACK s); 23 | int ST_push(STACK *s, elem x); 24 | int ST_pop(STACK *s, elem *x); 25 | -------------------------------------------------------------------------------- /data_structures_2_stack/stack_char/stack_char.h: -------------------------------------------------------------------------------- 1 | /* stack.h : Dilwseis stoivas */ 2 | 3 | 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | #define STACK_SIZE 10 /* Megethos pinaka stoivas */ 9 | 10 | typedef char elem; /* typos dedomenwn stoivas */ 11 | 12 | struct stack{ 13 | elem array[STACK_SIZE]; /* pinakas stoixeiwn */ 14 | int top; /*koryfi tis stoivas */ 15 | }; 16 | 17 | typedef struct stack STACK; /* Sinwnimo tis stoivas */ 18 | 19 | 20 | void ST_init(STACK *s); 21 | int ST_empty(STACK s); 22 | int ST_full(STACK s); 23 | int ST_push(STACK *s, elem x); 24 | int ST_pop(STACK *s, elem *x); 25 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi4/efarmogi4_stack.h: -------------------------------------------------------------------------------- 1 | /* stack.h : Dilwseis stoivas */ 2 | 3 | 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | #define STACK_SIZE 10 /* Megethos pinaka stoivas */ 9 | 10 | typedef double elem; /* typos dedomenwn stoivas */ 11 | 12 | struct stack{ 13 | elem array[STACK_SIZE]; /* pinakas stoixeiwn */ 14 | int top; /*koryfi tis stoivas */ 15 | }; 16 | 17 | typedef struct stack STACK; /* Sinwnimo tis stoivas */ 18 | 19 | 20 | void ST_init(STACK *s); 21 | int ST_empty(STACK s); 22 | int ST_full(STACK s); 23 | int ST_push(STACK *s, elem x); 24 | int ST_pop(STACK *s, elem *x); 25 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise4/graph.h: -------------------------------------------------------------------------------- 1 | /* graph.h : Dilwseis grafou (pin.geitniasis) */ 2 | #ifndef GRAPH_H 3 | #define GRAPH_H 4 | #include "linked_list.h" 5 | 6 | struct graph /* Typos komvou listas */ 7 | { 8 | LIST_PTR *array; /* pinakas listwn geitniasis */ 9 | int N; /* Plithos komvwn */ 10 | }; 11 | 12 | typedef struct graph GRAPH; 13 | 14 | /* Basikes Prakseis */ 15 | void GR_init(GRAPH *g, int N); 16 | void GR_print(GRAPH g); 17 | void GR_add_edge(GRAPH g, int vertex1, int vertex2, int weight); 18 | void GR_destroy(GRAPH g); 19 | 20 | /* Deutereouses Prakseis */ 21 | void GR_init_from_file(GRAPH *g, char *filename); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise3/graph.h: -------------------------------------------------------------------------------- 1 | /* graph.h : Dilwseis grafou (pin.geitniasis) */ 2 | #ifndef GRAPH_H 3 | #define GRAPH_H 4 | #include "linked_list.h" 5 | 6 | struct graph /* Typos komvou listas */ 7 | { 8 | LIST_PTR *array; /* pinakas listwn geitniasis */ 9 | int N; /* Plithos komvwn */ 10 | }; 11 | 12 | typedef struct graph GRAPH; 13 | 14 | /* Basikes Prakseis */ 15 | void GR_init(GRAPH *g, int N); 16 | void GR_print(GRAPH g); 17 | void GR_destroy(GRAPH g); 18 | 19 | /* Deutereouses Prakseis */ 20 | void GR_init_from_file(GRAPH *g, char *filename); 21 | void GR_neighbors(GRAPH g, int vertex, int *length, int **elements); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi1/queue.h: -------------------------------------------------------------------------------- 1 | /* queue.h : Dilwseis ouras */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | #define QUEUE_SIZE 5 /* Megethos pinaka ouras */ 7 | 8 | typedef char * elem; /* typos dedomenwn ouras */ 9 | 10 | struct queue{ 11 | elem array[QUEUE_SIZE]; /* pinakas stoixeiwn */ 12 | int start; /* arxi tis ouras */ 13 | int finish; /* telos tis ouras */ 14 | }; 15 | 16 | typedef struct queue QUEUE; /* Sinwnimo tis stoivas */ 17 | 18 | 19 | void QU_init(QUEUE *s); 20 | int QU_empty(QUEUE s); 21 | int QU_full(QUEUE s); 22 | int QU_enqueue(QUEUE *s, elem x); 23 | int QU_dequeue(QUEUE *s, elem *x); 24 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi3/queue.h: -------------------------------------------------------------------------------- 1 | /* queue.h : Dilwseis ouras */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | #define QUEUE_SIZE 10 /* Megethos pinaka ouras */ 7 | 8 | typedef int elem; /* typos dedomenwn ouras */ 9 | 10 | struct queue{ 11 | elem array[QUEUE_SIZE]; /* pinakas stoixeiwn */ 12 | int start; /* arxi tis ouras */ 13 | int finish; /* telos tis ouras */ 14 | }; 15 | 16 | typedef struct queue QUEUE; /* Sinwnimo tis stoivas */ 17 | 18 | 19 | void QU_init(QUEUE *s); 20 | int QU_empty(QUEUE s); 21 | int QU_full(QUEUE s); 22 | int QU_enqueue(QUEUE *s, elem x); 23 | int QU_dequeue(QUEUE *s, elem *x); 24 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi4/queue.h: -------------------------------------------------------------------------------- 1 | /* queue.h : Dilwseis ouras */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | #define QUEUE_SIZE 10 /* Megethos pinaka ouras */ 7 | 8 | typedef int elem; /* typos dedomenwn ouras */ 9 | 10 | struct queue{ 11 | elem array[QUEUE_SIZE]; /* pinakas stoixeiwn */ 12 | int start; /* arxi tis ouras */ 13 | int finish; /* telos tis ouras */ 14 | }; 15 | 16 | typedef struct queue QUEUE; /* Sinwnimo tis stoivas */ 17 | 18 | 19 | void QU_init(QUEUE *s); 20 | int QU_empty(QUEUE s); 21 | int QU_full(QUEUE s); 22 | int QU_enqueue(QUEUE *s, elem x); 23 | int QU_dequeue(QUEUE *s, elem *x); 24 | -------------------------------------------------------------------------------- /data_structures_3_queue/circular_queue/queue.h: -------------------------------------------------------------------------------- 1 | /* queue.h : Dilwseis ouras */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | #define QUEUE_SIZE 10 /* Megethos pinaka ouras */ 7 | 8 | typedef int elem; /* typos dedomenwn ouras */ 9 | 10 | struct queue{ 11 | elem array[QUEUE_SIZE]; /* pinakas stoixeiwn */ 12 | int start; /* arxi tis ouras */ 13 | int finish; /* telos tis ouras */ 14 | }; 15 | 16 | typedef struct queue QUEUE; /* Sinwnimo tis stoivas */ 17 | 18 | 19 | void QU_init(QUEUE *s); 20 | int QU_empty(QUEUE s); 21 | int QU_full(QUEUE s); 22 | int QU_enqueue(QUEUE *s, elem x); 23 | int QU_dequeue(QUEUE *s, elem *x); 24 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/askisi3/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "queue.h" 5 | 6 | main() 7 | { 8 | QUEUE q; 9 | elem x; 10 | int i; 11 | 12 | srand(time(NULL)); 13 | QU_init(&q); 14 | 15 | for (i=0; i<400; i++) 16 | { 17 | if (rand()%2) 18 | { 19 | printf("enqueue.. "); 20 | x = rand()%100; 21 | QU_enqueue(&q, x); 22 | } 23 | else 24 | { 25 | printf("dequeue .. "); 26 | QU_dequeue(&q, &x); 27 | } 28 | QU_print(q); 29 | printf("\n"); 30 | } 31 | 32 | QU_destroy(q); 33 | } 34 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/sequential_list/sequential_list.h: -------------------------------------------------------------------------------- 1 | /* queue.h : Dilwseis sindedemenis listas */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | #define SIZE 100 7 | 8 | typedef int elem; /* typos dedomenwn listas */ 9 | 10 | typedef struct list LIST; /* Sinwnimo tis listas */ 11 | 12 | struct list{ /* Akolouthiaki list */ 13 | elem data[SIZE]; /* Pinakas Dedomenwn */ 14 | int N; /* plithos stoixeiwn */ 15 | }; 16 | 17 | void SL_init(LIST *l); 18 | int SL_empty(LIST l); 19 | elem SL_data(LIST l, int ind); 20 | int SL_insert(LIST *l, int ind, elem x); 21 | int SL_delete(LIST *l, int ind, elem *x); 22 | void SL_print(LIST l); 23 | 24 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise01/graph.h: -------------------------------------------------------------------------------- 1 | /* graph.h : Dilwseis grafou (pin.geitniasis) */ 2 | #ifndef GRAPH_H 3 | #define GRAPH_H 4 | #include "linked_list.h" 5 | 6 | struct graph /* Typos komvou listas */ 7 | { 8 | LIST_PTR *array; /* pinakas listwn geitniasis */ 9 | int N; /* Plithos komvwn */ 10 | }; 11 | 12 | typedef struct graph GRAPH; 13 | 14 | /* Basikes Prakseis */ 15 | void GR_init(GRAPH *g, int N); 16 | void GR_print(GRAPH g); 17 | void GR_destroy(GRAPH g); 18 | int GR_vertices_count(GRAPH g); 19 | void GR_neighbors(GRAPH g, int vertex, int *length, elem **elements); 20 | 21 | /* Deutereouses Prakseis */ 22 | void GR_init_from_file(GRAPH *g, char *filename); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi2/efarmogi2_stack.h: -------------------------------------------------------------------------------- 1 | /* stack.h : Dilwseis stoivas */ 2 | 3 | 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | #define STACK_SIZE 10 /* Megethos pinaka stoivas */ 9 | 10 | struct foititis{ 11 | char onoma[80]; 12 | int vathmos; 13 | }; 14 | 15 | typedef struct foititis FOITITIS; 16 | 17 | typedef FOITITIS elem; /* typos dedomenwn stoivas */ 18 | 19 | struct stack{ 20 | elem array[STACK_SIZE]; /* pinakas stoixeiwn */ 21 | int top; /*koryfi tis stoivas */ 22 | }; 23 | 24 | typedef struct stack STACK; /* Sinwnimo tis stoivas */ 25 | 26 | 27 | void ST_init(STACK *s); 28 | int ST_empty(STACK s); 29 | int ST_full(STACK s); 30 | int ST_push(STACK *s, elem x); 31 | int ST_pop(STACK *s, elem *x); 32 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi2/queue.h: -------------------------------------------------------------------------------- 1 | /* queue.h : Dilwseis ouras */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | #define QUEUE_SIZE 10 /* Megethos pinaka ouras */ 7 | 8 | 9 | typedef int data_type; 10 | 11 | struct data_array{ 12 | data_type data; 13 | int priority; 14 | }; 15 | 16 | typedef struct data_array elem; /* typos dedomenwn ouras */ 17 | 18 | struct queue{ 19 | elem array[QUEUE_SIZE]; /* pinakas stoixeiwn */ 20 | int start; /* arxi tis ouras */ 21 | int finish; /* telos tis ouras */ 22 | }; 23 | 24 | typedef struct queue QUEUE; /* Sinwnimo tis stoivas */ 25 | 26 | 27 | void QU_init(QUEUE *s); 28 | int QU_empty(QUEUE s); 29 | int QU_full(QUEUE s); 30 | int QU_enqueue(QUEUE *s, elem x); 31 | int QU_dequeue(QUEUE *s, elem *x); 32 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise01/disjoint_sets.h: -------------------------------------------------------------------------------- 1 | /* disjoint_sets.h : Ksena Sinola */ 2 | #include "linked_list.h" 3 | 4 | struct extended_list 5 | { 6 | LIST_PTR head; 7 | LIST_PTR last; 8 | }; 9 | 10 | typedef struct extended_list EXTENDED_LIST; 11 | 12 | struct disjoint 13 | { 14 | elem *repr; /* pinakas antiproswpwn */ 15 | EXTENDED_LIST *list; /* pinakas listwn */ 16 | int N; /* Plithos stoixeiwn */ 17 | }; 18 | 19 | typedef struct disjoint DISJOINT; 20 | 21 | 22 | /* Basikes Prakseis disjoint sets */ 23 | void DS_init(DISJOINT *d, int N); 24 | void DS_make_set(DISJOINT *d, elem x); 25 | int DS_union(DISJOINT *d, elem x, elem y); 26 | elem DS_find_set(DISJOINT d, elem x); 27 | void DS_destroy(DISJOINT *d); 28 | 29 | /* Deutereouses Prakseis disjoint sets */ 30 | void DS_print(DISJOINT d); 31 | 32 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise02/disjoint_sets.h: -------------------------------------------------------------------------------- 1 | /* disjoint_sets.h : Ksena Sinola */ 2 | #include "linked_list.h" 3 | 4 | struct extended_list 5 | { 6 | LIST_PTR head; 7 | LIST_PTR last; 8 | }; 9 | 10 | typedef struct extended_list EXTENDED_LIST; 11 | 12 | struct disjoint 13 | { 14 | elem *repr; /* pinakas antiproswpwn */ 15 | EXTENDED_LIST *list; /* pinakas listwn */ 16 | int N; /* Plithos stoixeiwn */ 17 | }; 18 | 19 | typedef struct disjoint DISJOINT; 20 | 21 | 22 | /* Basikes Prakseis disjoint sets */ 23 | void DS_init(DISJOINT *d, int N); 24 | void DS_make_set(DISJOINT *d, elem x); 25 | int DS_union(DISJOINT *d, elem x, elem y); 26 | elem DS_find_set(DISJOINT d, elem x); 27 | void DS_destroy(DISJOINT *d); 28 | 29 | /* Deutereouses Prakseis disjoint sets */ 30 | void DS_print(DISJOINT d); 31 | 32 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/linked_list/linked_list.h: -------------------------------------------------------------------------------- 1 | /* list.h : Dilwseis sindedemenis listas */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | typedef int elem; /* typos dedomenwn listas */ 7 | 8 | struct node{ /* Typos komvou listas */ 9 | elem data; /* dedomena */ 10 | struct node *next; /* epomenos */ 11 | }; 12 | 13 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 14 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 15 | 16 | void LL_init(LIST_PTR *head); 17 | int LL_empty(LIST_PTR head); 18 | elem LL_data(LIST_PTR p); 19 | int LL_insert_start(LIST_PTR *head,elem x); 20 | int LL_insert_after(LIST_PTR p,elem x); 21 | int LL_delete_start(LIST_PTR *head, elem *x); 22 | int LL_delete_after(LIST_PTR prev, elem *x); 23 | void LL_print(LIST_PTR head); 24 | void LL_destroy(LIST_PTR *head); 25 | 26 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/DisjointSets(LinkedLists)/disjoint_sets.h: -------------------------------------------------------------------------------- 1 | /* disjoint_sets.h : Ksena Sinola */ 2 | #include "linked_list.h" 3 | 4 | struct extended_list 5 | { 6 | LIST_PTR head; 7 | LIST_PTR last; 8 | }; 9 | 10 | typedef struct extended_list EXTENDED_LIST; 11 | 12 | struct disjoint 13 | { 14 | elem *repr; /* pinakas antiproswpwn */ 15 | EXTENDED_LIST *list; /* pinakas listwn */ 16 | int N; /* Plithos stoixeiwn */ 17 | }; 18 | 19 | typedef struct disjoint DISJOINT; 20 | 21 | 22 | /* Basikes Prakseis disjoint sets */ 23 | void DS_init(DISJOINT *d, int N); 24 | void DS_make_set(DISJOINT *d, elem x); 25 | int DS_union(DISJOINT *d, elem x, elem y); 26 | elem DS_find_set(DISJOINT d, elem x); 27 | void DS_destroy(DISJOINT *d); 28 | 29 | /* Deutereouses Prakseis disjoint sets */ 30 | void DS_print(DISJOINT d); 31 | 32 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/circular_list/circular_list.h: -------------------------------------------------------------------------------- 1 | /* queue.h : Dilwseis sindedemenis listas */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | typedef int elem; /* typos dedomenwn listas */ 7 | 8 | struct node{ /* Typos komvou listas */ 9 | elem data; /* dedomena */ 10 | struct node *next; /* epomenos */ 11 | }; 12 | 13 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 14 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 15 | 16 | void CL_init(LIST_PTR *head); 17 | int CL_empty(LIST_PTR head); 18 | elem CL_data(LIST_PTR p); 19 | int CL_insert_start(LIST_PTR *head,elem x); 20 | int CL_insert_after(LIST_PTR p,elem x); 21 | int CL_delete_start(LIST_PTR *head, elem *x); 22 | int CL_delete_after(LIST_PTR prev, elem *x); 23 | void CL_print(LIST_PTR head); 24 | void CL_destroy(LIST_PTR *head); 25 | 26 | -------------------------------------------------------------------------------- /data_structures_6_trees/tree/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "tree.h" 4 | 5 | main() 6 | { 7 | int elem; 8 | TREE_PTR root; 9 | 10 | TR_init(&root); 11 | 12 | /* Eisagwgi tou "10" */ 13 | TR_insert_root(&root, 10); 14 | 15 | /* Eisagwgi twn epipleon stoixeiwn */ 16 | TR_insert_left(root, 6); 17 | TR_insert_right(root, 14); 18 | 19 | TR_insert_left(root->left, 5); 20 | TR_insert_right(root->left, 7); 21 | TR_insert_right(root->right, 19); 22 | 23 | TR_insert_left(root->left->left, 2); 24 | TR_insert_right(root->left->right, 8); 25 | 26 | TR_insert_right(root->left->left->left, 3); 27 | 28 | 29 | /* Ektypwsi toy dendrou */ 30 | printf("\n PREORDER: "); 31 | TR_preorder(root); 32 | printf("\n INORDER: "); 33 | TR_inorder(root); 34 | printf("\n POSTORDER: "); 35 | TR_postorder(root); 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/askisi2/circular_list.h: -------------------------------------------------------------------------------- 1 | /* queue.h : Dilwseis sindedemenis listas */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | typedef int elem; /* typos dedomenwn listas */ 7 | 8 | struct node{ /* Typos komvou listas */ 9 | elem data; /* dedomena */ 10 | struct node *next; /* epomenos */ 11 | }; 12 | 13 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 14 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 15 | 16 | void CL_init(LIST_PTR *head); 17 | int CL_empty(LIST_PTR head); 18 | elem CL_data(LIST_PTR p); 19 | int CL_insert_start(LIST_PTR *head,elem x); 20 | int CL_insert_after(LIST_PTR p,elem x); 21 | int CL_delete_start(LIST_PTR *head, elem *x); 22 | int CL_delete_after(LIST_PTR prev, elem *x); 23 | void CL_print(LIST_PTR head); 24 | void CL_destroy(LIST_PTR *head); 25 | 26 | int CL_get_i(LIST_PTR head, int n, elem *x); 27 | 28 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise03/disjoint_sets.h: -------------------------------------------------------------------------------- 1 | /* disjoint_sets.h : Ksena Sinola */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | typedef int elem; 7 | 8 | struct disjoint_node 9 | { 10 | int data; 11 | int height; 12 | struct disjoint_node *parent; 13 | }; 14 | 15 | typedef struct disjoint_node DISJOINT_NODE; 16 | typedef struct disjoint_node *DISJOINT_PTR; 17 | 18 | struct disjoint 19 | { 20 | DISJOINT_PTR *array; /* pinakas antiproswpwn */ 21 | int N; /* Plithos deiktwn */ 22 | }; 23 | 24 | typedef struct disjoint DISJOINT; 25 | 26 | 27 | /* Basikes Prakseis disjoint sets */ 28 | void DS_init(DISJOINT *d, int N); 29 | void DS_make_set(DISJOINT *d, elem x); 30 | int DS_union(DISJOINT *d, elem x, elem y); 31 | elem DS_find_set(DISJOINT d, elem x); 32 | void DS_destroy(DISJOINT *d); 33 | 34 | /* Deutereouses Prakseis disjoint sets */ 35 | void DS_print(DISJOINT d); 36 | 37 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/circular_list/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "circular_list.h" 4 | 5 | main() 6 | { 7 | LIST_PTR list; 8 | elem temp; 9 | 10 | CL_init(&list); 11 | 12 | CL_insert_start(&list, 1); 13 | CL_print(list); 14 | printf("\n"); 15 | 16 | CL_insert_start(&list, 2); 17 | CL_print(list); 18 | printf("\n"); 19 | 20 | CL_insert_after(list->next, 3); 21 | CL_print(list); 22 | printf("\n"); 23 | 24 | CL_insert_after(list, 4); 25 | CL_print(list); 26 | printf("\n"); 27 | 28 | CL_delete_start(&list, &temp); 29 | CL_print(list); 30 | printf("\n"); 31 | 32 | CL_delete_after(list->next, &temp); 33 | CL_print(list); 34 | printf("\n"); 35 | 36 | CL_delete_start(&list, &temp); 37 | CL_print(list); 38 | printf("\n"); 39 | 40 | CL_delete_start(&list, &temp); 41 | CL_print(list); 42 | printf("\n"); 43 | 44 | CL_destroy(&list); 45 | } 46 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/DisjointSets(ReverseTrees)/disjoint_sets.h: -------------------------------------------------------------------------------- 1 | /* disjoint_sets.h : Ksena Sinola */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | typedef int elem; 7 | 8 | struct disjoint_node 9 | { 10 | elem data; 11 | int height; 12 | struct disjoint_node *parent; 13 | }; 14 | 15 | typedef struct disjoint_node DISJOINT_NODE; 16 | typedef struct disjoint_node *DISJOINT_PTR; 17 | 18 | struct disjoint 19 | { 20 | DISJOINT_PTR *array; /* pinakas antiproswpwn */ 21 | int N; /* Plithos deiktwn */ 22 | }; 23 | 24 | typedef struct disjoint DISJOINT; 25 | 26 | 27 | /* Basikes Prakseis disjoint sets */ 28 | void DS_init(DISJOINT *d, int N); 29 | void DS_make_set(DISJOINT *d, elem x); 30 | int DS_union(DISJOINT *d, elem x, elem y); 31 | elem DS_find_set(DISJOINT d, elem x); 32 | void DS_destroy(DISJOINT *d); 33 | 34 | /* Deutereouses Prakseis disjoint sets */ 35 | void DS_print(DISJOINT d); 36 | 37 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/doubly_linked_list/doubly_linked_list.h: -------------------------------------------------------------------------------- 1 | /* double_linked_list.h : Dilwseis sindedemenis listas */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | typedef int elem; /* typos dedomenwn listas */ 7 | 8 | struct node{ /* Typos komvou listas */ 9 | elem data; /* dedomena */ 10 | struct node *next; /* epomenos */ 11 | struct node *prev; /* proigoumenos */ 12 | }; 13 | 14 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 15 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 16 | 17 | void DLL_init(LIST_PTR *head); 18 | int DLL_empty(LIST_PTR head); 19 | elem DLL_data(LIST_PTR p); 20 | int DLL_insert_start(LIST_PTR *head,elem x); 21 | int DLL_insert_after(LIST_PTR p,elem x); 22 | int DLL_delete_start(LIST_PTR *head, elem *x); 23 | int DLL_delete_after(LIST_PTR previous, elem *x); 24 | void DLL_print(LIST_PTR head); 25 | void LL_destroy(LIST_PTR *head); 26 | 27 | -------------------------------------------------------------------------------- /data_structures_10_graph/GraphAdjLists/linked_list.h: -------------------------------------------------------------------------------- 1 | /* linked_list.h : Dilwseis sindedemenis listas */ 2 | #ifndef LINKED_LIST_H 3 | #define LINKED_LIST_H 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | typedef int elem; /* typos dedomenwn listas */ 9 | 10 | struct node{ /* Typos komvou listas */ 11 | elem data; /* dedomena */ 12 | struct node *next; /* epomenos */ 13 | }; 14 | 15 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 16 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 17 | 18 | void LL_init(LIST_PTR *head); 19 | int LL_empty(LIST_PTR head); 20 | elem LL_data(LIST_PTR p); 21 | int LL_insert_start(LIST_PTR *head,elem x); 22 | int LL_insert_after(LIST_PTR p,elem x); 23 | int LL_delete_start(LIST_PTR *head, elem *x); 24 | int LL_delete_after(LIST_PTR prev, elem *x); 25 | void LL_print(LIST_PTR head); 26 | void LL_destroy(LIST_PTR *head); 27 | 28 | int LL_insert(LIST_PTR *head, elem x); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi4/efarmogi4_stack_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "efarmogi4_stack.h" 3 | 4 | main() 5 | { 6 | char c; 7 | STACK st; 8 | double x; 9 | double y1,y2; 10 | 11 | printf("Dwse ti metathematiki parastasi: "); 12 | c=getchar(); 13 | ST_init(&st); 14 | while (c!='\n') 15 | { 16 | if (c>='0' && c<='9') //psifio 17 | { 18 | x=c-'0'; 19 | ST_push(&st,x); 20 | } 21 | else //telestis 22 | { 23 | ST_pop(&st,&y1); 24 | ST_pop(&st,&y2); 25 | 26 | switch(c) 27 | { 28 | case '+': 29 | x=y1+y2; 30 | break; 31 | case '-': 32 | x=y2-y1; 33 | break; 34 | case '*': 35 | x=y1*y2; 36 | break; 37 | case '/': 38 | x=y2/y1; 39 | } 40 | 41 | ST_push(&st,x); 42 | } 43 | 44 | c=getchar(); 45 | } 46 | 47 | 48 | /* Ektypwsi tou apotelesmatos */ 49 | 50 | ST_pop(&st,&x); 51 | printf("To apotelesma einai: %.3f",x); 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise02/linked_list.h: -------------------------------------------------------------------------------- 1 | /* linked_list.h : Dilwseis sindedemenis listas */ 2 | #ifndef LINKED_LIST_H 3 | #define LINKED_LIST_H 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | typedef int elem; /* typos dedomenwn listas */ 9 | 10 | struct node{ /* Typos komvou listas */ 11 | elem data; /* dedomena */ 12 | struct node *next; /* epomenos */ 13 | }; 14 | 15 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 16 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 17 | 18 | void LL_init(LIST_PTR *head); 19 | int LL_empty(LIST_PTR head); 20 | elem LL_data(LIST_PTR p); 21 | int LL_insert_start(LIST_PTR *head,elem x); 22 | int LL_insert_after(LIST_PTR p,elem x); 23 | int LL_delete_start(LIST_PTR *head, elem *x); 24 | int LL_delete_after(LIST_PTR prev, elem *x); 25 | void LL_print(LIST_PTR head); 26 | void LL_destroy(LIST_PTR *head); 27 | 28 | int LL_insert(LIST_PTR *head, elem x); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/askisi1/doubly_linked_list.h: -------------------------------------------------------------------------------- 1 | /* double_linked_list.h : Dilwseis sindedemenis listas */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | typedef int elem; /* typos dedomenwn listas */ 7 | 8 | struct node{ /* Typos komvou listas */ 9 | elem data; /* dedomena */ 10 | struct node *next; /* epomenos */ 11 | struct node *prev; /* proigoumenos */ 12 | }; 13 | 14 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 15 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 16 | 17 | void DLL_init(LIST_PTR *head); 18 | int DLL_empty(LIST_PTR head); 19 | elem DLL_data(LIST_PTR p); 20 | int DLL_insert_start(LIST_PTR *head,elem x); 21 | int DLL_insert_after(LIST_PTR p,elem x); 22 | int DLL_delete_start(LIST_PTR *head, elem *x); 23 | int DLL_delete_after(LIST_PTR previous, elem *x); 24 | void DLL_print(LIST_PTR head); 25 | void LL_destroy(LIST_PTR *head); 26 | 27 | void DLL_print_reverse(LIST_PTR head); 28 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/DisjointSets(LinkedLists)/linked_list.h: -------------------------------------------------------------------------------- 1 | /* linked_list.h : Dilwseis sindedemenis listas */ 2 | #ifndef LINKED_LIST_H 3 | #define LINKED_LIST_H 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | typedef int elem; /* typos dedomenwn listas */ 9 | 10 | struct node{ /* Typos komvou listas */ 11 | elem data; /* dedomena */ 12 | struct node *next; /* epomenos */ 13 | }; 14 | 15 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 16 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 17 | 18 | void LL_init(LIST_PTR *head); 19 | int LL_empty(LIST_PTR head); 20 | elem LL_data(LIST_PTR p); 21 | int LL_insert_start(LIST_PTR *head,elem x); 22 | int LL_insert_after(LIST_PTR p,elem x); 23 | int LL_delete_start(LIST_PTR *head, elem *x); 24 | int LL_delete_after(LIST_PTR prev, elem *x); 25 | void LL_print(LIST_PTR head); 26 | void LL_destroy(LIST_PTR *head); 27 | 28 | int LL_insert(LIST_PTR *head, elem x); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /data_structures_7_binary_search_trees/tree/heap.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=heap.dev 3 | Name=heap 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings=0000000100000000000000000 32 | 33 | [VersionInfo] 34 | Major=1 35 | Minor=0 36 | Release=0 37 | Build=0 38 | LanguageID=1033 39 | CharsetID=1252 40 | CompanyName= 41 | FileVersion= 42 | FileDescription=Developed using the Dev-C++ IDE 43 | InternalName= 44 | LegalCopyright= 45 | LegalTrademarks= 46 | OriginalFilename= 47 | ProductName= 48 | ProductVersion= 49 | AutoIncBuildNr=0 50 | SyncProduct=1 51 | 52 | -------------------------------------------------------------------------------- /data_structures_6_trees/tree/tree.h: -------------------------------------------------------------------------------- 1 | /* tree.h : Dilwseis dendrou */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | typedef int elem; /* typos dedomenwn dendrou*/ 7 | 8 | struct node{ /* Typos komvou listas */ 9 | elem data; /* dedomena */ 10 | struct node *left; /* aristero paidi */ 11 | struct node *right; /* deksi paidi */ 12 | }; 13 | 14 | typedef struct node TREE_NODE; /* Sinwnimo tou komvou dendrou */ 15 | typedef struct node *TREE_PTR; /* Sinwnimo tou deikti komvou */ 16 | 17 | void TR_init(TREE_PTR *root); 18 | int TR_empty(TREE_PTR root); 19 | elem TR_data(TREE_PTR p); 20 | int TR_insert_root(TREE_PTR *root,elem x); 21 | int TR_insert_left(TREE_PTR node,elem x); 22 | int TR_insert_right(TREE_PTR node,elem x); 23 | int TR_delete_root(TREE_PTR *root, elem *x); 24 | int TR_delete_left(TREE_PTR parent, elem *x); 25 | int TR_delete_right(TREE_PTR parent, elem *x); 26 | void TR_preorder(TREE_PTR v); 27 | void TR_inorder(TREE_PTR v); 28 | void TR_postorder(TREE_PTR v); 29 | 30 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise3/linked_list.h: -------------------------------------------------------------------------------- 1 | /* linked_list.h : Dilwseis sindedemenis listas */ 2 | #ifndef LINKED_LIST_H 3 | #define LINKED_LIST_H 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | typedef int elem; /* typos dedomenwn listas */ 9 | 10 | struct node{ /* Typos komvou listas */ 11 | elem data; /* dedomena */ 12 | struct node *next; /* epomenos */ 13 | }; 14 | 15 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 16 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 17 | 18 | void LL_init(LIST_PTR *head); 19 | int LL_empty(LIST_PTR head); 20 | elem LL_data(LIST_PTR p); 21 | int LL_insert_start(LIST_PTR *head,elem x); 22 | int LL_insert_after(LIST_PTR p,elem x); 23 | int LL_delete_start(LIST_PTR *head, elem *x); 24 | int LL_delete_after(LIST_PTR prev, elem *x); 25 | void LL_print(LIST_PTR head); 26 | void LL_destroy(LIST_PTR *head); 27 | 28 | int LL_insert(LIST_PTR *head, elem x); 29 | void LL_to_array(LIST_PTR head, int *length, int **elements); 30 | #endif 31 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise01/linked_list.h: -------------------------------------------------------------------------------- 1 | /* linked_list.h : Dilwseis sindedemenis listas */ 2 | #ifndef LINKED_LIST_H 3 | #define LINKED_LIST_H 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | typedef int elem; /* typos dedomenwn listas */ 9 | 10 | struct node{ /* Typos komvou listas */ 11 | elem data; /* dedomena */ 12 | struct node *next; /* epomenos */ 13 | }; 14 | 15 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 16 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 17 | 18 | void LL_init(LIST_PTR *head); 19 | int LL_empty(LIST_PTR head); 20 | elem LL_data(LIST_PTR p); 21 | int LL_insert_start(LIST_PTR *head,elem x); 22 | int LL_insert_after(LIST_PTR p,elem x); 23 | int LL_delete_start(LIST_PTR *head, elem *x); 24 | int LL_delete_after(LIST_PTR prev, elem *x); 25 | void LL_print(LIST_PTR head); 26 | void LL_destroy(LIST_PTR *head); 27 | 28 | int LL_insert(LIST_PTR *head, elem x); 29 | void LL_to_array(LIST_PTR head, int *length, elem **elements); 30 | #endif 31 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise4/linked_list.h: -------------------------------------------------------------------------------- 1 | /* linked_list.h : Dilwseis sindedemenis listas */ 2 | #ifndef LINKED_LIST_H 3 | #define LINKED_LIST_H 4 | 5 | #define TRUE 1 6 | #define FALSE 0 7 | 8 | struct ELEM{ 9 | int id; 10 | int weight; 11 | }; 12 | 13 | typedef struct ELEM elem; /* typos dedomenwn listas */ 14 | 15 | struct node{ /* Typos komvou listas */ 16 | elem data; /* dedomena */ 17 | struct node *next; /* epomenos */ 18 | }; 19 | 20 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 21 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 22 | 23 | void LL_init(LIST_PTR *head); 24 | int LL_empty(LIST_PTR head); 25 | elem LL_data(LIST_PTR p); 26 | int LL_insert_start(LIST_PTR *head,elem x); 27 | int LL_insert_after(LIST_PTR p,elem x); 28 | int LL_delete_start(LIST_PTR *head, elem *x); 29 | int LL_delete_after(LIST_PTR prev, elem *x); 30 | void LL_print(LIST_PTR head); 31 | void LL_destroy(LIST_PTR *head); 32 | 33 | int LL_insert(LIST_PTR *head, int id, int weight); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/askisi2/stack.h: -------------------------------------------------------------------------------- 1 | /* stack.h : Dilwseis stoivas */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | typedef int elem; /* typos dedomenwn listas */ 7 | 8 | struct node{ /* Typos komvou listas */ 9 | elem data; /* dedomena */ 10 | struct node *next; /* epomenos */ 11 | }; 12 | 13 | typedef struct node LIST_NODE; /* Sinwnimo tou komvou listas */ 14 | typedef struct node *LIST_PTR; /* Sinwnimo tou deikti komvou */ 15 | 16 | typedef LIST_PTR STACK; 17 | 18 | void LL_init(LIST_PTR *head); 19 | int LL_empty(LIST_PTR head); 20 | elem LL_data(LIST_PTR p); 21 | int LL_insert_start(LIST_PTR *head,elem x); 22 | int LL_insert_after(LIST_PTR p,elem x); 23 | int LL_delete_start(LIST_PTR *head, elem *x); 24 | int LL_delete_after(LIST_PTR prev, elem *x); 25 | void LL_print(LIST_PTR head); 26 | void LL_destroy(LIST_PTR *head); 27 | 28 | void ST_init(STACK *s); 29 | int ST_empty(STACK s); 30 | int ST_push(STACK *s,elem x); 31 | int ST_pop(STACK *s,elem *x); 32 | int ST_print(STACK s); 33 | int ST_destroy(STACK *s); 34 | 35 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise01/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "graph.h" 4 | #include "disjoint_sets.h" 5 | 6 | DISJOINT ConnectedComponents(GRAPH g); 7 | 8 | int main() 9 | { 10 | GRAPH g; 11 | DISJOINT d; 12 | 13 | GR_init_from_file(&g, "graph2.graph"); 14 | printf("Initial Graph\n"); 15 | GR_print(g); 16 | 17 | d = ConnectedComponents(g); 18 | 19 | printf("\nConnected components: "); 20 | DS_print(d); 21 | 22 | DS_destroy(&d); 23 | 24 | return 0; 25 | } 26 | 27 | DISJOINT ConnectedComponents(GRAPH g) 28 | { 29 | DISJOINT d; 30 | int i, v, vertices; 31 | int *neighbors, neighbors_length; 32 | 33 | vertices = GR_vertices_count(g); 34 | DS_init(&d, vertices); 35 | 36 | for (v=0; vtop=-1; 10 | } 11 | 12 | /* ST_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i stoiva einai adeia */ 14 | int ST_empty(STACK s) 15 | { 16 | return s.top==-1; 17 | } 18 | 19 | /* ST_full(): epistrefei TRUE/FALSE 20 | * analoga me to an i stoiva einai gemati */ 21 | int ST_full(STACK s) 22 | { 23 | return s.top==STACK_SIZE-1; 24 | } 25 | 26 | /* ST_push(): Eisagei to x sti stoiva s 27 | * epistrefei TRUE: se periptwsi epitixias 28 | * FALSE: se periptwsi apotixias */ 29 | int ST_push(STACK *s,elem x) 30 | { 31 | if (ST_full(*s)) 32 | return FALSE; 33 | else 34 | { 35 | s->top++; 36 | s->array[s->top]=x; 37 | return TRUE; 38 | } 39 | } 40 | 41 | 42 | /* ST_pop(): Kanei eksagwgi poy einai stin korifi tis listas 43 | * epistrefei TRUE: se periptwsi epitixias 44 | * FALSE: se periptwsi apotixias */ 45 | int ST_pop(STACK *s,elem *x) 46 | { 47 | if (ST_empty(*s)) 48 | return FALSE; 49 | else 50 | { 51 | *x=s->array[s->top]; 52 | s->top--; 53 | return TRUE; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi4/stack.c: -------------------------------------------------------------------------------- 1 | /* stack.c: Kwdikas tis vivliothikis stoivas */ 2 | #include "stack.h" 3 | 4 | 5 | 6 | /* ST_init(): arxikopoiei ti lista */ 7 | void ST_init(STACK *s) 8 | { 9 | s->top=-1; 10 | } 11 | 12 | /* ST_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i stoiva einai adeia */ 14 | int ST_empty(STACK s) 15 | { 16 | return s.top==-1; 17 | } 18 | 19 | /* ST_full(): epistrefei TRUE/FALSE 20 | * analoga me to an i stoiva einai gemati */ 21 | int ST_full(STACK s) 22 | { 23 | return s.top==STACK_SIZE-1; 24 | } 25 | 26 | /* ST_push(): Eisagei to x sti stoiva s 27 | * epistrefei TRUE: se periptwsi epitixias 28 | * FALSE: se periptwsi apotixias */ 29 | int ST_push(STACK *s,elem x) 30 | { 31 | if (ST_full(*s)) 32 | return FALSE; 33 | else 34 | { 35 | s->top++; 36 | s->array[s->top]=x; 37 | return TRUE; 38 | } 39 | } 40 | 41 | 42 | /* ST_pop(): Kanei eksagwgi poy einai stin korifi tis listas 43 | * epistrefei TRUE: se periptwsi epitixias 44 | * FALSE: se periptwsi apotixias */ 45 | int ST_pop(STACK *s,elem *x) 46 | { 47 | if (ST_empty(*s)) 48 | return FALSE; 49 | else 50 | { 51 | *x=s->array[s->top]; 52 | s->top--; 53 | return TRUE; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /data_structures_2_stack/stack_char/stack_char.c: -------------------------------------------------------------------------------- 1 | /* stack.c: Kwdikas tis vivliothikis stoivas */ 2 | #include "stack_char.h" 3 | 4 | 5 | 6 | /* ST_init(): arxikopoiei ti lista */ 7 | void ST_init(STACK *s) 8 | { 9 | s->top=-1; 10 | } 11 | 12 | /* ST_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i stoiva einai adeia */ 14 | int ST_empty(STACK s) 15 | { 16 | return s.top==-1; 17 | } 18 | 19 | /* ST_full(): epistrefei TRUE/FALSE 20 | * analoga me to an i stoiva einai gemati */ 21 | int ST_full(STACK s) 22 | { 23 | return s.top==STACK_SIZE-1; 24 | } 25 | 26 | /* ST_push(): Eisagei to x sti stoiva s 27 | * epistrefei TRUE: se periptwsi epitixias 28 | * FALSE: se periptwsi apotixias */ 29 | int ST_push(STACK *s,elem x) 30 | { 31 | if (ST_full(*s)) 32 | return FALSE; 33 | else 34 | { 35 | s->top++; 36 | s->array[s->top]=x; 37 | return TRUE; 38 | } 39 | } 40 | 41 | 42 | /* ST_pop(): Kanei eksagwgi poy einai stin korifi tis listas 43 | * epistrefei TRUE: se periptwsi epitixias 44 | * FALSE: se periptwsi apotixias */ 45 | int ST_pop(STACK *s,elem *x) 46 | { 47 | if (ST_empty(*s)) 48 | return FALSE; 49 | else 50 | { 51 | *x=s->array[s->top]; 52 | s->top--; 53 | return TRUE; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi2/efarmogi2_stack.c: -------------------------------------------------------------------------------- 1 | /* stack.c: Kwdikas tis vivliothikis stoivas */ 2 | #include "efarmogi2_stack.h" 3 | 4 | 5 | 6 | /* ST_init(): arxikopoiei ti lista */ 7 | void ST_init(STACK *s) 8 | { 9 | s->top=-1; 10 | } 11 | 12 | /* ST_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i stoiva einai adeia */ 14 | int ST_empty(STACK s) 15 | { 16 | return s.top==-1; 17 | } 18 | 19 | /* ST_full(): epistrefei TRUE/FALSE 20 | * analoga me to an i stoiva einai gemati */ 21 | int ST_full(STACK s) 22 | { 23 | return s.top==STACK_SIZE-1; 24 | } 25 | 26 | /* ST_push(): Eisagei to x sti stoiva s 27 | * epistrefei TRUE: se periptwsi epitixias 28 | * FALSE: se periptwsi apotixias */ 29 | int ST_push(STACK *s,elem x) 30 | { 31 | if (ST_full(*s)) 32 | return FALSE; 33 | else 34 | { 35 | s->top++; 36 | s->array[s->top]=x; 37 | return TRUE; 38 | } 39 | } 40 | 41 | 42 | /* ST_pop(): Kanei eksagwgi poy einai stin korifi tis listas 43 | * epistrefei TRUE: se periptwsi epitixias 44 | * FALSE: se periptwsi apotixias */ 45 | int ST_pop(STACK *s,elem *x) 46 | { 47 | if (ST_empty(*s)) 48 | return FALSE; 49 | else 50 | { 51 | *x=s->array[s->top]; 52 | s->top--; 53 | return TRUE; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi3/efarmogi3_stack.c: -------------------------------------------------------------------------------- 1 | /* stack.c: Kwdikas tis vivliothikis stoivas */ 2 | #include "efarmogi3_stack.h" 3 | 4 | 5 | 6 | /* ST_init(): arxikopoiei ti lista */ 7 | void ST_init(STACK *s) 8 | { 9 | s->top=-1; 10 | } 11 | 12 | /* ST_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i stoiva einai adeia */ 14 | int ST_empty(STACK s) 15 | { 16 | return s.top==-1; 17 | } 18 | 19 | /* ST_full(): epistrefei TRUE/FALSE 20 | * analoga me to an i stoiva einai gemati */ 21 | int ST_full(STACK s) 22 | { 23 | return s.top==STACK_SIZE-1; 24 | } 25 | 26 | /* ST_push(): Eisagei to x sti stoiva s 27 | * epistrefei TRUE: se periptwsi epitixias 28 | * FALSE: se periptwsi apotixias */ 29 | int ST_push(STACK *s,elem x) 30 | { 31 | if (ST_full(*s)) 32 | return FALSE; 33 | else 34 | { 35 | s->top++; 36 | s->array[s->top]=x; 37 | return TRUE; 38 | } 39 | } 40 | 41 | 42 | /* ST_pop(): Kanei eksagwgi poy einai stin korifi tis listas 43 | * epistrefei TRUE: se periptwsi epitixias 44 | * FALSE: se periptwsi apotixias */ 45 | int ST_pop(STACK *s,elem *x) 46 | { 47 | if (ST_empty(*s)) 48 | return FALSE; 49 | else 50 | { 51 | *x=s->array[s->top]; 52 | s->top--; 53 | return TRUE; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi4/efarmogi4_stack.c: -------------------------------------------------------------------------------- 1 | /* stack.c: Kwdikas tis vivliothikis stoivas */ 2 | #include "efarmogi4_stack.h" 3 | 4 | 5 | 6 | /* ST_init(): arxikopoiei ti lista */ 7 | void ST_init(STACK *s) 8 | { 9 | s->top=-1; 10 | } 11 | 12 | /* ST_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i stoiva einai adeia */ 14 | int ST_empty(STACK s) 15 | { 16 | return s.top==-1; 17 | } 18 | 19 | /* ST_full(): epistrefei TRUE/FALSE 20 | * analoga me to an i stoiva einai gemati */ 21 | int ST_full(STACK s) 22 | { 23 | return s.top==STACK_SIZE-1; 24 | } 25 | 26 | /* ST_push(): Eisagei to x sti stoiva s 27 | * epistrefei TRUE: se periptwsi epitixias 28 | * FALSE: se periptwsi apotixias */ 29 | int ST_push(STACK *s,elem x) 30 | { 31 | if (ST_full(*s)) 32 | return FALSE; 33 | else 34 | { 35 | s->top++; 36 | s->array[s->top]=x; 37 | return TRUE; 38 | } 39 | } 40 | 41 | 42 | /* ST_pop(): Kanei eksagwgi poy einai stin korifi tis listas 43 | * epistrefei TRUE: se periptwsi epitixias 44 | * FALSE: se periptwsi apotixias */ 45 | int ST_pop(STACK *s,elem *x) 46 | { 47 | if (ST_empty(*s)) 48 | return FALSE; 49 | else 50 | { 51 | *x=s->array[s->top]; 52 | s->top--; 53 | return TRUE; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/sequential_list/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "sequential_list.h" 4 | 5 | main() 6 | { 7 | int d; 8 | LIST l; 9 | 10 | SL_init(&l); 11 | 12 | /* Eisagwgi tou "1" */ 13 | SL_insert(&l, 0, 1); 14 | 15 | printf("\n"); 16 | SL_print(l); 17 | 18 | /* Eisagwgi tou "2" stin arxi */ 19 | SL_insert(&l, 0, 2); 20 | 21 | printf("\n"); 22 | SL_print(l); 23 | 24 | /* Eisagwgi tou "3" sti thesi 1 */ 25 | SL_insert(&l, 1, 3); 26 | 27 | printf("\n"); 28 | SL_print(l); 29 | 30 | /* Eisagwgi tou "4" sti thesi 2 */ 31 | SL_insert(&l, 2, 4); 32 | 33 | printf("\n"); 34 | SL_print(l); 35 | 36 | /* Eisagwgi tou "5" stin arxi */ 37 | SL_insert(&l, 0, 5); 38 | 39 | printf("\n"); 40 | SL_print(l); 41 | 42 | /* Eisagwgi tou "6" stin arxi */ 43 | SL_insert(&l, 0, 6); 44 | 45 | printf("\n"); 46 | SL_print(l); 47 | 48 | /* Eisagwgi tou "7" sto telos */ 49 | SL_insert(&l, 6, 7); 50 | 51 | printf("\n"); 52 | SL_print(l); 53 | 54 | /* Diagrafi tou 1ou stoixeiou */ 55 | SL_delete(&l, 0, &d); 56 | 57 | printf("\n"); 58 | SL_print(l); 59 | 60 | /* Diagrafi tou teleytaiou stoixeiou */ 61 | SL_delete(&l, 5, &d); 62 | 63 | printf("\n"); 64 | SL_print(l); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /data_structures_2_stack/stack/stack_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "stack.h" 4 | 5 | main() 6 | { 7 | int choice,elem,i; 8 | STACK st; 9 | 10 | ST_init(&st); 11 | 12 | while(1) 13 | { 14 | system("cls"); 15 | printf("Menu Stoivas: "); 16 | printf("\n--------------"); 17 | printf("\n1-Othisi"); 18 | printf("\n2-Eksagogi"); 19 | printf("\n3-Ektypwsi"); 20 | printf("\n4-Eksodos"); 21 | printf("\nEpilogi? "); 22 | scanf("%d",&choice); 23 | 24 | switch(choice) 25 | { 26 | case 1: 27 | printf("\nDwse Stoixeio: "); 28 | scanf("%d",&elem); 29 | if (ST_push(&st,elem)) 30 | printf("Egine i othisi!"); 31 | else 32 | printf("Den egine i othisi! Gemati Stoiva!"); 33 | break; 34 | case 2: 35 | if (ST_pop(&st,&elem)) 36 | printf("Egine i eksagogi tou %d", elem); 37 | else 38 | printf("Den egine i eksagogi! Adeia Stoiva!"); 39 | break; 40 | case 3: 41 | //MONO GIA EKPAIDEYTIKOUS LOGOUS!!! 42 | //Apagorevetai na akoumpame ti domi!! 43 | printf("\n\nH stoiva exei %d stoixeia: \n", st.top+1); 44 | for (i=0; i<=st.top; i++) 45 | { 46 | printf("|%3d",st.array[i]); 47 | } 48 | break; 49 | case 4: 50 | printf("Bye Bye!!"); 51 | exit(0); 52 | default: 53 | printf("Lathos eisodos!"); 54 | } 55 | printf("\n\n"); 56 | system("pause"); 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /data_structures_3_queue/simple_queue/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "queue.h" 4 | 5 | main() 6 | { 7 | int choice,elem,i; 8 | QUEUE q; 9 | 10 | QU_init(&q); 11 | 12 | while(1) 13 | { 14 | system("cls"); 15 | printf("Menu Ouras: "); 16 | printf("\n--------------"); 17 | printf("\n1-Eisagwgi"); 18 | printf("\n2-Apomakrinsi"); 19 | printf("\n3-Ektypwsi"); 20 | printf("\n4-Eksodos"); 21 | printf("\nEpilogi? "); 22 | scanf("%d",&choice); 23 | 24 | switch(choice) 25 | { 26 | case 1: 27 | printf("\nDwse Stoixeio: "); 28 | scanf("%d",&elem); 29 | if (QU_enqueue(&q,elem)) 30 | printf("Egine i eisagwgi!"); 31 | else 32 | printf("Den egine i eiasagwgi! Gemati Oura!"); 33 | break; 34 | case 2: 35 | if (QU_dequeue(&q,&elem)) 36 | printf("Egine i apomakrinsi tou %d", elem); 37 | else 38 | printf("Den egine i apomakrinsi! Adeia Oura!"); 39 | break; 40 | case 3: 41 | //MONO GIA EKPAIDEYTIKOUS LOGOUS!!! 42 | //Apagorevetai na akoumpame ti domi!! 43 | printf("\n\nH oura exei %d stoixeia: \n", q.finish+1); 44 | for (i=0; i<=q.finish; i++) 45 | { 46 | printf("|%3d",q.array[i]); 47 | } 48 | break; 49 | case 4: 50 | printf("Bye Bye!!"); 51 | exit(0); 52 | default: 53 | printf("Lathos eisodos!"); 54 | } 55 | printf("\n\n"); 56 | system("pause"); 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /data_structures_2_stack/stack_char/stack_main_char.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "stack_char.h" 4 | 5 | main() 6 | { 7 | int choice,i; 8 | char elem; 9 | STACK st; 10 | 11 | ST_init(&st); 12 | 13 | while(1) 14 | { 15 | system("cls"); 16 | printf("Menu Stoivas: "); 17 | printf("\n--------------"); 18 | printf("\n1-Othisi"); 19 | printf("\n2-Eksagogi"); 20 | printf("\n3-Ektypwsi"); 21 | printf("\n4-Eksodos"); 22 | printf("\nEpilogi? "); 23 | scanf("%d",&choice); 24 | 25 | switch(choice) 26 | { 27 | case 1: 28 | printf("\nDwse Stoixeio: "); 29 | fflush(stdin); 30 | scanf("%c",&elem); 31 | if (ST_push(&st,elem)) 32 | printf("Egine i othisi!"); 33 | else 34 | printf("Den egine i othisi! Gemati Stoiva!"); 35 | break; 36 | case 2: 37 | if (ST_pop(&st,&elem)) 38 | printf("Egine i eksagogi tou %c", elem); 39 | else 40 | printf("Den egine i eksagogi! Adeia Stoiva!"); 41 | break; 42 | case 3: 43 | //MONO GIA EKPAIDEYTIKOUS LOGOUS!!! 44 | //Apagorevetai na akoumpame ti domi!! 45 | printf("\n\nH stoiva exei %d stoixeia: \n", st.top+1); 46 | for (i=0; i<=st.top; i++) 47 | { 48 | printf("|%c",st.array[i]); 49 | } 50 | break; 51 | case 4: 52 | printf("Bye Bye!!"); 53 | exit(0); 54 | default: 55 | printf("Lathos eisodos!"); 56 | } 57 | printf("\n\n"); 58 | system("pause"); 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /data_structures_9_avl/AVL.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=AVL.dev 3 | Name=AVL 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings=0000000000000000001000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=tree.c 65 | CompileCpp=0 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=tree.h 75 | CompileCpp=0 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_3_queue/simple_queue/queue.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=queue.dev 3 | Name=queue 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings= 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder=queue 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=queue.c 65 | CompileCpp=0 66 | Folder=queue 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=queue.h 75 | CompileCpp=0 76 | Folder=queue 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_6_trees/tree/tree.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=tree.dev 3 | Name=tree 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings=0000000100000000001000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit2] 54 | FileName=tree.h 55 | CompileCpp=0 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit3] 64 | FileName=main.c 65 | CompileCpp=0 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit1] 74 | FileName=tree.c 75 | CompileCpp=0 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_8_heaps/tree/tree.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=tree.dev 3 | Name=tree 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings=0000000100000000001000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit2] 54 | FileName=tree.h 55 | CompileCpp=0 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit3] 64 | FileName=main.c 65 | CompileCpp=0 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit1] 74 | FileName=tree.c 75 | CompileCpp=0 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi1/circular.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=circular.dev 3 | Name=queue 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings= 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder=queue 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=queue.c 65 | CompileCpp=0 66 | Folder=queue 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=queue.h 75 | CompileCpp=0 76 | Folder=queue 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi2/circular.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=circular.dev 3 | Name=queue 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings= 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder=queue 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=queue.c 65 | CompileCpp=0 66 | Folder=queue 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=queue.h 75 | CompileCpp=0 76 | Folder=queue 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_3_queue/circular_queue/circular.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=circular.dev 3 | Name=queue 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings= 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder=queue 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=queue.c 65 | CompileCpp=0 66 | Folder=queue 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=queue.h 75 | CompileCpp=0 76 | Folder=queue 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_8_heaps/tree/heap.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=heap.dev 3 | Name=heap 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings=0000000100000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=heap.c 55 | CompileCpp=0 56 | Folder=heap 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=heap.h 65 | CompileCpp=0 66 | Folder=heap 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=main.c 75 | CompileCpp=0 76 | Folder=heap 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/askisi2/askisi2.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=askisi2.dev 3 | Name=askisi2 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings=0000000000000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=stack.c 65 | CompileCpp=0 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=stack.h 75 | CompileCpp=0 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/askisi3/askisi3.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=askisi3.dev 3 | Name=askisi3 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings=0000000000000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=queue.c 65 | CompileCpp=0 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=queue.h 75 | CompileCpp=0 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_3_queue/circular_queue/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "queue.h" 4 | 5 | main() 6 | { 7 | int choice,elem,i; 8 | QUEUE q; 9 | 10 | QU_init(&q); 11 | 12 | while(1) 13 | { 14 | system("cls"); 15 | printf("Menu Ouras: "); 16 | printf("\n--------------"); 17 | printf("\n1-Eisagwgi"); 18 | printf("\n2-Apomakrinsi"); 19 | printf("\n3-Ektypwsi"); 20 | printf("\n4-Eksodos"); 21 | printf("\nEpilogi? "); 22 | scanf("%d",&choice); 23 | 24 | switch(choice) 25 | { 26 | case 1: 27 | printf("\nDwse Stoixeio: "); 28 | scanf("%d",&elem); 29 | if (QU_enqueue(&q,elem)) 30 | printf("Egine i eisagwgi!"); 31 | else 32 | printf("Den egine i eiasagwgi! Gemati Oura!"); 33 | break; 34 | case 2: 35 | if (QU_dequeue(&q,&elem)) 36 | printf("Egine i apomakrinsi tou %d", elem); 37 | else 38 | printf("Den egine i apomakrinsi! Adeia Oura!"); 39 | break; 40 | case 3: 41 | //MONO GIA EKPAIDEYTIKOUS LOGOUS!!! 42 | //Apagorevetai na akoumpame ti domi!! 43 | if (q.start!=-1) 44 | { 45 | i=q.start; 46 | while (1) 47 | { 48 | printf("|%3d",q.array[i]); 49 | if (i==q.finish) 50 | break; 51 | i=(i+1)%QUEUE_SIZE; 52 | } 53 | } 54 | break; 55 | case 4: 56 | printf("Bye Bye!!"); 57 | exit(0); 58 | default: 59 | printf("Lathos eisodos!"); 60 | } 61 | printf("\n\n"); 62 | system("pause"); 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/askisi1/askisi1.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=askisi1.dev 3 | Name=askisi1 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings=0000000000000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=linked_list.c 65 | CompileCpp=0 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=linked_list.h 75 | CompileCpp=0 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/askisi2/askisi2.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=askisi2.dev 3 | Name=askisi2 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings=0000000000000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=circular_list.c 65 | CompileCpp=0 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=circular_list.h 75 | CompileCpp=0 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi1/efarmogi1.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=efarmogi1.dev 3 | Name=Project1 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings= 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=stack_char.c 55 | CompileCpp=0 56 | Folder=Project1 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=stack_char.h 65 | CompileCpp=0 66 | Folder=Project1 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=stack_main_char.c 75 | CompileCpp=0 76 | Folder=Project1 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/linked_list/linked_list.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=linked_list.dev 3 | Name=linked_list 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=1 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings=0000000100000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=1 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=linked_list.h 65 | CompileCpp=1 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=linked_list.c 75 | CompileCpp=1 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/askisi1/askisi1.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=askisi1.dev 3 | Name=askisi1 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings=0000000000000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=doubly_linked_list.c 65 | CompileCpp=0 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=doubly_linked_list.h 75 | CompileCpp=0 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_9_avl/tree.h: -------------------------------------------------------------------------------- 1 | /* tree.h : Dilwseis dendrou AVL */ 2 | 3 | #define TRUE 1 4 | #define FALSE 0 5 | 6 | #define DEPTH 100 /* Megisto Epitrepto Ipsos Dentroy */ 7 | 8 | typedef int elem; /* typos dedomenwn dendrou*/ 9 | 10 | struct node{ /* Typos komvou listas */ 11 | elem data; /* dedomena */ 12 | struct node *left; /* aristero paidi */ 13 | struct node *right; /* deksi paidi */ 14 | int height; /* Ypsos toy ypodendroy */ 15 | }; 16 | 17 | typedef struct node TREE_NODE; /* Sinwnimo tou komvou dendrou */ 18 | typedef struct node *TREE_PTR; /* Sinwnimo tou deikti komvou */ 19 | 20 | void TR_init(TREE_PTR *root); 21 | int TR_empty(TREE_PTR root); 22 | elem TR_data(TREE_PTR p); 23 | int TR_insert_root(TREE_PTR *root,elem x); 24 | int TR_insert_left(TREE_PTR node,elem x); 25 | int TR_insert_right(TREE_PTR node,elem x); 26 | int TR_delete_root(TREE_PTR *root, elem *x); 27 | int TR_delete_left(TREE_PTR parent, elem *x); 28 | int TR_delete_right(TREE_PTR parent, elem *x); 29 | void TR_preorder(TREE_PTR v); 30 | void TR_inorder(TREE_PTR v); 31 | void TR_postorder(TREE_PTR v); 32 | 33 | int TR_delete_BST(TREE_PTR *root, elem x); 34 | 35 | TREE_PTR AVL_rotate_R(TREE_PTR C); 36 | TREE_PTR AVL_rotate_L(TREE_PTR C); 37 | TREE_PTR AVL_rotate_LR(TREE_PTR C); 38 | TREE_PTR AVL_rotate_RL(TREE_PTR C); 39 | 40 | TREE_PTR TR_insert_AVL(TREE_PTR *root, elem x); 41 | int TR_delete_AVL(TREE_PTR *root, elem x); 42 | int TR_search_AVL(TREE_PTR root, elem x); 43 | void TR_print_AVL(TREE_PTR root); 44 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi2/efarmogi2.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=efarmogi2.dev 3 | Name=efarmogi2 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings= 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=efarmogi2_stack.c 55 | CompileCpp=0 56 | Folder=efarmogi2 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=efarmogi2_stack.h 65 | CompileCpp=0 66 | Folder=efarmogi2 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=efarmogi2_main.c 75 | CompileCpp=0 76 | Folder=efarmogi2 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_2_stack/stack/stack.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=stack.dev 3 | Name=stack 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName=stack.exe 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings=0000000000000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion=1.0.0.0 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion=1.0.0.0 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=stack.c 55 | CompileCpp=0 56 | Folder=Project5 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=stack.h 65 | CompileCpp=0 66 | Folder=Project5 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=stack_main.c 75 | CompileCpp=0 76 | Folder=Project5 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi3/efarmogi3.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=efarmogi3.dev 3 | Name=efarmogi3 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings= 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=efarmogi3_stack.c 55 | CompileCpp=0 56 | Folder=efarmogi3 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=efarmogi3_stack.h 65 | CompileCpp=0 66 | Folder=efarmogi3 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=efarmogi3_stack_main.c 75 | CompileCpp=0 76 | Folder=efarmogi3 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi4/efarmogi4.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=efarmogi4.dev 3 | Name=efarmogi4 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings= 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=efarmogi4_stack.h 55 | CompileCpp=0 56 | Folder=efarmogi4 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=efarmogi4_stack.c 65 | CompileCpp=0 66 | Folder=efarmogi4 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=efarmogi4_stack_main.c 75 | CompileCpp=0 76 | Folder=efarmogi4 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/sequential_list/linked_list.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=linked_list.dev 3 | Name=linked_list 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=1 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings=0000000100000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=1 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=sequential_list.h 65 | CompileCpp=1 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=sequential_list.c 75 | CompileCpp=1 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/circular_list/circular_list.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=circular_list.dev 3 | Name=circular_list 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings=0000000000000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=circular_list.c 65 | CompileCpp=0 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=circular_list.h 75 | CompileCpp=0 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_3_queue/simple_queue/queue.c: -------------------------------------------------------------------------------- 1 | /* queue.c: Kwdikas tis vivliothikis ouras */ 2 | #include "queue.h" 3 | 4 | 5 | 6 | /* QU_init(): arxikopoiei tin oura */ 7 | void QU_init(QUEUE *q) 8 | { 9 | q->finish=-1; 10 | } 11 | 12 | /* QU_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i oura einai adeia */ 14 | int QU_empty(QUEUE q) 15 | { 16 | return q.finish==-1; 17 | } 18 | 19 | /* QU_full(): epistrefei TRUE/FALSE 20 | * analoga me to an i oura einai gemati */ 21 | int QU_full(QUEUE q) 22 | { 23 | return q.finish==QUEUE_SIZE-1; 24 | } 25 | 26 | /* QU_enqueue(): Eisagei to x stin oura q 27 | * epistrefei TRUE: se periptwsi epitixias 28 | * FALSE: se periptwsi apotixias */ 29 | int QU_enqueue(QUEUE *q,elem x) 30 | { 31 | if (QU_full(*q)) 32 | return FALSE; 33 | else 34 | { 35 | q->finish++; 36 | q->array[q->finish]=x; 37 | return TRUE; 38 | } 39 | } 40 | 41 | 42 | /* QU_dequeue(): Kanei apomakrinsi tou prwtou stoixeiou tis ouras 43 | * epistrefei TRUE: se periptwsi epitixias 44 | * FALSE: se periptwsi apotixias */ 45 | int QU_dequeue(QUEUE *q,elem *x) 46 | { 47 | int i; 48 | 49 | if (QU_empty(*q)) 50 | return FALSE; 51 | else 52 | { 53 | /* 1. Apothikeysi tou stoixeiou pou eksagetai*/ 54 | *x=q->array[0]; 55 | 56 | /* 2. Aristeri metakinisi twn stoixeiwn kata mia thesi */ 57 | for (i=0; ifinish; i++) 58 | q->array[i]=q->array[i+1]; 59 | 60 | /* 3. To finish meiwnetai kata 1 */ 61 | q->finish--; 62 | 63 | return TRUE; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/doubly_linked_list/doubly_linked_list.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=double_linked_list.dev 3 | Name=double_linked_list 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings=0000000000000000000000000 32 | UnitCount=3 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit2] 54 | FileName=doubly_linked_list.c 55 | CompileCpp=0 56 | Folder= 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit3] 64 | FileName=doubly_linked_list.h 65 | CompileCpp=0 66 | Folder= 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit1] 74 | FileName=main.c 75 | CompileCpp=0 76 | Folder= 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | -------------------------------------------------------------------------------- /data_structures_9_avl/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "tree.h" 3 | 4 | int main() 5 | { 6 | TREE_PTR tree; 7 | 8 | TR_init(&tree); 9 | 10 | TR_insert_AVL(&tree, 2); 11 | TR_print_AVL(tree); 12 | printf("\n"); 13 | TR_insert_AVL(&tree, 20); 14 | TR_print_AVL(tree); 15 | printf("\n"); 16 | TR_insert_AVL(&tree, 28); 17 | TR_print_AVL(tree); 18 | printf("\n"); 19 | TR_insert_AVL(&tree, 36); 20 | TR_print_AVL(tree); 21 | printf("\n"); 22 | TR_insert_AVL(&tree, 32); 23 | TR_print_AVL(tree); 24 | printf("\n"); 25 | TR_insert_AVL(&tree, 29); 26 | TR_print_AVL(tree); 27 | printf("\n"); 28 | TR_insert_AVL(&tree, 7); 29 | TR_print_AVL(tree); 30 | printf("\n"); 31 | TR_insert_AVL(&tree, 15); 32 | TR_print_AVL(tree); 33 | printf("\n"); 34 | TR_insert_AVL(&tree, 12); 35 | TR_print_AVL(tree); 36 | printf("\n"); 37 | TR_delete_AVL(&tree, 32); 38 | TR_print_AVL(tree); 39 | printf("\n"); 40 | TR_delete_AVL(&tree, 36); 41 | TR_print_AVL(tree); 42 | printf("\n"); 43 | TR_delete_AVL(&tree, 2); 44 | TR_print_AVL(tree); 45 | printf("\n"); 46 | TR_delete_AVL(&tree, 7); 47 | TR_print_AVL(tree); 48 | printf("\n"); 49 | TR_delete_AVL(&tree, 12); 50 | TR_print_AVL(tree); 51 | printf("\n"); 52 | TR_delete_AVL(&tree, 15); 53 | TR_print_AVL(tree); 54 | printf("\n"); 55 | TR_delete_AVL(&tree, 28); 56 | TR_print_AVL(tree); 57 | printf("\n"); 58 | TR_delete_AVL(&tree, 29); 59 | TR_print_AVL(tree); 60 | printf("\n"); 61 | TR_delete_AVL(&tree, 20); 62 | TR_print_AVL(tree); 63 | 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /data_structures_2_stack/efarmogi2/efarmogi2_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "efarmogi2_stack.h" 4 | 5 | main() 6 | { 7 | int choice,i; 8 | STACK st; 9 | FOITITIS elem; 10 | 11 | ST_init(&st); 12 | 13 | while(1) 14 | { 15 | system("cls"); 16 | printf("Menu Stoivas: "); 17 | printf("\n--------------"); 18 | printf("\n1-Othisi"); 19 | printf("\n2-Eksagogi"); 20 | printf("\n3-Ektypwsi"); 21 | printf("\n4-Eksodos"); 22 | printf("\nEpilogi? "); 23 | scanf("%d",&choice); 24 | 25 | switch(choice) 26 | { 27 | case 1: 28 | fflush(stdin); 29 | printf("\nDwse Onomateponimo: "); 30 | gets(elem.onoma); 31 | printf("\nDwse to vathmo: "); 32 | scanf("%d", &elem.vathmos); 33 | if (ST_push(&st,elem)) 34 | printf("Egine i othisi!"); 35 | else 36 | printf("Den egine i othisi! Gemati Stoiva!"); 37 | break; 38 | case 2: 39 | if (ST_pop(&st,&elem)) 40 | printf("Egine i eksagogi tou %s(%d)", elem.onoma,elem.vathmos); 41 | else 42 | printf("Den egine i eksagogi! Adeia Stoiva!"); 43 | break; 44 | case 3: 45 | //MONO GIA EKPAIDEYTIKOUS LOGOUS!!! 46 | //Apagorevetai na akoumpame ti domi!! 47 | printf("\n\nH stoiva exei %d stoixeia: \n", st.top+1); 48 | for (i=0; i<=st.top; i++) 49 | { 50 | printf("|%s(%d)",st.array[i].onoma, st.array[i].vathmos); 51 | } 52 | break; 53 | case 4: 54 | printf("Bye Bye!!"); 55 | exit(0); 56 | default: 57 | printf("Lathos eisodos!"); 58 | } 59 | printf("\n\n"); 60 | system("pause"); 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi2/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "queue.h" 4 | 5 | main() 6 | { 7 | int choice,i; 8 | elem x; 9 | 10 | QUEUE q; 11 | 12 | QU_init(&q); 13 | 14 | while(1) 15 | { 16 | system("cls"); 17 | printf("Menu Ouras: "); 18 | printf("\n--------------"); 19 | printf("\n1-Eisagwgi"); 20 | printf("\n2-Apomakrinsi"); 21 | printf("\n3-Ektypwsi"); 22 | printf("\n4-Eksodos"); 23 | printf("\nEpilogi? "); 24 | scanf("%d",&choice); 25 | 26 | switch(choice) 27 | { 28 | case 1: 29 | printf("\nDwse Stoixeio: "); 30 | scanf("%d",&x.data); 31 | printf("\nDwse Proteraiotita: "); 32 | scanf("%d",&x.priority); 33 | if (QU_enqueue(&q,x)) 34 | printf("Egine i eisagwgi!"); 35 | else 36 | printf("Den egine i eiasagwgi! Gemati Oura!"); 37 | break; 38 | case 2: 39 | if (QU_dequeue(&q,&x)) 40 | printf("Egine i apomakrinsi tou %d", x); 41 | else 42 | printf("Den egine i apomakrinsi! Adeia Oura!"); 43 | break; 44 | case 3: 45 | //MONO GIA EKPAIDEYTIKOUS LOGOUS!!! 46 | //Apagorevetai na akoumpame ti domi!! 47 | if (q.start!=-1) 48 | { 49 | i=q.start; 50 | while (1) 51 | { 52 | printf("|%3d(%d)",q.array[i].data,q.array[i].priority); 53 | if (i==q.finish) 54 | break; 55 | i=(i+1)%QUEUE_SIZE; 56 | } 57 | } 58 | break; 59 | case 4: 60 | printf("Bye Bye!!"); 61 | exit(0); 62 | default: 63 | printf("Lathos eisodos!"); 64 | } 65 | printf("\n\n"); 66 | system("pause"); 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/sequential_list/sequential_list.c: -------------------------------------------------------------------------------- 1 | /* linked_list.c: Kwdikas tis vivliothikis akolouthiakis listas */ 2 | #include 3 | #include "sequential_list.h" 4 | 5 | /* SL_init(): arxikopoiei tin lista */ 6 | void SL_init(LIST *l) 7 | { 8 | l->N=0; 9 | } 10 | 11 | /* SL_empty(): epistrefei TRUE/FALSE 12 | * analoga me to an i lista einai adeia */ 13 | int SL_empty(LIST l) 14 | { 15 | return l.N == 0; 16 | } 17 | 18 | /* SL_data(): epistrefei ta dedomena tou komvou 19 | tou index ind */ 20 | elem SL_data(LIST l, int ind) 21 | { 22 | return l.data[ind]; 23 | } 24 | 25 | /* SL_insert(): Eisagei to stoixeio x sti thesi ind */ 26 | int SL_insert(LIST *l, int ind, elem x) 27 | { 28 | int i; 29 | 30 | if (ind<0 || ind>l->N) 31 | return FALSE; 32 | 33 | if (l->N < SIZE) 34 | { 35 | for (i=l->N; i>ind; i--) 36 | l->data[i]=l->data[i-1]; 37 | 38 | l->data[ind]=x; 39 | l->N++; 40 | return TRUE; 41 | } 42 | else 43 | return FALSE; 44 | } 45 | 46 | /* SL_delete(): Diagrafei ta data pou vriskontai 47 | sti thesi ind */ 48 | int SL_delete(LIST *l, int ind, elem *x) 49 | { 50 | int i; 51 | 52 | if (ind<0 || ind>=l->N) 53 | return FALSE; 54 | 55 | *x = l->data[ind]; 56 | 57 | for (i=ind; iN; i++) 58 | l->data[i]=l->data[i+1]; 59 | 60 | l->N--; 61 | return TRUE; 62 | 63 | } 64 | 65 | /* SL_print(): Typwnei ta periexomena mias 66 | akolouthiakis listas */ 67 | 68 | void SL_print(LIST l) 69 | { 70 | int i; 71 | 72 | for (i=0; istart =-1; 10 | q->finish=-1; 11 | } 12 | 13 | /* QU_empty(): epistrefei TRUE/FALSE 14 | * analoga me to an i oura einai adeia */ 15 | int QU_empty(QUEUE q) 16 | { 17 | return q.start==-1; 18 | } 19 | 20 | /* QU_full(): epistrefei TRUE/FALSE 21 | * analoga me to an i oura einai gemati */ 22 | int QU_full(QUEUE q) 23 | { 24 | return q.start==(q.finish+1)%QUEUE_SIZE; 25 | } 26 | 27 | /* QU_enqueue(): Eisagei to x stin oura q 28 | * epistrefei TRUE: se periptwsi epitixias 29 | * FALSE: se periptwsi apotixias */ 30 | int QU_enqueue(QUEUE *q,elem x) 31 | { 32 | if (QU_full(*q)) 33 | return FALSE; 34 | else 35 | { 36 | if (QU_empty(*q)) 37 | { 38 | q->start=0; 39 | q->finish=0; 40 | } 41 | else 42 | { 43 | q->finish=(q->finish+1)%QUEUE_SIZE; 44 | } 45 | q->array[q->finish]=x; 46 | return TRUE; 47 | } 48 | } 49 | 50 | 51 | /* QU_dequeue(): Kanei apomakrinsi tou prwtou stoixeiou tis ouras 52 | * epistrefei TRUE: se periptwsi epitixias 53 | * FALSE: se periptwsi apotixias */ 54 | int QU_dequeue(QUEUE *q,elem *x) 55 | { 56 | if (QU_empty(*q)) 57 | return FALSE; 58 | else 59 | { 60 | *x=q->array[q->start]; 61 | 62 | if (q->start == q->finish) /* H oura adeiase */ 63 | { 64 | q->start=-1; 65 | q->finish=-1; 66 | } 67 | else 68 | { 69 | q->start=(q->start+1)%QUEUE_SIZE; 70 | } 71 | 72 | return TRUE; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi3/queue.c: -------------------------------------------------------------------------------- 1 | /* queue.c: Kwdikas tis vivliothikis ouras */ 2 | #include "queue.h" 3 | 4 | 5 | 6 | /* QU_init(): arxikopoiei tin oura */ 7 | void QU_init(QUEUE *q) 8 | { 9 | q->start =-1; 10 | q->finish=-1; 11 | } 12 | 13 | /* QU_empty(): epistrefei TRUE/FALSE 14 | * analoga me to an i oura einai adeia */ 15 | int QU_empty(QUEUE q) 16 | { 17 | return q.start==-1; 18 | } 19 | 20 | /* QU_full(): epistrefei TRUE/FALSE 21 | * analoga me to an i oura einai gemati */ 22 | int QU_full(QUEUE q) 23 | { 24 | return q.start==(q.finish+1)%QUEUE_SIZE; 25 | } 26 | 27 | /* QU_enqueue(): Eisagei to x stin oura q 28 | * epistrefei TRUE: se periptwsi epitixias 29 | * FALSE: se periptwsi apotixias */ 30 | int QU_enqueue(QUEUE *q,elem x) 31 | { 32 | if (QU_full(*q)) 33 | return FALSE; 34 | else 35 | { 36 | if (QU_empty(*q)) 37 | { 38 | q->start=0; 39 | q->finish=0; 40 | } 41 | else 42 | { 43 | q->finish=(q->finish+1)%QUEUE_SIZE; 44 | } 45 | q->array[q->finish]=x; 46 | return TRUE; 47 | } 48 | } 49 | 50 | 51 | /* QU_dequeue(): Kanei apomakrinsi tou prwtou stoixeiou tis ouras 52 | * epistrefei TRUE: se periptwsi epitixias 53 | * FALSE: se periptwsi apotixias */ 54 | int QU_dequeue(QUEUE *q,elem *x) 55 | { 56 | if (QU_empty(*q)) 57 | return FALSE; 58 | else 59 | { 60 | *x=q->array[q->start]; 61 | 62 | if (q->start == q->finish) /* H oura adeiase */ 63 | { 64 | q->start=-1; 65 | q->finish=-1; 66 | } 67 | else 68 | { 69 | q->start=(q->start+1)%QUEUE_SIZE; 70 | } 71 | 72 | return TRUE; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi4/queue.c: -------------------------------------------------------------------------------- 1 | /* queue.c: Kwdikas tis vivliothikis ouras */ 2 | #include "queue.h" 3 | 4 | 5 | 6 | /* QU_init(): arxikopoiei tin oura */ 7 | void QU_init(QUEUE *q) 8 | { 9 | q->start =-1; 10 | q->finish=-1; 11 | } 12 | 13 | /* QU_empty(): epistrefei TRUE/FALSE 14 | * analoga me to an i oura einai adeia */ 15 | int QU_empty(QUEUE q) 16 | { 17 | return q.start==-1; 18 | } 19 | 20 | /* QU_full(): epistrefei TRUE/FALSE 21 | * analoga me to an i oura einai gemati */ 22 | int QU_full(QUEUE q) 23 | { 24 | return q.start==(q.finish+1)%QUEUE_SIZE; 25 | } 26 | 27 | /* QU_enqueue(): Eisagei to x stin oura q 28 | * epistrefei TRUE: se periptwsi epitixias 29 | * FALSE: se periptwsi apotixias */ 30 | int QU_enqueue(QUEUE *q,elem x) 31 | { 32 | if (QU_full(*q)) 33 | return FALSE; 34 | else 35 | { 36 | if (QU_empty(*q)) 37 | { 38 | q->start=0; 39 | q->finish=0; 40 | } 41 | else 42 | { 43 | q->finish=(q->finish+1)%QUEUE_SIZE; 44 | } 45 | q->array[q->finish]=x; 46 | return TRUE; 47 | } 48 | } 49 | 50 | 51 | /* QU_dequeue(): Kanei apomakrinsi tou prwtou stoixeiou tis ouras 52 | * epistrefei TRUE: se periptwsi epitixias 53 | * FALSE: se periptwsi apotixias */ 54 | int QU_dequeue(QUEUE *q,elem *x) 55 | { 56 | if (QU_empty(*q)) 57 | return FALSE; 58 | else 59 | { 60 | *x=q->array[q->start]; 61 | 62 | if (q->start == q->finish) /* H oura adeiase */ 63 | { 64 | q->start=-1; 65 | q->finish=-1; 66 | } 67 | else 68 | { 69 | q->start=(q->start+1)%QUEUE_SIZE; 70 | } 71 | 72 | return TRUE; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /data_structures_3_queue/circular_queue/queue.c: -------------------------------------------------------------------------------- 1 | /* queue.c: Kwdikas tis vivliothikis ouras */ 2 | #include "queue.h" 3 | 4 | 5 | 6 | /* QU_init(): arxikopoiei tin oura */ 7 | void QU_init(QUEUE *q) 8 | { 9 | q->start =-1; 10 | q->finish=-1; 11 | } 12 | 13 | /* QU_empty(): epistrefei TRUE/FALSE 14 | * analoga me to an i oura einai adeia */ 15 | int QU_empty(QUEUE q) 16 | { 17 | return q.start==-1; 18 | } 19 | 20 | /* QU_full(): epistrefei TRUE/FALSE 21 | * analoga me to an i oura einai gemati */ 22 | int QU_full(QUEUE q) 23 | { 24 | return q.start==(q.finish+1)%QUEUE_SIZE; 25 | } 26 | 27 | /* QU_enqueue(): Eisagei to x stin oura q 28 | * epistrefei TRUE: se periptwsi epitixias 29 | * FALSE: se periptwsi apotixias */ 30 | int QU_enqueue(QUEUE *q,elem x) 31 | { 32 | if (QU_full(*q)) 33 | return FALSE; 34 | else 35 | { 36 | if (QU_empty(*q)) 37 | { 38 | q->start=0; 39 | q->finish=0; 40 | } 41 | else 42 | { 43 | q->finish=(q->finish+1)%QUEUE_SIZE; 44 | } 45 | q->array[q->finish]=x; 46 | return TRUE; 47 | } 48 | } 49 | 50 | 51 | /* QU_dequeue(): Kanei apomakrinsi tou prwtou stoixeiou tis ouras 52 | * epistrefei TRUE: se periptwsi epitixias 53 | * FALSE: se periptwsi apotixias */ 54 | int QU_dequeue(QUEUE *q,elem *x) 55 | { 56 | if (QU_empty(*q)) 57 | return FALSE; 58 | else 59 | { 60 | *x=q->array[q->start]; 61 | 62 | if (q->start == q->finish) /* H oura adeiase */ 63 | { 64 | q->start=-1; 65 | q->finish=-1; 66 | } 67 | else 68 | { 69 | q->start=(q->start+1)%QUEUE_SIZE; 70 | } 71 | 72 | return TRUE; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi3/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "queue.h" 4 | 5 | void QU_print(QUEUE *q); 6 | 7 | main() 8 | { 9 | int choice,elem,i; 10 | QUEUE q; 11 | 12 | QU_init(&q); 13 | 14 | while(1) 15 | { 16 | system("cls"); 17 | printf("Menu Ouras: "); 18 | printf("\n--------------"); 19 | printf("\n1-Eisagwgi"); 20 | printf("\n2-Apomakrinsi"); 21 | printf("\n3-Ektypwsi"); 22 | printf("\n4-Eksodos"); 23 | printf("\nEpilogi? "); 24 | scanf("%d",&choice); 25 | 26 | switch(choice) 27 | { 28 | case 1: 29 | printf("\nDwse Stoixeio: "); 30 | scanf("%d",&elem); 31 | if (QU_enqueue(&q,elem)) 32 | printf("Egine i eisagwgi!"); 33 | else 34 | printf("Den egine i eiasagwgi! Gemati Oura!"); 35 | break; 36 | case 2: 37 | if (QU_dequeue(&q,&elem)) 38 | printf("Egine i apomakrinsi tou %d", elem); 39 | else 40 | printf("Den egine i apomakrinsi! Adeia Oura!"); 41 | break; 42 | case 3: 43 | QU_print(&q); 44 | break; 45 | case 4: 46 | printf("Bye Bye!!"); 47 | exit(0); 48 | default: 49 | printf("Lathos eisodos!"); 50 | } 51 | printf("\n\n"); 52 | system("pause"); 53 | } 54 | } 55 | 56 | void QU_print(QUEUE *q) 57 | { 58 | QUEUE temp; 59 | int x; 60 | 61 | /* 1. Ektypwsi twn stoixeiwn tis ouras */ 62 | QU_init(&temp); 63 | 64 | while(!QU_empty(*q)) 65 | { 66 | QU_dequeue(q,&x); 67 | printf("%3d|",x); 68 | QU_enqueue(&temp,x); 69 | } 70 | 71 | /* 2. Ksanagemisma tis ouras q */ 72 | 73 | while (!QU_empty(temp)) 74 | { 75 | QU_dequeue(&temp,&x); 76 | QU_enqueue(q,x); 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/linked_list/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "linked_list.h" 4 | 5 | main() 6 | { 7 | int elem; 8 | LIST_PTR head,prev,current; 9 | 10 | LL_init(&head); 11 | 12 | /* Eisagwgi tou "1" */ 13 | LL_insert_start(&head, 1); 14 | 15 | printf("\n"); 16 | LL_print(head); 17 | 18 | /* Eisagwgi tou "2" stin arxi */ 19 | LL_insert_start(&head, 2); 20 | 21 | printf("\n"); 22 | LL_print(head); 23 | 24 | /* Eisagwgi tou "3" meta to 1o stoixeio */ 25 | LL_insert_after(head, 3); 26 | 27 | printf("\n"); 28 | LL_print(head); 29 | 30 | /* Eisagwgi tou "4" meta to 2o stoixeio */ 31 | LL_insert_after(head->next, 4); 32 | 33 | printf("\n"); 34 | LL_print(head); 35 | 36 | /* Eisagwgi tou "5" stin arxi */ 37 | LL_insert_start(&head, 5); 38 | 39 | printf("\n"); 40 | LL_print(head); 41 | 42 | /* Eisagwgi tou "6" stin arxi */ 43 | LL_insert_start(&head, 6); 44 | 45 | printf("\n"); 46 | LL_print(head); 47 | 48 | /* Eisagwgi tou "7" sto telos */ 49 | current=head; 50 | prev=current; 51 | while(current->next!=NULL) 52 | { 53 | prev=current; 54 | current=current->next; 55 | } 56 | LL_insert_after(prev, 7); 57 | 58 | printf("\n"); 59 | LL_print(head); 60 | 61 | /* Diagrafi tou 1ou stoixeiou */ 62 | LL_delete_start(&head,&elem); 63 | 64 | printf("\n"); 65 | LL_print(head); 66 | 67 | /* Diagrafi tou teleytaiou stoixeiou */ 68 | current=head; 69 | while(current->next!=NULL) 70 | { 71 | prev=current; 72 | current=current->next; 73 | } 74 | LL_delete_after(prev,&elem); 75 | 76 | printf("\n"); 77 | LL_print(head); 78 | 79 | LL_destroy(&head); 80 | } 81 | 82 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/doubly_linked_list/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "doubly_linked_list.h" 4 | 5 | main() 6 | { 7 | int elem; 8 | LIST_PTR head,prev,current; 9 | 10 | DLL_init(&head); 11 | 12 | /* Eisagwgi tou "1" */ 13 | DLL_insert_start(&head, 1); 14 | 15 | printf("\n"); 16 | DLL_print(head); 17 | 18 | /* Eisagwgi tou "2" stin arxi */ 19 | DLL_insert_start(&head, 2); 20 | 21 | printf("\n"); 22 | DLL_print(head); 23 | 24 | /* Eisagwgi tou "3" meta to 1o stoixeio */ 25 | DLL_insert_after(head, 3); 26 | 27 | printf("\n"); 28 | DLL_print(head); 29 | 30 | /* Eisagwgi tou "4" meta to 2o stoixeio */ 31 | DLL_insert_after(head->next, 4); 32 | 33 | printf("\n"); 34 | DLL_print(head); 35 | 36 | /* Eisagwgi tou "5" stin arxi */ 37 | DLL_insert_start(&head, 5); 38 | 39 | printf("\n"); 40 | DLL_print(head); 41 | 42 | /* Eisagwgi tou "6" stin arxi */ 43 | DLL_insert_start(&head, 6); 44 | 45 | printf("\n"); 46 | DLL_print(head); 47 | 48 | /* Eisagwgi tou "7" sto telos */ 49 | current=head; 50 | prev=current; 51 | while(current->next!=NULL) 52 | { 53 | prev=current; 54 | current=current->next; 55 | } 56 | DLL_insert_after(prev, 7); 57 | 58 | printf("\n"); 59 | DLL_print(head); 60 | 61 | /* Diagrafi tou 1ou stoixeiou */ 62 | DLL_delete_start(&head,&elem); 63 | 64 | printf("\n"); 65 | DLL_print(head); 66 | 67 | /* Diagrafi tou teleytaiou stoixeiou */ 68 | current=head; 69 | while(current->next!=NULL) 70 | { 71 | prev=current; 72 | current=current->next; 73 | } 74 | DLL_delete_after(prev,&elem); 75 | 76 | printf("\n"); 77 | DLL_print(head); 78 | 79 | DLL_destroy(&head); 80 | } 81 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/askisi1/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "linked_list.h" 5 | 6 | main() 7 | { 8 | elem student; 9 | LIST_PTR list; 10 | int choice; 11 | 12 | LL_init(&list); 13 | 14 | while(1) 15 | { 16 | printf("MENU\n"); 17 | printf("====\n"); 18 | printf("1-eisagogi\n"); 19 | printf("2-diagrafi\n"); 20 | printf("3-ektipwsi\n"); 21 | printf("4-mesos oros\n"); 22 | printf("5-perasan\n"); 23 | printf("6-eksodos\n"); 24 | printf("Epilogi? "); 25 | scanf("%d", &choice); 26 | getchar(); 27 | 28 | switch(choice) 29 | { 30 | case 1: 31 | printf("Dwse onoma: "); 32 | fgets(student.name, 80, stdin); 33 | student.name[strlen(student.name)-1]='\0'; 34 | printf("Dwse vathmo: "); 35 | scanf("%d", &student.grade); 36 | 37 | LL_insert(&list, student); 38 | printf("H eisagogi egine\n\n"); 39 | 40 | break; 41 | case 2: 42 | printf("Dwse onoma: "); 43 | fgets(student.name, 80, stdin); 44 | student.name[strlen(student.name)-1]='\0'; 45 | 46 | if (LL_delete(&list,student.name)) 47 | { 48 | printf("H diagrafi egine!\n\n"); 49 | } 50 | else 51 | { 52 | printf("O foititis den vrethike\n\n"); 53 | } 54 | 55 | break; 56 | case 3: 57 | 58 | LL_print(list); 59 | printf("\n\n"); 60 | 61 | break; 62 | case 4: 63 | printf("O mesos oros einai: %.2lf\n\n", LL_average(list)); 64 | break; 65 | case 5: 66 | printf("To plithos epitixontwn einai: %d\n\n", LL_pass(list)); 67 | break; 68 | case 6: 69 | printf("Bye bye!"); 70 | LL_destroy(&list); 71 | exit(0); 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /data_structures_7_binary_search_trees/tree/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "tree.h" 4 | 5 | main() 6 | { 7 | int choice,i; 8 | int data; 9 | TREE_PTR root; 10 | 11 | TR_init(&root); 12 | TR_insert_BST(&root,10); 13 | TR_insert_BST(&root,6); 14 | TR_insert_BST(&root,14); 15 | TR_insert_BST(&root,5); 16 | TR_insert_BST(&root,7); 17 | TR_insert_BST(&root,19); 18 | TR_insert_BST(&root,2); 19 | TR_insert_BST(&root,8); 20 | TR_insert_BST(&root,3); 21 | 22 | while(1) 23 | { 24 | system("cls"); 25 | printf("Menu DDA: "); 26 | printf("\n--------------"); 27 | printf("\n1-Eisagwgi"); 28 | printf("\n2-Diagrafi"); 29 | printf("\n3-Ektypwsi"); 30 | printf("\n4-Eksodos"); 31 | printf("\nEpilogi? "); 32 | scanf("%d",&choice); 33 | 34 | switch(choice) 35 | { 36 | case 1: 37 | printf("\nDwse Stoixeio: "); 38 | scanf("%d",&data); 39 | if (TR_insert_BST(&root,data)) 40 | printf("Egine i eisagwgi!"); 41 | else 42 | printf("Den egine i eisagwgi! To stoixeio yparxei idi!"); 43 | break; 44 | case 2: 45 | printf("\nDwse Stoixeio: "); 46 | scanf("%d",&data); 47 | if (TR_delete_BST(&root,data)) 48 | printf("Egine i apomakrinsi tou %d", data); 49 | else 50 | printf("Den egine i diagrafi. To stoixeio den yparxei!"); 51 | break; 52 | case 3: 53 | printf("\n INORDER: "); 54 | TR_inorder(root); 55 | printf("\n PREORDER: "); 56 | TR_preorder(root); 57 | printf("\n POSTORDER: "); 58 | TR_postorder(root); 59 | break; 60 | case 4: 61 | printf("Bye Bye!!"); 62 | exit(0); 63 | default: 64 | printf("Lathos eisodos!"); 65 | } 66 | printf("\n\n"); 67 | system("pause"); 68 | } 69 | 70 | } 71 | 72 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi4/circular.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=circular.dev 3 | Name=queue 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=3 31 | CompilerSettings= 32 | UnitCount=5 33 | 34 | [VersionInfo] 35 | Major=1 36 | Minor=0 37 | Release=0 38 | Build=0 39 | LanguageID=1033 40 | CharsetID=1252 41 | CompanyName= 42 | FileVersion= 43 | FileDescription=Developed using the Dev-C++ IDE 44 | InternalName= 45 | LegalCopyright= 46 | LegalTrademarks= 47 | OriginalFilename= 48 | ProductName= 49 | ProductVersion= 50 | AutoIncBuildNr=0 51 | SyncProduct=1 52 | 53 | [Unit1] 54 | FileName=main.c 55 | CompileCpp=0 56 | Folder=queue 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit2] 64 | FileName=queue.c 65 | CompileCpp=0 66 | Folder=queue 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit3] 74 | FileName=queue.h 75 | CompileCpp=0 76 | Folder=queue 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | [Unit4] 84 | FileName=stack.c 85 | CompileCpp=0 86 | Folder=queue 87 | Compile=1 88 | Link=1 89 | Priority=1000 90 | OverrideBuildCmd=0 91 | BuildCmd= 92 | 93 | [Unit5] 94 | FileName=stack.h 95 | CompileCpp=0 96 | Folder=queue 97 | Compile=1 98 | Link=1 99 | Priority=1000 100 | OverrideBuildCmd=0 101 | BuildCmd= 102 | 103 | -------------------------------------------------------------------------------- /data_structures_8_heaps/tree/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "heap.h" 4 | 5 | #define SIZE 100 6 | 7 | main() 8 | { 9 | int choice,i,j; 10 | int data; 11 | int array[SIZE],N; 12 | HEAP heap,heapsort_heap; 13 | 14 | HEAP_init(&heap); 15 | 16 | while(1) 17 | { 18 | system("cls"); 19 | printf("Menu Heap: "); 20 | printf("\n--------------"); 21 | printf("\n1-Eisagwgi"); 22 | printf("\n2-Diagrafi"); 23 | printf("\n3-Ektypwsi"); 24 | printf("\n4-HeapSort!"); 25 | printf("\n5-Eksodos"); 26 | printf("\nEpilogi? "); 27 | scanf("%d",&choice); 28 | 29 | switch(choice) 30 | { 31 | case 1: 32 | printf("\nDwse Stoixeio: "); 33 | scanf("%d",&data); 34 | if (HEAP_insert(&heap,data)) 35 | printf("Egine i eisagwgi!"); 36 | else 37 | printf("Den egine i eisagwgi! O swros gemise!"); 38 | break; 39 | case 2: 40 | if (HEAP_delete(&heap,&data)) 41 | printf("Egine i apomakrinsi tou %d", data); 42 | else 43 | printf("Den egine i diagrafi. O swros einai adeios!"); 44 | break; 45 | case 3: 46 | for (i=0; i 3 | #include 4 | #include "graph.h" 5 | #include "linked_list.h" 6 | 7 | /* GR_init(): arxikopoiei to grafo */ 8 | void GR_init(GRAPH *g, int N) 9 | { 10 | int i; 11 | g->N = N; 12 | 13 | g->array = (LIST_PTR *)malloc(sizeof(LIST_PTR)*N); 14 | if(!g->array) 15 | { 16 | printf("Error Allocating Memory"); 17 | exit(0); 18 | } 19 | for (i=0; iarray[i])); 21 | 22 | } 23 | 24 | /* GR_print(): ektypwnei to grafo */ 25 | void GR_print(GRAPH g) 26 | { 27 | int i; 28 | 29 | for (i=0; ig.N || vertex2<0 || vertex2>g.N) 41 | { 42 | printf("Error: index out of bounds"); 43 | exit(0); 44 | } 45 | 46 | LL_insert(&g.array[vertex1], vertex2); 47 | LL_insert(&g.array[vertex2], vertex1); 48 | } 49 | 50 | 51 | void GR_destroy(GRAPH g) 52 | { 53 | int i; 54 | 55 | for (i=0; iN); 77 | 78 | g->array = (LIST_PTR *)malloc(sizeof(LIST_PTR)*g->N); 79 | if(!g->array) 80 | { 81 | printf("Error Allocating Memory"); 82 | exit(0); 83 | } 84 | 85 | for (i=0; iN; i++) 86 | LL_init(&(g->array[i])); 87 | 88 | while(!feof(fp)) 89 | { 90 | fscanf(fp,"%d %d", &i, &j); 91 | GR_add_edge(*g, i, j); 92 | } 93 | 94 | fclose(fp); 95 | } 96 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise4/graph.c: -------------------------------------------------------------------------------- 1 | /* graph.c: Kwdikas tis vivliothikis grafoy (pin.geitniasis) */ 2 | #include 3 | #include 4 | #include "graph.h" 5 | #include "linked_list.h" 6 | 7 | /* GR_init(): arxikopoiei to grafo */ 8 | void GR_init(GRAPH *g, int N) 9 | { 10 | int i; 11 | g->N = N; 12 | 13 | g->array = (LIST_PTR *)malloc(sizeof(LIST_PTR)*N); 14 | if(!g->array) 15 | { 16 | printf("Error Allocating Memory"); 17 | exit(0); 18 | } 19 | for (i=0; iarray[i])); 21 | 22 | } 23 | 24 | /* GR_print(): ektypwnei to grafo */ 25 | void GR_print(GRAPH g) 26 | { 27 | int i; 28 | 29 | for (i=0; ig.N || vertex2<0 || vertex2>g.N) 41 | { 42 | printf("Error: index out of bounds"); 43 | exit(0); 44 | } 45 | 46 | LL_insert(&g.array[vertex1], vertex2, weight); 47 | LL_insert(&g.array[vertex2], vertex1, weight); 48 | } 49 | 50 | 51 | void GR_destroy(GRAPH g) 52 | { 53 | int i; 54 | 55 | for (i=0; iN); 77 | 78 | g->array = (LIST_PTR *)malloc(sizeof(LIST_PTR)*g->N); 79 | if(!g->array) 80 | { 81 | printf("Error Allocating Memory"); 82 | exit(0); 83 | } 84 | 85 | for (i=0; iN; i++) 86 | LL_init(&(g->array[i])); 87 | 88 | while(!feof(fp)) 89 | { 90 | fscanf(fp,"%d %d %d", &i, &j, &w); 91 | GR_add_edge(*g, i, j, w); 92 | } 93 | 94 | fclose(fp); 95 | } 96 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise3/graph.c: -------------------------------------------------------------------------------- 1 | /* graph.c: Kwdikas tis vivliothikis grafoy (pin.geitniasis) */ 2 | #include 3 | #include 4 | #include "graph.h" 5 | #include "linked_list.h" 6 | 7 | /* GR_init(): arxikopoiei to grafo */ 8 | void GR_init(GRAPH *g, int N) 9 | { 10 | int i; 11 | g->N = N; 12 | 13 | g->array = (LIST_PTR *)malloc(sizeof(LIST_PTR)*N); 14 | if(!g->array) 15 | { 16 | printf("Error Allocating Memory"); 17 | exit(0); 18 | } 19 | for (i=0; iarray[i])); 21 | 22 | } 23 | 24 | /* GR_print(): ektypwnei to grafo */ 25 | void GR_print(GRAPH g) 26 | { 27 | int i; 28 | 29 | for (i=0; ig.N || vertex2<0 || vertex2>g.N) 41 | { 42 | printf("Error: index out of bounds"); 43 | exit(0); 44 | } 45 | 46 | LL_insert(&g.array[vertex1], vertex2); 47 | LL_insert(&g.array[vertex2], vertex1); 48 | } 49 | 50 | 51 | void GR_destroy(GRAPH g) 52 | { 53 | int i; 54 | 55 | for (i=0; iN); 77 | 78 | g->array = (LIST_PTR *)malloc(sizeof(LIST_PTR)*g->N); 79 | if(!g->array) 80 | { 81 | printf("Error Allocating Memory"); 82 | exit(0); 83 | } 84 | 85 | for (i=0; iN; i++) 86 | LL_init(&(g->array[i])); 87 | 88 | while(!feof(fp)) 89 | { 90 | fscanf(fp,"%d %d", &i, &j); 91 | GR_add_edge(*g, i, j); 92 | } 93 | 94 | fclose(fp); 95 | } 96 | 97 | void GR_neighbors(GRAPH g, int vertex, int *length, int **elements) 98 | { 99 | LL_to_array(g.array[vertex], length, elements); 100 | } 101 | -------------------------------------------------------------------------------- /data_structures_10_graph/GraphIncidenceMatrix/graph.c: -------------------------------------------------------------------------------- 1 | /* graph.c: Kwdikas tis vivliothikis grafoy (pin.geitniasis) */ 2 | #include 3 | #include 4 | #include "graph.h" 5 | 6 | /* GR_init(): arxikopoiei to grafo */ 7 | void GR_init(GRAPH *g, int N, int M) 8 | { 9 | int i,j; 10 | g->N = N; 11 | g->M = M; 12 | g->array = (int **)malloc(sizeof(int*)*N); 13 | if(!g->array) 14 | { 15 | printf("Error Allocating Memory"); 16 | exit(0); 17 | } 18 | for (i=0; iarray[i] = (int *)malloc(sizeof(int)*M); 21 | if (!g->array[i]) 22 | { 23 | printf("Error Allocating Memory"); 24 | exit(0); 25 | } 26 | for (j=0; jarray[i][j] = 0; 28 | } 29 | } 30 | 31 | /* GR_print(): ektypwnei to grafo */ 32 | void GR_print(GRAPH g) 33 | { 34 | int i,j; 35 | 36 | printf(" "); 37 | for (i=0; iN, &g->M); 72 | 73 | g->array = (int **)malloc(sizeof(int*)*g->N); 74 | if(!g->array) 75 | { 76 | printf("Error Allocating Memory"); 77 | exit(0); 78 | } 79 | 80 | for (i=0; iN; i++) 81 | { 82 | g->array[i] = (int *)malloc(sizeof(int)*g->M); 83 | if (!g->array[i]) 84 | { 85 | printf("Error Allocating Memory"); 86 | exit(0); 87 | } 88 | for (j=0; jM; j++) 89 | g->array[i][j] = 0; 90 | } 91 | 92 | k=0; 93 | while(!feof(fp)) 94 | { 95 | fscanf(fp,"%d %d", &i, &j); 96 | g->array[i][k] = 1; 97 | g->array[j][k] = 1; 98 | k++; 99 | } 100 | 101 | fclose(fp); 102 | } 103 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/DisjointSets(ReverseTrees)/disjoint_sets.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "disjoint_sets.h" 4 | 5 | /* Basikes Prakseis */ 6 | void DS_init(DISJOINT *d, int N) 7 | { 8 | int i; 9 | 10 | d->N = N; 11 | 12 | d->array = (DISJOINT_PTR *)malloc(sizeof(DISJOINT_PTR)*N); 13 | if (!d->array) 14 | { 15 | printf("Error allocating memory!"); 16 | exit(0); 17 | } 18 | 19 | for (i=0; iarray[x] = (DISJOINT_NODE *)malloc(sizeof(DISJOINT_NODE)); 27 | if (!d->array[x]) 28 | { 29 | printf("Error allocating memory!"); 30 | exit(0); 31 | } 32 | d->array[x]->data = x; 33 | d->array[x]->height = 0; 34 | d->array[x]->parent = d->array[x]; 35 | } 36 | 37 | int DS_union(DISJOINT *d, elem x, elem y) 38 | { 39 | int p1, p2; 40 | 41 | p1 = DS_find_set(*d, x); 42 | p2 = DS_find_set(*d, y); 43 | 44 | if (p1==p2) 45 | { 46 | printf("Elements %d and %d are in the same set(%d)", x, y, p1); 47 | return FALSE; 48 | } 49 | 50 | if (d->array[p1]->height < d->array[p2]->height) 51 | d->array[p1]->parent = d->array[p2]; 52 | else if (d->array[p1]->height > d->array[p2]->height) 53 | d->array[p2]->parent = d->array[p1]; 54 | else 55 | { 56 | d->array[p2]->parent = d->array[p1]; 57 | (d->array[p1]->height)++; 58 | } 59 | 60 | return TRUE; 61 | } 62 | 63 | elem DS_find_set(DISJOINT d, elem x) 64 | { 65 | int p; 66 | if (d.array[x]->parent == d.array[x]) 67 | return x; 68 | else 69 | { 70 | p = DS_find_set(d, d.array[x]->parent->data); 71 | d.array[x]->parent=d.array[p]; 72 | return p; 73 | } 74 | } 75 | 76 | void DS_destroy(DISJOINT *d) 77 | { 78 | int i; 79 | 80 | for (i=0; iN; i++) 81 | { 82 | free(d->array[i]); 83 | } 84 | 85 | free(d->array); 86 | } 87 | 88 | /* Deutereouses Prakseis */ 89 | void DS_print(DISJOINT d) 90 | { 91 | int i; 92 | 93 | for (i=0; i%d (set: %d)\n", i, d.array[i]->parent->data, DS_find_set(d,i)); 96 | } 97 | } 98 | 99 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise01/graph.c: -------------------------------------------------------------------------------- 1 | /* graph.c: Kwdikas tis vivliothikis grafoy (pin.geitniasis) */ 2 | #include 3 | #include 4 | #include "graph.h" 5 | #include "linked_list.h" 6 | 7 | /* GR_init(): arxikopoiei to grafo */ 8 | void GR_init(GRAPH *g, int N) 9 | { 10 | int i; 11 | g->N = N; 12 | 13 | g->array = (LIST_PTR *)malloc(sizeof(LIST_PTR)*N); 14 | if(!g->array) 15 | { 16 | printf("Error Allocating Memory"); 17 | exit(0); 18 | } 19 | for (i=0; iarray[i])); 21 | 22 | } 23 | 24 | /* GR_print(): ektypwnei to grafo */ 25 | void GR_print(GRAPH g) 26 | { 27 | int i; 28 | 29 | for (i=0; ig.N || vertex2<0 || vertex2>g.N) 41 | { 42 | printf("Error: index out of bounds"); 43 | exit(0); 44 | } 45 | 46 | LL_insert(&g.array[vertex1], vertex2); 47 | LL_insert(&g.array[vertex2], vertex1); 48 | } 49 | 50 | 51 | void GR_destroy(GRAPH g) 52 | { 53 | int i; 54 | 55 | for (i=0; iN); 77 | 78 | g->array = (LIST_PTR *)malloc(sizeof(LIST_PTR)*g->N); 79 | if(!g->array) 80 | { 81 | printf("Error Allocating Memory"); 82 | exit(0); 83 | } 84 | 85 | for (i=0; iN; i++) 86 | LL_init(&(g->array[i])); 87 | 88 | while(!feof(fp)) 89 | { 90 | fscanf(fp,"%d %d", &i, &j); 91 | GR_add_edge(*g, i, j); 92 | } 93 | 94 | fclose(fp); 95 | } 96 | 97 | int GR_vertices_count(GRAPH g) 98 | { 99 | return g.N; 100 | } 101 | 102 | void GR_neighbors(GRAPH g, int vertex, int *length, elem **elements) 103 | { 104 | LL_to_array(g.array[vertex], length, elements); 105 | } 106 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi4/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "queue.h" 4 | #include "stack.h" 5 | 6 | void QU_print(QUEUE *q); 7 | void QU_reverse(QUEUE *q); 8 | 9 | main() 10 | { 11 | int choice,elem,i; 12 | QUEUE q; 13 | 14 | QU_init(&q); 15 | 16 | while(1) 17 | { 18 | system("cls"); 19 | printf("Menu Ouras: "); 20 | printf("\n--------------"); 21 | printf("\n1-Eisagwgi"); 22 | printf("\n2-Apomakrinsi"); 23 | printf("\n3-Ektypwsi"); 24 | printf("\n4-Antistrofi ouras"); 25 | printf("\n5-Eksodos"); 26 | printf("\nEpilogi? "); 27 | scanf("%d",&choice); 28 | 29 | switch(choice) 30 | { 31 | case 1: 32 | printf("\nDwse Stoixeio: "); 33 | scanf("%d",&elem); 34 | if (QU_enqueue(&q,elem)) 35 | printf("Egine i eisagwgi!"); 36 | else 37 | printf("Den egine i eiasagwgi! Gemati Oura!"); 38 | break; 39 | case 2: 40 | if (QU_dequeue(&q,&elem)) 41 | printf("Egine i apomakrinsi tou %d", elem); 42 | else 43 | printf("Den egine i apomakrinsi! Adeia Oura!"); 44 | break; 45 | case 3: 46 | QU_print(&q); 47 | break; 48 | case 4: 49 | QU_reverse(&q); 50 | break; 51 | case 5: 52 | printf("Bye Bye!!"); 53 | exit(0); 54 | default: 55 | printf("Lathos eisodos!"); 56 | } 57 | printf("\n\n"); 58 | system("pause"); 59 | } 60 | } 61 | 62 | void QU_print(QUEUE *q) 63 | { 64 | QUEUE temp; 65 | int x; 66 | 67 | /* 1. Ektypwsi twn stoixeiwn tis ouras */ 68 | QU_init(&temp); 69 | 70 | while(!QU_empty(*q)) 71 | { 72 | QU_dequeue(q,&x); 73 | printf("%3d|",x); 74 | QU_enqueue(&temp,x); 75 | } 76 | 77 | /* 2. Ksanagemisma tis ouras q */ 78 | 79 | while (!QU_empty(temp)) 80 | { 81 | QU_dequeue(&temp,&x); 82 | QU_enqueue(q,x); 83 | } 84 | } 85 | 86 | void QU_reverse(QUEUE *q) 87 | { 88 | STACK temp; 89 | int x; 90 | 91 | /* 1. Adeiasma tis ouras => gemisma tis stoivas */ 92 | 93 | ST_init(&temp); 94 | 95 | while (!QU_empty(*q)) 96 | { 97 | QU_dequeue(q,&x); 98 | ST_push(&temp,x); 99 | } 100 | 101 | /* 2. Adeiasma tis stoivas => gemisma tis ouras */ 102 | 103 | while (!ST_empty(temp)) 104 | { 105 | ST_pop (&temp,&x); 106 | QU_enqueue(q,x); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi1/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "queue.h" 4 | 5 | #define N 80 6 | 7 | main() 8 | { 9 | int choice,i; 10 | QUEUE tameio1,tameio2; 11 | char *pelatis; 12 | 13 | 14 | QU_init(&tameio1); 15 | QU_init(&tameio2); 16 | 17 | while(1) 18 | { 19 | system("cls"); 20 | printf("Menu Trapezas: "); 21 | printf("\n--------------"); 22 | printf("\n1-Afiksi Pelati"); 23 | printf("\n2-Anaxwrisi Pelati"); 24 | printf("\n3-Eksodos"); 25 | printf("\nEpilogi? "); 26 | scanf("%d",&choice); 27 | 28 | switch(choice) 29 | { 30 | case 1: 31 | printf("\nDwse Onomatepwnimo Pelati: "); 32 | 33 | pelatis=malloc(sizeof(char)*N); 34 | if (!pelatis) 35 | { 36 | printf("Adynamia desmeysis mnimis"); 37 | exit(0); 38 | } 39 | scanf("%s",pelatis); 40 | 41 | if (QU_enqueue(&tameio1,pelatis)) 42 | { 43 | printf("Egine i eisagwgi tou %s sto 1o tameio: ", pelatis); 44 | } 45 | else 46 | { 47 | if (QU_enqueue(&tameio2,pelatis)) 48 | { 49 | printf("Egine i eisagwgi tou %s sto 2o tameio: ", pelatis); 50 | } 51 | else 52 | printf("Ta tameia einai gemata. O %s apoxwrei",pelatis); 53 | } 54 | break; 55 | case 2: 56 | 57 | if (!QU_empty(tameio1) && !QU_empty(tameio2)) 58 | { 59 | if (1+rand()%2==1) 60 | { 61 | QU_dequeue(&tameio1,&pelatis); 62 | printf("O pelatis %s eksipiretithike apo to tameio 1", pelatis); 63 | } 64 | else 65 | { 66 | QU_dequeue(&tameio2,&pelatis); 67 | printf("O pelatis %s eksipiretithike apo to tameio 2", pelatis); 68 | } 69 | free(pelatis); 70 | } 71 | else if (!QU_empty(tameio1)) 72 | { 73 | QU_dequeue(&tameio1,&pelatis); 74 | printf("O pelatis %s eksipiretithike apo to tameio 1", pelatis); 75 | free(pelatis); 76 | } 77 | else if (!QU_empty(tameio2)) 78 | { 79 | QU_dequeue(&tameio2,&pelatis); 80 | printf("O pelatis %s eksipiretithike apo to tameio 2", pelatis); 81 | free(pelatis); 82 | } 83 | else 84 | { 85 | printf("Ta dyo tameia einai adeia!!"); 86 | } 87 | break; 88 | case 3: 89 | printf("Bye Bye!!"); 90 | exit(0); 91 | default: 92 | printf("Lathos eisodos!"); 93 | } 94 | printf("\n\n"); 95 | system("pause"); 96 | } 97 | } 98 | 99 | -------------------------------------------------------------------------------- /data_structures_3_queue/efarmogi2/queue.c: -------------------------------------------------------------------------------- 1 | /* queue.c: Kwdikas tis vivliothikis ouras */ 2 | #include "queue.h" 3 | 4 | 5 | 6 | /* QU_init(): arxikopoiei tin oura */ 7 | void QU_init(QUEUE *q) 8 | { 9 | q->start =-1; 10 | q->finish=-1; 11 | } 12 | 13 | /* QU_empty(): epistrefei TRUE/FALSE 14 | * analoga me to an i oura einai adeia */ 15 | int QU_empty(QUEUE q) 16 | { 17 | return q.start==-1; 18 | } 19 | 20 | /* QU_full(): epistrefei TRUE/FALSE 21 | * analoga me to an i oura einai gemati */ 22 | int QU_full(QUEUE q) 23 | { 24 | return q.start==(q.finish+1)%QUEUE_SIZE; 25 | } 26 | 27 | /* QU_enqueue(): Eisagei to x stin oura q 28 | * epistrefei TRUE: se periptwsi epitixias 29 | * FALSE: se periptwsi apotixias */ 30 | int QU_enqueue(QUEUE *q,elem x) 31 | { 32 | int i; 33 | elem temp; 34 | 35 | if (QU_full(*q)) 36 | return FALSE; 37 | else 38 | { 39 | if (QU_empty(*q)) 40 | { 41 | q->start=0; 42 | q->finish=0; 43 | } 44 | else 45 | { 46 | q->finish=(q->finish+1)%QUEUE_SIZE; 47 | } 48 | q->array[q->finish]=x; 49 | 50 | 51 | i=q->finish; 52 | 53 | while(i!=q->start) 54 | { 55 | if (i>0) 56 | { 57 | if (q->array[i-1].priority < q->array[i].priority) 58 | { 59 | temp=q->array[i-1]; 60 | q->array[i-1]=q->array[i]; 61 | q->array[i]=temp; 62 | i--; 63 | } 64 | else 65 | break; 66 | } 67 | else //i==0 68 | { 69 | if (q->array[QUEUE_SIZE-1].priority < q->array[i].priority) 70 | { 71 | temp=q->array[QUEUE_SIZE-1]; 72 | q->array[QUEUE_SIZE-1]=q->array[i]; 73 | q->array[i]=temp; 74 | i=QUEUE_SIZE-1; 75 | } 76 | else 77 | break; 78 | } 79 | } 80 | 81 | return TRUE; 82 | } 83 | } 84 | 85 | 86 | /* QU_dequeue(): Kanei apomakrinsi tou prwtou stoixeiou tis ouras 87 | * epistrefei TRUE: se periptwsi epitixias 88 | * FALSE: se periptwsi apotixias */ 89 | int QU_dequeue(QUEUE *q,elem *x) 90 | { 91 | if (QU_empty(*q)) 92 | return FALSE; 93 | else 94 | { 95 | *x=q->array[q->start]; 96 | 97 | if (q->start == q->finish) /* H oura adeiase */ 98 | { 99 | q->start=-1; 100 | q->finish=-1; 101 | } 102 | else 103 | { 104 | q->start=(q->start+1)%QUEUE_SIZE; 105 | } 106 | 107 | return TRUE; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise1.1/graph.c: -------------------------------------------------------------------------------- 1 | /* graph.c: Kwdikas tis vivliothikis grafoy (pin.geitniasis) */ 2 | #include 3 | #include 4 | #include "graph.h" 5 | 6 | /* GR_init(): arxikopoiei to grafo */ 7 | void GR_init(GRAPH *g, int N) 8 | { 9 | int i,j; 10 | g->N = N; 11 | g->array = (int **)malloc(sizeof(int*)*N); 12 | if(!g->array) 13 | { 14 | printf("Error Allocating Memory"); 15 | exit(0); 16 | } 17 | for (i=0; iarray[i] = (int *)malloc(sizeof(int)*N); 20 | if (!g->array[i]) 21 | { 22 | printf("Error Allocating Memory"); 23 | exit(0); 24 | } 25 | for (j=0; jarray[i][j] = 0; 27 | } 28 | } 29 | 30 | /* GR_print(): ektypwnei to grafo */ 31 | void GR_print(GRAPH g) 32 | { 33 | int i,j; 34 | 35 | printf(" "); 36 | for (i=0; ig.N || vertex2<0 || vertex2>g.N) 58 | { 59 | printf("Error: index out of bounds"); 60 | exit(0); 61 | } 62 | if (g.array[vertex1][vertex2]==1) 63 | printf("Error: H akmh (%d,%d) yparxei hdh", vertex1, vertex2); 64 | else 65 | { 66 | g.array[vertex1][vertex2]=1; 67 | } 68 | } 69 | 70 | /* GR_destroy(): katastrefei to grafo */ 71 | void GR_destroy(GRAPH g) 72 | { 73 | int i; 74 | for (i=0; iN); 87 | 88 | g->array = (int **)malloc(sizeof(int*)*g->N); 89 | if(!g->array) 90 | { 91 | printf("Error Allocating Memory"); 92 | exit(0); 93 | } 94 | 95 | for (i=0; iN; i++) 96 | { 97 | g->array[i] = (int *)malloc(sizeof(int)*g->N); 98 | if (!g->array[i]) 99 | { 100 | printf("Error Allocating Memory"); 101 | exit(0); 102 | } 103 | for (j=0; jN; j++) 104 | g->array[i][j] = 0; 105 | } 106 | 107 | while(!feof(fp)) 108 | { 109 | fscanf(fp,"%d %d", &i, &j); 110 | GR_add_edge(*g, i, j); 111 | } 112 | 113 | fclose(fp); 114 | } 115 | -------------------------------------------------------------------------------- /data_structures_10_graph/GraphAdjMatrix/graph.c: -------------------------------------------------------------------------------- 1 | /* graph.c: Kwdikas tis vivliothikis grafoy (pin.geitniasis) */ 2 | #include 3 | #include 4 | #include "graph.h" 5 | 6 | /* GR_init(): arxikopoiei to grafo */ 7 | void GR_init(GRAPH *g, int N) 8 | { 9 | int i,j; 10 | g->N = N; 11 | g->array = (int **)malloc(sizeof(int*)*N); 12 | if(!g->array) 13 | { 14 | printf("Error Allocating Memory"); 15 | exit(0); 16 | } 17 | for (i=0; iarray[i] = (int *)malloc(sizeof(int)*N); 20 | if (!g->array[i]) 21 | { 22 | printf("Error Allocating Memory"); 23 | exit(0); 24 | } 25 | for (j=0; jarray[i][j] = 0; 27 | } 28 | } 29 | 30 | /* GR_print(): ektypwnei to grafo */ 31 | void GR_print(GRAPH g) 32 | { 33 | int i,j; 34 | 35 | printf(" "); 36 | for (i=0; ig.N || vertex2<0 || vertex2>g.N) 58 | { 59 | printf("Error: index out of bounds"); 60 | exit(0); 61 | } 62 | if (g.array[vertex1][vertex2]==1) 63 | printf("Error: H akmh (%d,%d) yparxei hdh", vertex1, vertex2); 64 | else 65 | { 66 | g.array[vertex1][vertex2]=1; 67 | g.array[vertex2][vertex1]=1; 68 | } 69 | } 70 | 71 | /* GR_destroy(): katastrefei to grafo */ 72 | void GR_destroy(GRAPH g) 73 | { 74 | int i; 75 | for (i=0; iN); 88 | 89 | g->array = (int **)malloc(sizeof(int*)*g->N); 90 | if(!g->array) 91 | { 92 | printf("Error Allocating Memory"); 93 | exit(0); 94 | } 95 | 96 | for (i=0; iN; i++) 97 | { 98 | g->array[i] = (int *)malloc(sizeof(int)*g->N); 99 | if (!g->array[i]) 100 | { 101 | printf("Error Allocating Memory"); 102 | exit(0); 103 | } 104 | for (j=0; jN; j++) 105 | g->array[i][j] = 0; 106 | } 107 | 108 | while(!feof(fp)) 109 | { 110 | fscanf(fp,"%d %d", &i, &j); 111 | GR_add_edge(*g, i, j); 112 | } 113 | 114 | fclose(fp); 115 | } 116 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise1.2/graph.c: -------------------------------------------------------------------------------- 1 | /* graph.c: Kwdikas tis vivliothikis grafoy (pin.geitniasis) */ 2 | #include 3 | #include 4 | #include "graph.h" 5 | 6 | /* GR_init(): arxikopoiei to grafo */ 7 | void GR_init(GRAPH *g, int N) 8 | { 9 | int i,j; 10 | g->N = N; 11 | g->array = (int **)malloc(sizeof(int*)*N); 12 | if(!g->array) 13 | { 14 | printf("Error Allocating Memory"); 15 | exit(0); 16 | } 17 | for (i=0; iarray[i] = (int *)malloc(sizeof(int)*N); 20 | if (!g->array[i]) 21 | { 22 | printf("Error Allocating Memory"); 23 | exit(0); 24 | } 25 | for (j=0; jarray[i][j] = 0; 27 | } 28 | } 29 | 30 | /* GR_print(): ektypwnei to grafo */ 31 | void GR_print(GRAPH g) 32 | { 33 | int i,j; 34 | 35 | printf(" "); 36 | for (i=0; ig.N || vertex2<0 || vertex2>g.N) 58 | { 59 | printf("Error: index out of bounds"); 60 | exit(0); 61 | } 62 | if (g.array[vertex1][vertex2]==1) 63 | printf("Error: H akmh (%d,%d) yparxei hdh", vertex1, vertex2); 64 | else 65 | { 66 | g.array[vertex1][vertex2]=weight; 67 | g.array[vertex2][vertex1]=weight; 68 | } 69 | } 70 | 71 | /* GR_destroy(): katastrefei to grafo */ 72 | void GR_destroy(GRAPH g) 73 | { 74 | int i; 75 | for (i=0; iN); 88 | 89 | g->array = (int **)malloc(sizeof(int*)*g->N); 90 | if(!g->array) 91 | { 92 | printf("Error Allocating Memory"); 93 | exit(0); 94 | } 95 | 96 | for (i=0; iN; i++) 97 | { 98 | g->array[i] = (int *)malloc(sizeof(int)*g->N); 99 | if (!g->array[i]) 100 | { 101 | printf("Error Allocating Memory"); 102 | exit(0); 103 | } 104 | for (j=0; jN; j++) 105 | g->array[i][j] = 0; 106 | } 107 | 108 | while(!feof(fp)) 109 | { 110 | fscanf(fp,"%d %d %d", &i, &j, &w); 111 | GR_add_edge(*g, i, j, w); 112 | } 113 | 114 | fclose(fp); 115 | } 116 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/linked_list/linked_list.c: -------------------------------------------------------------------------------- 1 | /* linked_list.c: Kwdikas tis vivliothikis sindedemenis listas */ 2 | #include 3 | #include 4 | #include "linked_list.h" 5 | 6 | /* LL_init(): arxikopoiei tin lista */ 7 | void LL_init(LIST_PTR *head) 8 | { 9 | *head=NULL; 10 | } 11 | 12 | /* LL_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i lista einai adeia */ 14 | int LL_empty(LIST_PTR head) 15 | { 16 | return head == NULL; 17 | } 18 | 19 | /* LL_data(): epistrefei ta dedomena tou komvou 20 | pou deixnei o deiktis p */ 21 | elem LL_data(LIST_PTR p) 22 | { 23 | return p->data; 24 | } 25 | 26 | /* LL_insert_start(): Eisagei to stoixeio x 27 | stin arxi tis listas */ 28 | int LL_insert_start(LIST_PTR *head,elem x) 29 | { 30 | LIST_PTR newnode; 31 | 32 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 33 | if (!newnode) 34 | { 35 | printf("Adynamia desmeusis mnimis"); 36 | return FALSE; 37 | } 38 | newnode->data=x; 39 | 40 | newnode->next=*head; 41 | *head=newnode; 42 | return TRUE; 43 | } 44 | 45 | /* LL_insert_after(): Eisagei to stoixeio x 46 | meta to stoixeio pou deixnei o p */ 47 | int LL_insert_after(LIST_PTR p,elem x) 48 | { 49 | LIST_PTR newnode; 50 | 51 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 52 | if (!newnode) 53 | { 54 | printf("Adynamia desmeusis mnimis"); 55 | return FALSE; 56 | } 57 | newnode->data=x; 58 | 59 | newnode->next=p->next; 60 | p->next=newnode; 61 | return TRUE; 62 | } 63 | 64 | /* LL_delete_start(): Diagrafei ton komvo poy deixnei 65 | i kefali tis listas */ 66 | int LL_delete_start(LIST_PTR *head, elem *x) 67 | { 68 | LIST_PTR current; 69 | 70 | if (*head==NULL) 71 | return FALSE; 72 | 73 | current=*head; 74 | *x=current->data; 75 | 76 | (*head)=(*head)->next; 77 | free(current); 78 | return TRUE; 79 | } 80 | 81 | /* LL_delete_after(): Diagrafei ton epomeno tou 82 | komvou poy deixnei o prev */ 83 | int LL_delete_after(LIST_PTR prev, elem *x) 84 | { 85 | LIST_PTR current; 86 | 87 | if (prev->next==NULL) 88 | return FALSE; 89 | 90 | current=prev->next; 91 | *x=current->data; 92 | 93 | prev->next=current->next; 94 | free(current); 95 | return TRUE; 96 | } 97 | 98 | /* LL_print(): Typwnei ta periexomena mias 99 | syndedemenis listas */ 100 | 101 | void LL_print(LIST_PTR head) 102 | { 103 | LIST_PTR current; 104 | 105 | current=head; 106 | while(current!=NULL) 107 | { 108 | printf("%d ",current->data); 109 | current=current->next; 110 | } 111 | } 112 | 113 | /* LL_destroy(): Apodesmeyei to xwro poy exei 114 | desmeusei i lista */ 115 | 116 | void LL_destroy(LIST_PTR *head) 117 | { 118 | LIST_PTR ptr; 119 | 120 | while (*head!=NULL) 121 | { 122 | ptr=*head; 123 | *head=(*head)->next; 124 | free(ptr); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /data_structures_10_graph/exercise2/graph.c: -------------------------------------------------------------------------------- 1 | /* graph.c: Kwdikas tis vivliothikis grafoy (pin.geitniasis) */ 2 | #include 3 | #include 4 | #include "graph.h" 5 | 6 | /* GR_init(): arxikopoiei to grafo */ 7 | void GR_init(GRAPH *g, int N) 8 | { 9 | int i,j; 10 | g->N = N; 11 | g->array = (int **)malloc(sizeof(int*)*N); 12 | if(!g->array) 13 | { 14 | printf("Error Allocating Memory"); 15 | exit(0); 16 | } 17 | for (i=0; iarray[i] = (int *)malloc(sizeof(int)*N); 20 | if (!g->array[i]) 21 | { 22 | printf("Error Allocating Memory"); 23 | exit(0); 24 | } 25 | for (j=0; jarray[i][j] = 0; 27 | } 28 | } 29 | 30 | /* GR_print(): ektypwnei to grafo */ 31 | void GR_print(GRAPH g) 32 | { 33 | int i,j; 34 | 35 | printf(" "); 36 | for (i=0; ig.N || vertex2<0 || vertex2>g.N) 58 | { 59 | printf("Error: index out of bounds"); 60 | exit(0); 61 | } 62 | if (g.array[vertex1][vertex2]==1) 63 | printf("Error: H akmh (%d,%d) yparxei hdh", vertex1, vertex2); 64 | else 65 | { 66 | g.array[vertex1][vertex2]=weight; 67 | g.array[vertex2][vertex1]=weight; 68 | } 69 | } 70 | 71 | /* GR_destroy(): katastrefei to grafo */ 72 | void GR_destroy(GRAPH g) 73 | { 74 | int i; 75 | for (i=0; i0) 87 | cnt++; 88 | 89 | return cnt; 90 | } 91 | 92 | /* GR_init_from_file(): arxikopoiisi apo arxeio */ 93 | void GR_init_from_file(GRAPH *g, char *filename) 94 | { 95 | int i,j,w; 96 | FILE *fp; 97 | 98 | fp = fopen(filename, "r"); 99 | fscanf(fp,"%d", &g->N); 100 | 101 | g->array = (int **)malloc(sizeof(int*)*g->N); 102 | if(!g->array) 103 | { 104 | printf("Error Allocating Memory"); 105 | exit(0); 106 | } 107 | 108 | for (i=0; iN; i++) 109 | { 110 | g->array[i] = (int *)malloc(sizeof(int)*g->N); 111 | if (!g->array[i]) 112 | { 113 | printf("Error Allocating Memory"); 114 | exit(0); 115 | } 116 | for (j=0; jN; j++) 117 | g->array[i][j] = 0; 118 | } 119 | 120 | while(!feof(fp)) 121 | { 122 | fscanf(fp,"%d %d %d", &i, &j, &w); 123 | GR_add_edge(*g, i, j, w); 124 | } 125 | 126 | fclose(fp); 127 | } 128 | -------------------------------------------------------------------------------- /data_structures_8_heaps/tree/heap.c: -------------------------------------------------------------------------------- 1 | /* heap.c: Kwdikas tis vivliothikis dendrou */ 2 | #include 3 | #include 4 | #include "heap.h" 5 | 6 | void swap (elem *x, elem *y) 7 | { 8 | elem temp; 9 | 10 | temp=*x; 11 | *x=*y; 12 | *y=temp; 13 | } 14 | 15 | 16 | /* HEAP_init(): arxikopoiei to dendro */ 17 | void HEAP_init(HEAP *heap) 18 | { 19 | heap->N=0; 20 | } 21 | 22 | /* HEAP_insert(): Eisagei to stoixeio x 23 | sto dentro-swros heap */ 24 | int HEAP_insert(HEAP *heap,elem x) 25 | { 26 | int posParent, posCurrent; 27 | 28 | /* An den xwraei sto swro */ 29 | if (heap->N == MAX_SIZE) 30 | return FALSE; 31 | 32 | /* 1. Eisagwgi tou neou komvou */ 33 | heap->data[heap->N]=x; 34 | heap->N ++; 35 | 36 | /* 2. Antimetathesi me to gonea 37 | efoson vrei mikroteri timi */ 38 | posCurrent=heap->N - 1; 39 | while (posCurrent>0) 40 | { 41 | posParent=(posCurrent-1)/2; 42 | /* 2.1 Exei megaliteri timi apo gonea. Antimetathesi. */ 43 | if (heap->data[posCurrent] > heap->data[posParent]) 44 | { 45 | swap(&heap->data[posCurrent],&heap->data[posParent]); 46 | posCurrent=posParent; 47 | } 48 | /* 2.2 Pire tin oristiki tou thesi. Diakopi */ 49 | else 50 | break; 51 | } 52 | 53 | return TRUE; 54 | } 55 | 56 | 57 | /* HEAP_delete(): Diagrafei ti riza tou dendrou */ 58 | int HEAP_delete(HEAP *heap,elem *x) 59 | { 60 | int posCurrent, posLeft, posRight, pos; 61 | elem temp; 62 | 63 | /* An o swros den einai adeios */ 64 | if (heap->N == 0) 65 | return FALSE; 66 | 67 | /* 1. Sigkratisi (epistrofi) tis rizas */ 68 | *x=heap->data[0]; 69 | 70 | /* 2. Topothetisi tou teleutaiou stoixeiou sti riza */ 71 | heap->data[0]=heap->data[heap->N - 1]; 72 | heap->N --; 73 | 74 | 75 | posCurrent=0; 76 | while(posCurrentN) 77 | { 78 | posLeft=2*posCurrent+1; 79 | posRight=2*posCurrent+2; 80 | 81 | if (posLeft >= heap->N) 82 | posLeft=-1; 83 | if (posRight >= heap->N) 84 | posRight=-1; 85 | 86 | /* 1. Den exei paidia */ 87 | if (posLeft==-1 && posRight==-1) 88 | break; 89 | /* 2. Exei mono aristero paidi */ 90 | else if (posLeft!=-1 && posRight==-1) 91 | { 92 | if (heap->data[posCurrent] < heap->data[posLeft]) 93 | { 94 | swap(&heap->data[posCurrent],&heap->data[posLeft]); 95 | posCurrent=posLeft; 96 | } 97 | else 98 | break; 99 | } 100 | /* 3. Exei dyo paidia */ 101 | else // posLeft!=-1 && posRight!=-1 102 | { 103 | /*3.1 Eyresi tou megaliterou apo ta dyo paidia */ 104 | if (heap->data[posLeft] < heap->data[posRight]) 105 | pos=posRight; 106 | else 107 | pos=posLeft; 108 | 109 | /*3.2 Antimetathesi an einai mikrotero */ 110 | if (heap->data[posCurrent] < heap->data[pos]) 111 | { 112 | swap(&heap->data[posCurrent],&heap->data[pos]); 113 | posCurrent=pos; 114 | } 115 | else 116 | break; 117 | } 118 | } 119 | } 120 | 121 | 122 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise02/disjoint_sets.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "disjoint_sets.h" 4 | 5 | /* Basikes Prakseis */ 6 | void DS_init(DISJOINT *d, int N) 7 | { 8 | int i; 9 | 10 | d->N = N; 11 | 12 | d->repr = (elem *)malloc(sizeof(elem)*N); 13 | if (!d->repr) 14 | { 15 | printf("Error allocating memory!"); 16 | exit(0); 17 | } 18 | d->list = (EXTENDED_LIST *)malloc(sizeof(EXTENDED_LIST)*N); 19 | if (!d->list) 20 | { 21 | printf("Error allocating memory!"); 22 | exit(0); 23 | } 24 | 25 | for (i=0; ilist[i].head=NULL; 28 | d->list[i].last=NULL; 29 | } 30 | 31 | for (i=0; irepr[i]=i; 35 | } 36 | 37 | } 38 | 39 | void DS_make_set(DISJOINT *d, elem x) 40 | { 41 | LL_insert_start(&((d->list[x]).head),x); 42 | d->list[x].last=d->list[x].head; 43 | } 44 | 45 | int DS_union(DISJOINT *d, elem x, elem y) 46 | { 47 | LIST_PTR current; 48 | 49 | if (d->repr[x]==d->repr[y]) 50 | { 51 | printf("Error: Both elements in the same set"); 52 | return FALSE; 53 | } 54 | 55 | d->list[x].last->next = d->list[y].head; 56 | d->list[x].last = d->list[y].last; 57 | 58 | current = d->list[x].head; 59 | while(current!=NULL) 60 | { 61 | d->list[current->data]=d->list[x]; 62 | current=current->next; 63 | } 64 | current = d->list[y].head; 65 | while(current!=NULL) 66 | { 67 | d->repr[current->data]=x; 68 | d->list[current->data]=d->list[x]; 69 | current=current->next; 70 | } 71 | 72 | return TRUE; 73 | } 74 | 75 | elem DS_find_set(DISJOINT d, elem x) 76 | { 77 | return d.repr[x]; 78 | } 79 | 80 | void DS_destroy(DISJOINT *d) 81 | { 82 | int i; 83 | LIST_PTR current; 84 | elem x; 85 | 86 | for (i=0; iN; i++) 87 | { 88 | current = d->list[i].head; 89 | while(current!=NULL) 90 | { 91 | d->list[current->data].head=NULL; 92 | LL_delete_start(¤t, &x); 93 | } 94 | } 95 | 96 | free(d->list); 97 | free(d->repr); 98 | } 99 | 100 | /* Deutereouses Prakseis */ 101 | void DS_print(DISJOINT d) 102 | { 103 | int i; 104 | int *MARK; 105 | LIST_PTR current, head; 106 | 107 | MARK=(int *)malloc(sizeof(int)*d.N); 108 | for (i=0; idata]==1) 116 | continue; 117 | 118 | printf("{ "); 119 | while(current!=NULL) 120 | { 121 | printf("%d ",current->data); 122 | MARK[current->data]=1; 123 | current = current->next; 124 | } 125 | printf("}\n"); 126 | } 127 | free(MARK); 128 | } 129 | 130 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/DisjointSets(LinkedLists)/disjoint_sets.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "disjoint_sets.h" 4 | 5 | /* Basikes Prakseis */ 6 | void DS_init(DISJOINT *d, int N) 7 | { 8 | int i; 9 | 10 | d->N = N; 11 | 12 | d->repr = (elem *)malloc(sizeof(elem)*N); 13 | if (!d->repr) 14 | { 15 | printf("Error allocating memory!"); 16 | exit(0); 17 | } 18 | d->list = (EXTENDED_LIST *)malloc(sizeof(EXTENDED_LIST)*N); 19 | if (!d->list) 20 | { 21 | printf("Error allocating memory!"); 22 | exit(0); 23 | } 24 | 25 | for (i=0; ilist[i].head=NULL; 28 | d->list[i].last=NULL; 29 | } 30 | 31 | for (i=0; irepr[i]=i; 35 | } 36 | 37 | } 38 | 39 | void DS_make_set(DISJOINT *d, elem x) 40 | { 41 | LL_insert_start(&((d->list[x]).head),x); 42 | d->list[x].last=d->list[x].head; 43 | } 44 | 45 | int DS_union(DISJOINT *d, elem x, elem y) 46 | { 47 | LIST_PTR current; 48 | 49 | if (d->repr[x]==d->repr[y]) 50 | { 51 | printf("Error: Both elements in the same set"); 52 | return FALSE; 53 | } 54 | 55 | d->list[x].last->next = d->list[y].head; 56 | d->list[x].last = d->list[y].last; 57 | 58 | current = d->list[x].head; 59 | while(current!=NULL) 60 | { 61 | d->list[current->data]=d->list[x]; 62 | current=current->next; 63 | } 64 | current = d->list[y].head; 65 | while(current!=NULL) 66 | { 67 | d->repr[current->data]=x; 68 | d->list[current->data]=d->list[x]; 69 | current=current->next; 70 | } 71 | 72 | return TRUE; 73 | } 74 | 75 | elem DS_find_set(DISJOINT d, elem x) 76 | { 77 | return d.repr[x]; 78 | } 79 | 80 | void DS_destroy(DISJOINT *d) 81 | { 82 | int i; 83 | LIST_PTR current; 84 | elem x; 85 | 86 | for (i=0; iN; i++) 87 | { 88 | current = d->list[i].head; 89 | while(current!=NULL) 90 | { 91 | d->list[current->data].head=NULL; 92 | LL_delete_start(¤t, &x); 93 | } 94 | } 95 | 96 | free(d->list); 97 | free(d->repr); 98 | } 99 | 100 | /* Deutereouses Prakseis */ 101 | void DS_print(DISJOINT d) 102 | { 103 | int i; 104 | int *MARK; 105 | LIST_PTR current, head; 106 | 107 | MARK=(int *)malloc(sizeof(int)*d.N); 108 | for (i=0; idata]==1) 116 | continue; 117 | 118 | printf("{ "); 119 | while(current!=NULL) 120 | { 121 | printf("%d ",current->data); 122 | MARK[current->data]=1; 123 | current = current->next; 124 | } 125 | printf("}\n"); 126 | } 127 | free(MARK); 128 | } 129 | 130 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise01/disjoint_sets.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "disjoint_sets.h" 4 | 5 | /* Basikes Prakseis */ 6 | void DS_init(DISJOINT *d, int N) 7 | { 8 | int i; 9 | 10 | d->N = N; 11 | 12 | d->repr = (elem *)malloc(sizeof(elem)*N); 13 | if (!d->repr) 14 | { 15 | printf("Error allocating memory!"); 16 | exit(0); 17 | } 18 | d->list = (EXTENDED_LIST *)malloc(sizeof(EXTENDED_LIST)*N); 19 | if (!d->list) 20 | { 21 | printf("Error allocating memory!"); 22 | exit(0); 23 | } 24 | 25 | for (i=0; ilist[i].head=NULL; 28 | d->list[i].last=NULL; 29 | } 30 | 31 | for (i=0; irepr[i]=i; 35 | } 36 | 37 | } 38 | 39 | void DS_make_set(DISJOINT *d, elem x) 40 | { 41 | LL_insert_start(&((d->list[x]).head),x); 42 | d->list[x].last=d->list[x].head; 43 | } 44 | 45 | int DS_union(DISJOINT *d, elem x, elem y) 46 | { 47 | LIST_PTR current; 48 | if (d->repr[x]==d->repr[y]) 49 | { 50 | //printf("Error: Both elements in the same set"); 51 | return FALSE; 52 | } 53 | 54 | d->list[x].last->next = d->list[y].head; 55 | d->list[x].last = d->list[y].last; 56 | 57 | current = d->list[x].head; 58 | while(current!=NULL) 59 | { 60 | d->list[current->data]=d->list[x]; 61 | current=current->next; 62 | } 63 | current = d->list[y].head; 64 | while(current!=NULL) 65 | { 66 | d->repr[current->data]=x; 67 | d->list[current->data]=d->list[x]; 68 | current=current->next; 69 | } 70 | 71 | return TRUE; 72 | } 73 | 74 | elem DS_find_set(DISJOINT d, elem x) 75 | { 76 | return d.repr[x]; 77 | } 78 | 79 | void DS_destroy(DISJOINT *d) 80 | { 81 | int i; 82 | LIST_PTR current; 83 | elem x; 84 | 85 | for (i=0; iN; i++) 86 | { 87 | current = d->list[i].head; 88 | while(current!=NULL) 89 | { 90 | d->list[current->data].head=NULL; 91 | LL_delete_start(¤t, &x); 92 | } 93 | } 94 | 95 | free(d->list); 96 | free(d->repr); 97 | } 98 | 99 | /* Deutereouses Prakseis */ 100 | void DS_print(DISJOINT d) 101 | { 102 | int i; 103 | int *MARK; 104 | LIST_PTR current, head; 105 | 106 | MARK=(int *)malloc(sizeof(int)*d.N); 107 | for (i=0; idata]==1) 116 | continue; 117 | 118 | printf("{ "); 119 | while(current!=NULL) 120 | { 121 | printf("%d ",current->data); 122 | MARK[current->data]=1; 123 | current = current->next; 124 | } 125 | printf("}\n"); 126 | } 127 | free(MARK); 128 | } 129 | 130 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/doubly_linked_list/doubly_linked_list.c: -------------------------------------------------------------------------------- 1 | /* linked_list.c: Kwdikas tis vivliothikis sindedemenis listas */ 2 | #include 3 | #include 4 | #include "doubly_linked_list.h" 5 | 6 | /* DLL_init(): arxikopoiei tin lista */ 7 | void DLL_init(LIST_PTR *head) 8 | { 9 | *head=NULL; 10 | } 11 | 12 | /* DLL_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i lista einai adeia */ 14 | int DLL_empty(LIST_PTR head) 15 | { 16 | return head == NULL; 17 | } 18 | 19 | /* DLL_data(): epistrefei ta dedomena tou komvou 20 | pou deixnei o deiktis p */ 21 | elem DLL_data(LIST_PTR p) 22 | { 23 | return p->data; 24 | } 25 | 26 | /* DLL_insert_start(): Eisagei to stoixeio x 27 | stin arxi tis listas */ 28 | int DLL_insert_start(LIST_PTR *head,elem x) 29 | { 30 | LIST_PTR newnode; 31 | 32 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 33 | if (!newnode) 34 | { 35 | printf("Adynamia desmeusis mnimis"); 36 | return FALSE; 37 | } 38 | newnode->data=x; 39 | 40 | newnode->next=*head; 41 | newnode->prev=NULL; 42 | *head=newnode; 43 | if (newnode->next!=NULL) 44 | newnode->next->prev=newnode; 45 | return TRUE; 46 | } 47 | 48 | /* DLL_insert_after(): Eisagei to stoixeio x 49 | meta to stoixeio pou deixnei o p */ 50 | int DLL_insert_after(LIST_PTR p,elem x) 51 | { 52 | LIST_PTR newnode; 53 | 54 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 55 | if (!newnode) 56 | { 57 | printf("Adynamia desmeusis mnimis"); 58 | return FALSE; 59 | } 60 | newnode->data=x; 61 | 62 | newnode->next=p->next; 63 | newnode->prev=p; 64 | p->next=newnode; 65 | if (newnode->next!=NULL) 66 | newnode->next->prev=newnode; 67 | return TRUE; 68 | } 69 | 70 | /* DLL_delete_start(): Diagrafei ton komvo poy deixnei 71 | i kefali tis listas */ 72 | int DLL_delete_start(LIST_PTR *head, elem *x) 73 | { 74 | LIST_PTR current; 75 | 76 | if (*head==NULL) 77 | return FALSE; 78 | 79 | current=*head; 80 | *x=current->data; 81 | 82 | (*head)=(*head)->next; 83 | if ((*head)!=NULL) 84 | (*head)->prev=NULL; 85 | 86 | free(current); 87 | return TRUE; 88 | } 89 | 90 | /* DLL_delete_after(): Diagrafei ton epomeno tou 91 | komvou poy deixnei o prev */ 92 | int DLL_delete_after(LIST_PTR previous, elem *x) 93 | { 94 | LIST_PTR current; 95 | 96 | if (previous->next==NULL) 97 | return FALSE; 98 | 99 | current=previous->next; 100 | *x=current->data; 101 | 102 | previous->next=current->next; 103 | if (current->next!=NULL) 104 | current->next->prev=previous; 105 | 106 | free(current); 107 | return TRUE; 108 | } 109 | 110 | /* DLL_print(): Typwnei ta periexomena mias 111 | syndedemenis listas */ 112 | 113 | void DLL_print(LIST_PTR head) 114 | { 115 | LIST_PTR current; 116 | 117 | current=head; 118 | while(current!=NULL) 119 | { 120 | printf("%d ",current->data); 121 | current=current->next; 122 | } 123 | } 124 | 125 | /* DLL_destroy(): Apodesmeyei to xwro poy exei 126 | desmeusei i lista */ 127 | 128 | void DLL_destroy(LIST_PTR *head) 129 | { 130 | LIST_PTR ptr; 131 | 132 | while (*head!=NULL) 133 | { 134 | ptr=*head; 135 | *head=(*head)->next; 136 | free(ptr); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise03/disjoint_sets.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "disjoint_sets.h" 4 | 5 | /* Basikes Prakseis */ 6 | void DS_init(DISJOINT *d, int N) 7 | { 8 | int i; 9 | 10 | d->N = N; 11 | 12 | d->array = (DISJOINT_PTR *)malloc(sizeof(DISJOINT_PTR)*N); 13 | if (!d->array) 14 | { 15 | printf("Error allocating memory!"); 16 | exit(0); 17 | } 18 | 19 | for (i=0; iarray[x] = (DISJOINT_NODE *)malloc(sizeof(DISJOINT_NODE)); 27 | if (!d->array[x]) 28 | { 29 | printf("Error allocating memory!"); 30 | exit(0); 31 | } 32 | d->array[x]->data = x; 33 | d->array[x]->height = 0; 34 | d->array[x]->parent = d->array[x]; 35 | } 36 | 37 | int DS_union(DISJOINT *d, elem x, elem y) 38 | { 39 | int p1, p2; 40 | 41 | p1 = DS_find_set(*d, x); 42 | p2 = DS_find_set(*d, y); 43 | 44 | if (p1==p2) 45 | { 46 | printf("Elements %d and %d are in the same set(%d)", x, y, p1); 47 | return FALSE; 48 | } 49 | 50 | if (d->array[p1]->height < d->array[p2]->height) 51 | d->array[p1]->parent = d->array[p2]; 52 | else if (d->array[p1]->height > d->array[p2]->height) 53 | d->array[p2]->parent = d->array[p1]; 54 | else 55 | { 56 | d->array[p2]->parent = d->array[p1]; 57 | (d->array[p1]->height)++; 58 | } 59 | 60 | return TRUE; 61 | } 62 | 63 | elem DS_find_set(DISJOINT d, elem x) 64 | { 65 | int p; 66 | if (d.array[x]->parent == d.array[x]) 67 | return x; 68 | else 69 | { 70 | p = DS_find_set(d, d.array[x]->parent->data); 71 | d.array[x]->parent=d.array[p]; 72 | return p; 73 | } 74 | } 75 | 76 | void DS_destroy(DISJOINT *d) 77 | { 78 | int i; 79 | 80 | for (i=0; iN; i++) 81 | { 82 | free(d->array[i]); 83 | } 84 | 85 | free(d->array); 86 | } 87 | 88 | 89 | /* Deutereouses Prakseis */ 90 | elem DS_find_set_print(DISJOINT d, elem x) 91 | { 92 | if (d.array[x]->parent == d.array[x]) 93 | return x; 94 | else 95 | return DS_find_set_print(d, d.array[x]->parent->data); 96 | } 97 | 98 | void DS_print(DISJOINT d) 99 | { 100 | int i, v, cnt; 101 | int *MARK; 102 | 103 | MARK = (int *)malloc(sizeof(int)*d.N); 104 | if(!MARK) 105 | { 106 | printf("Error allocating memory"); 107 | exit(0); 108 | } 109 | for (i=0; iparent->data); 129 | } 130 | printf("} "); 131 | } 132 | 133 | free(MARK); 134 | } 135 | 136 | -------------------------------------------------------------------------------- /data_structures_4_linked_lists/askisi2/stack.c: -------------------------------------------------------------------------------- 1 | /* stoiva.c: Kwdikas tis vivliothikis stoiva */ 2 | #include 3 | #include 4 | #include "stack.h" 5 | 6 | /* LL_init(): arxikopoiei tin lista */ 7 | void LL_init(LIST_PTR *head) 8 | { 9 | *head=NULL; 10 | } 11 | 12 | /* LL_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i lista einai adeia */ 14 | int LL_empty(LIST_PTR head) 15 | { 16 | return head == NULL; 17 | } 18 | 19 | /* LL_data(): epistrefei ta dedomena tou komvou 20 | pou deixnei o deiktis p */ 21 | elem LL_data(LIST_PTR p) 22 | { 23 | return p->data; 24 | } 25 | 26 | /* LL_insert_start(): Eisagei to stoixeio x 27 | stin arxi tis listas */ 28 | int LL_insert_start(LIST_PTR *head,elem x) 29 | { 30 | LIST_PTR newnode; 31 | 32 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 33 | if (!newnode) 34 | { 35 | printf("Adynamia desmeusis mnimis"); 36 | return FALSE; 37 | } 38 | newnode->data=x; 39 | 40 | newnode->next=*head; 41 | *head=newnode; 42 | return TRUE; 43 | } 44 | 45 | /* LL_insert_after(): Eisagei to stoixeio x 46 | meta to stoixeio pou deixnei o p */ 47 | int LL_insert_after(LIST_PTR p,elem x) 48 | { 49 | LIST_PTR newnode; 50 | 51 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 52 | if (!newnode) 53 | { 54 | printf("Adynamia desmeusis mnimis"); 55 | return FALSE; 56 | } 57 | newnode->data=x; 58 | 59 | newnode->next=p->next; 60 | p->next=newnode; 61 | return TRUE; 62 | } 63 | 64 | /* LL_delete_start(): Diagrafei ton komvo poy deixnei 65 | i kefali tis listas */ 66 | int LL_delete_start(LIST_PTR *head, elem *x) 67 | { 68 | LIST_PTR current; 69 | 70 | if (*head==NULL) 71 | return FALSE; 72 | 73 | current=*head; 74 | *x=current->data; 75 | 76 | (*head)=(*head)->next; 77 | free(current); 78 | return TRUE; 79 | } 80 | 81 | /* LL_delete_after(): Diagrafei ton epomeno tou 82 | komvou poy deixnei o prev */ 83 | int LL_delete_after(LIST_PTR prev, elem *x) 84 | { 85 | LIST_PTR current; 86 | 87 | if (prev->next==NULL) 88 | return FALSE; 89 | 90 | current=prev->next; 91 | *x=current->data; 92 | 93 | prev->next=current->next; 94 | free(current); 95 | return TRUE; 96 | } 97 | 98 | /* LL_print(): Typwnei ta periexomena mias 99 | syndedemenis listas */ 100 | 101 | void LL_print(LIST_PTR head) 102 | { 103 | LIST_PTR current; 104 | 105 | current=head; 106 | while(current!=NULL) 107 | { 108 | printf("%d ",current->data); 109 | current=current->next; 110 | } 111 | } 112 | 113 | /* LL_destroy(): Apodesmeyei to xwro poy exei 114 | desmeusei i lista */ 115 | 116 | void LL_destroy(LIST_PTR *head) 117 | { 118 | LIST_PTR ptr; 119 | 120 | while (*head!=NULL) 121 | { 122 | ptr=*head; 123 | *head=(*head)->next; 124 | free(ptr); 125 | } 126 | } 127 | 128 | void ST_init(STACK *s) 129 | { 130 | LL_init(s); 131 | } 132 | 133 | int ST_empty(STACK s) 134 | { 135 | return LL_empty(s); 136 | } 137 | 138 | int ST_push(STACK *s,elem x) 139 | { 140 | LL_insert_start(s,x); 141 | } 142 | 143 | int ST_pop(STACK *s,elem *x) 144 | { 145 | return LL_delete_start(s, x); 146 | } 147 | 148 | int ST_print(STACK s) 149 | { 150 | LL_print(s); 151 | } 152 | 153 | int ST_destroy(STACK *s) 154 | { 155 | LL_destroy(s); 156 | } 157 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/circular_list/circular_list.c: -------------------------------------------------------------------------------- 1 | /* circular_list.c: Kwdikas tis vivliothikis sindedemenis listas */ 2 | #include 3 | #include 4 | #include "circular_list.h" 5 | 6 | /* CL_init(): arxikopoiei tin lista */ 7 | void CL_init(LIST_PTR *head) 8 | { 9 | *head=NULL; 10 | } 11 | 12 | /* CL_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i lista einai adeia */ 14 | int CL_empty(LIST_PTR head) 15 | { 16 | return head == NULL; 17 | } 18 | 19 | /* CL_data(): epistrefei ta dedomena tou komvou 20 | pou deixnei o deiktis p */ 21 | elem CL_data(LIST_PTR p) 22 | { 23 | return p->data; 24 | } 25 | 26 | /* CL_insert_start(): Eisagei to stoixeio x 27 | stin arxi tis listas */ 28 | int CL_insert_start(LIST_PTR *head,elem x) 29 | { 30 | LIST_PTR newnode, last; 31 | // 1 32 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 33 | if (!newnode) 34 | { 35 | printf("Adynamia desmeusis mnimis"); 36 | return FALSE; 37 | } 38 | newnode->data=x; 39 | 40 | if (*head == NULL) 41 | { // 2 42 | newnode->next=newnode; 43 | *head=newnode; 44 | } 45 | else 46 | { 47 | // 3.1 48 | last = *head; 49 | while (last->next!=*head) 50 | last=last->next; 51 | last->next=newnode; 52 | 53 | // 3.2 54 | newnode->next=*head; 55 | 56 | // 3.3 57 | *head=newnode; 58 | } 59 | 60 | return TRUE; 61 | } 62 | 63 | /* CL_insert_after(): Eisagei to stoixeio x 64 | meta to stoixeio pou deixnei o p */ 65 | int CL_insert_after(LIST_PTR p,elem x) 66 | { 67 | LIST_PTR newnode; 68 | 69 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 70 | if (!newnode) 71 | { 72 | printf("Adynamia desmeusis mnimis"); 73 | return FALSE; 74 | } 75 | newnode->data=x; 76 | 77 | newnode->next=p->next; 78 | p->next=newnode; 79 | return TRUE; 80 | } 81 | 82 | /* CL_delete_start(): Diagrafei ton komvo poy deixnei 83 | i kefali tis listas */ 84 | int CL_delete_start(LIST_PTR *head, elem *x) 85 | { 86 | LIST_PTR next, last; 87 | 88 | // 0 stoixeia 89 | if (*head==NULL) 90 | return FALSE; 91 | 92 | // 1 stoixeio 93 | if (*head==(*head)->next) 94 | { 95 | *x=(*head)->data; 96 | free(*head); 97 | *head=NULL; 98 | return TRUE; 99 | } 100 | // >=2 stoixeia 101 | last=(*head)->next; 102 | while (last->next!=(*head)) 103 | last=last->next; 104 | last->next=(*head)->next; 105 | 106 | *x=(*head)->data; 107 | free(*head); 108 | (*head)=last->next; 109 | return TRUE; 110 | } 111 | 112 | /* CL_delete_after(): Diagrafei ton komvo 113 | poy deixnei o current */ 114 | int CL_delete_after(LIST_PTR current, elem *x) 115 | { 116 | LIST_PTR prev = current; 117 | 118 | while (prev->next!=current) 119 | prev=prev->next; 120 | 121 | *x=current->data; 122 | 123 | prev->next=current->next; 124 | free(current); 125 | return TRUE; 126 | } 127 | 128 | /* CL_print(): Typwnei ta periexomena tis listas */ 129 | void CL_print(LIST_PTR head) 130 | { 131 | LIST_PTR current; 132 | 133 | if (head!=NULL) 134 | { 135 | printf("%d ", head->data); 136 | 137 | current=head->next; 138 | while(current!=head) 139 | { 140 | printf("%d ",current->data); 141 | current=current->next; 142 | } 143 | } 144 | } 145 | 146 | /* CL_destroy(): Apodesmeyei to xwro poy exei 147 | desmeusei i lista */ 148 | void CL_destroy(LIST_PTR *head) 149 | { 150 | LIST_PTR ptr; 151 | elem temp; 152 | 153 | while (*head!=NULL) 154 | CL_delete_start(head, &temp); 155 | } 156 | -------------------------------------------------------------------------------- /data_structures_5_ll_variations/askisi1/doubly_linked_list.c: -------------------------------------------------------------------------------- 1 | /* linked_list.c: Kwdikas tis vivliothikis sindedemenis listas */ 2 | #include 3 | #include 4 | #include "doubly_linked_list.h" 5 | 6 | /* DLL_init(): arxikopoiei tin lista */ 7 | void DLL_init(LIST_PTR *head) 8 | { 9 | *head=NULL; 10 | } 11 | 12 | /* DLL_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i lista einai adeia */ 14 | int DLL_empty(LIST_PTR head) 15 | { 16 | return head == NULL; 17 | } 18 | 19 | /* DLL_data(): epistrefei ta dedomena tou komvou 20 | pou deixnei o deiktis p */ 21 | elem DLL_data(LIST_PTR p) 22 | { 23 | return p->data; 24 | } 25 | 26 | /* DLL_insert_start(): Eisagei to stoixeio x 27 | stin arxi tis listas */ 28 | int DLL_insert_start(LIST_PTR *head,elem x) 29 | { 30 | LIST_PTR newnode; 31 | 32 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 33 | if (!newnode) 34 | { 35 | printf("Adynamia desmeusis mnimis"); 36 | return FALSE; 37 | } 38 | newnode->data=x; 39 | 40 | newnode->next=*head; 41 | newnode->prev=NULL; 42 | *head=newnode; 43 | if (newnode->next!=NULL) 44 | newnode->next->prev=newnode; 45 | return TRUE; 46 | } 47 | 48 | /* DLL_insert_after(): Eisagei to stoixeio x 49 | meta to stoixeio pou deixnei o p */ 50 | int DLL_insert_after(LIST_PTR p,elem x) 51 | { 52 | LIST_PTR newnode; 53 | 54 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 55 | if (!newnode) 56 | { 57 | printf("Adynamia desmeusis mnimis"); 58 | return FALSE; 59 | } 60 | newnode->data=x; 61 | 62 | newnode->next=p->next; 63 | newnode->prev=p; 64 | p->next=newnode; 65 | if (p->next!=NULL) 66 | p->next->prev=newnode; 67 | return TRUE; 68 | } 69 | 70 | /* DLL_delete_start(): Diagrafei ton komvo poy deixnei 71 | i kefali tis listas */ 72 | int DLL_delete_start(LIST_PTR *head, elem *x) 73 | { 74 | LIST_PTR current; 75 | 76 | if (*head==NULL) 77 | return FALSE; 78 | 79 | current=*head; 80 | *x=current->data; 81 | 82 | (*head)=(*head)->next; 83 | if ((*head)!=NULL) 84 | (*head)->prev=NULL; 85 | 86 | free(current); 87 | return TRUE; 88 | } 89 | 90 | /* DLL_delete_after(): Diagrafei ton epomeno tou 91 | komvou poy deixnei o prev */ 92 | int DLL_delete_after(LIST_PTR previous, elem *x) 93 | { 94 | LIST_PTR current; 95 | 96 | if (previous->next==NULL) 97 | return FALSE; 98 | 99 | current=previous->next; 100 | *x=current->data; 101 | 102 | previous->next=current->next; 103 | if (current->next!=NULL) 104 | current->next->prev=previous; 105 | 106 | free(current); 107 | return TRUE; 108 | } 109 | 110 | /* DLL_print(): Typwnei ta periexomena mias 111 | syndedemenis listas */ 112 | 113 | void DLL_print(LIST_PTR head) 114 | { 115 | LIST_PTR current; 116 | 117 | current=head; 118 | while(current!=NULL) 119 | { 120 | printf("%d ",current->data); 121 | current=current->next; 122 | } 123 | } 124 | 125 | /* DLL_destroy(): Apodesmeyei to xwro poy exei 126 | desmeusei i lista */ 127 | 128 | void DLL_destroy(LIST_PTR *head) 129 | { 130 | LIST_PTR ptr; 131 | 132 | while (*head!=NULL) 133 | { 134 | ptr=*head; 135 | *head=(*head)->next; 136 | free(ptr); 137 | } 138 | } 139 | 140 | 141 | void DLL_print_reverse(LIST_PTR head) 142 | { 143 | LIST_PTR current; 144 | 145 | if (head!=NULL) 146 | { 147 | current=head; 148 | while (current->next!=NULL) 149 | current=current->next; 150 | 151 | while (current!=head) 152 | { 153 | printf("%d ", current->data); 154 | current=current->prev; 155 | } 156 | printf("%d", head->data); 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /data_structures_10_graph/GraphAdjLists/linked_list.c: -------------------------------------------------------------------------------- 1 | /* linked_list.c: Kwdikas tis vivliothikis sindedemenis listas */ 2 | #include 3 | #include 4 | #include "linked_list.h" 5 | 6 | /* LL_init(): arxikopoiei tin lista */ 7 | void LL_init(LIST_PTR *head) 8 | { 9 | *head=NULL; 10 | } 11 | 12 | /* LL_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i lista einai adeia */ 14 | int LL_empty(LIST_PTR head) 15 | { 16 | return head == NULL; 17 | } 18 | 19 | /* LL_data(): epistrefei ta dedomena tou komvou 20 | pou deixnei o deiktis p */ 21 | elem LL_data(LIST_PTR p) 22 | { 23 | return p->data; 24 | } 25 | 26 | /* LL_insert_start(): Eisagei to stoixeio x 27 | stin arxi tis listas */ 28 | int LL_insert_start(LIST_PTR *head,elem x) 29 | { 30 | LIST_PTR newnode; 31 | 32 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 33 | if (!newnode) 34 | { 35 | printf("Adynamia desmeusis mnimis"); 36 | return FALSE; 37 | } 38 | newnode->data=x; 39 | newnode->next=*head; 40 | *head=newnode; 41 | return TRUE; 42 | } 43 | 44 | /* LL_insert_after(): Eisagei to stoixeio x 45 | meta to stoixeio pou deixnei o p */ 46 | int LL_insert_after(LIST_PTR p,elem x) 47 | { 48 | LIST_PTR newnode; 49 | 50 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 51 | if (!newnode) 52 | { 53 | printf("Adynamia desmeusis mnimis"); 54 | return FALSE; 55 | } 56 | newnode->data=x; 57 | 58 | newnode->next=p->next; 59 | p->next=newnode; 60 | return TRUE; 61 | } 62 | 63 | /* LL_delete_start(): Diagrafei ton komvo poy deixnei 64 | i kefali tis listas */ 65 | int LL_delete_start(LIST_PTR *head, elem *x) 66 | { 67 | LIST_PTR current; 68 | 69 | if (*head==NULL) 70 | return FALSE; 71 | 72 | current=*head; 73 | *x=current->data; 74 | 75 | (*head)=(*head)->next; 76 | free(current); 77 | return TRUE; 78 | } 79 | 80 | /* LL_delete_after(): Diagrafei ton epomeno tou 81 | komvou poy deixnei o prev */ 82 | int LL_delete_after(LIST_PTR prev, elem *x) 83 | { 84 | LIST_PTR current; 85 | 86 | if (prev->next==NULL) 87 | return FALSE; 88 | 89 | current=prev->next; 90 | *x=current->data; 91 | 92 | prev->next=current->next; 93 | free(current); 94 | return TRUE; 95 | } 96 | 97 | /* LL_print(): Typwnei ta periexomena mias 98 | syndedemenis listas */ 99 | 100 | void LL_print(LIST_PTR head) 101 | { 102 | LIST_PTR current; 103 | 104 | current=head; 105 | while(current!=NULL) 106 | { 107 | printf("%d ",current->data); 108 | current=current->next; 109 | } 110 | } 111 | 112 | /* LL_destroy(): Apodesmeyei to xwro poy exei 113 | desmeusei i lista */ 114 | 115 | void LL_destroy(LIST_PTR *head) 116 | { 117 | LIST_PTR ptr; 118 | 119 | while (*head!=NULL) 120 | { 121 | ptr=*head; 122 | *head=(*head)->next; 123 | free(ptr); 124 | } 125 | } 126 | 127 | 128 | /* Deytereouses prakseis gia ti domi: grafos */ 129 | /* LL_insert: eisagei taksinomimena ena stoixeio sti lista */ 130 | int LL_insert(LIST_PTR *head, elem x) 131 | { 132 | LIST_PTR prev, cur; 133 | if (*head==NULL) 134 | return LL_insert_start(head, x); 135 | else if (x < (*head)->data) 136 | return LL_insert_start(head, x); 137 | else 138 | { 139 | cur = *head; 140 | while(1) 141 | { 142 | if (x==cur->data) 143 | { 144 | printf("H akmh yparxei hdh"); 145 | return FALSE; 146 | } 147 | else if (x>cur->data) 148 | { 149 | prev=cur; 150 | cur=cur->next; 151 | if (cur==NULL) 152 | return LL_insert_after(prev,x); 153 | } 154 | else // x < cur.data 155 | return LL_insert_after(prev, x); 156 | } 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/exercise02/linked_list.c: -------------------------------------------------------------------------------- 1 | /* linked_list.c: Kwdikas tis vivliothikis sindedemenis listas */ 2 | #include 3 | #include 4 | #include "linked_list.h" 5 | 6 | /* LL_init(): arxikopoiei tin lista */ 7 | void LL_init(LIST_PTR *head) 8 | { 9 | *head=NULL; 10 | } 11 | 12 | /* LL_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i lista einai adeia */ 14 | int LL_empty(LIST_PTR head) 15 | { 16 | return head == NULL; 17 | } 18 | 19 | /* LL_data(): epistrefei ta dedomena tou komvou 20 | pou deixnei o deiktis p */ 21 | elem LL_data(LIST_PTR p) 22 | { 23 | return p->data; 24 | } 25 | 26 | /* LL_insert_start(): Eisagei to stoixeio x 27 | stin arxi tis listas */ 28 | int LL_insert_start(LIST_PTR *head,elem x) 29 | { 30 | LIST_PTR newnode; 31 | 32 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 33 | if (!newnode) 34 | { 35 | printf("Adynamia desmeusis mnimis"); 36 | return FALSE; 37 | } 38 | newnode->data=x; 39 | newnode->next=*head; 40 | *head=newnode; 41 | return TRUE; 42 | } 43 | 44 | /* LL_insert_after(): Eisagei to stoixeio x 45 | meta to stoixeio pou deixnei o p */ 46 | int LL_insert_after(LIST_PTR p,elem x) 47 | { 48 | LIST_PTR newnode; 49 | 50 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 51 | if (!newnode) 52 | { 53 | printf("Adynamia desmeusis mnimis"); 54 | return FALSE; 55 | } 56 | newnode->data=x; 57 | 58 | newnode->next=p->next; 59 | p->next=newnode; 60 | return TRUE; 61 | } 62 | 63 | /* LL_delete_start(): Diagrafei ton komvo poy deixnei 64 | i kefali tis listas */ 65 | int LL_delete_start(LIST_PTR *head, elem *x) 66 | { 67 | LIST_PTR current; 68 | 69 | if (*head==NULL) 70 | return FALSE; 71 | 72 | current=*head; 73 | *x=current->data; 74 | 75 | (*head)=(*head)->next; 76 | free(current); 77 | return TRUE; 78 | } 79 | 80 | /* LL_delete_after(): Diagrafei ton epomeno tou 81 | komvou poy deixnei o prev */ 82 | int LL_delete_after(LIST_PTR prev, elem *x) 83 | { 84 | LIST_PTR current; 85 | 86 | if (prev->next==NULL) 87 | return FALSE; 88 | 89 | current=prev->next; 90 | *x=current->data; 91 | 92 | prev->next=current->next; 93 | free(current); 94 | return TRUE; 95 | } 96 | 97 | /* LL_print(): Typwnei ta periexomena mias 98 | syndedemenis listas */ 99 | 100 | void LL_print(LIST_PTR head) 101 | { 102 | LIST_PTR current; 103 | 104 | current=head; 105 | while(current!=NULL) 106 | { 107 | printf("%d ",current->data); 108 | current=current->next; 109 | } 110 | } 111 | 112 | /* LL_destroy(): Apodesmeyei to xwro poy exei 113 | desmeusei i lista */ 114 | 115 | void LL_destroy(LIST_PTR *head) 116 | { 117 | LIST_PTR ptr; 118 | 119 | while (*head!=NULL) 120 | { 121 | ptr=*head; 122 | *head=(*head)->next; 123 | free(ptr); 124 | } 125 | } 126 | 127 | 128 | /* Deytereouses prakseis gia ti domi: grafos */ 129 | /* LL_insert: eisagei taksinomimena ena stoixeio sti lista */ 130 | int LL_insert(LIST_PTR *head, elem x) 131 | { 132 | LIST_PTR prev, cur; 133 | if (*head==NULL) 134 | return LL_insert_start(head, x); 135 | else if (x < (*head)->data) 136 | return LL_insert_start(head, x); 137 | else 138 | { 139 | cur = *head; 140 | while(1) 141 | { 142 | if (x==cur->data) 143 | { 144 | printf("H akmh yparxei hdh"); 145 | return FALSE; 146 | } 147 | else if (x>cur->data) 148 | { 149 | prev=cur; 150 | cur=cur->next; 151 | if (cur==NULL) 152 | return LL_insert_after(prev,x); 153 | } 154 | else // x < cur.data 155 | return LL_insert_after(prev, x); 156 | } 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /data_structures_11_disjoint_sets/DisjointSets(LinkedLists)/linked_list.c: -------------------------------------------------------------------------------- 1 | /* linked_list.c: Kwdikas tis vivliothikis sindedemenis listas */ 2 | #include 3 | #include 4 | #include "linked_list.h" 5 | 6 | /* LL_init(): arxikopoiei tin lista */ 7 | void LL_init(LIST_PTR *head) 8 | { 9 | *head=NULL; 10 | } 11 | 12 | /* LL_empty(): epistrefei TRUE/FALSE 13 | * analoga me to an i lista einai adeia */ 14 | int LL_empty(LIST_PTR head) 15 | { 16 | return head == NULL; 17 | } 18 | 19 | /* LL_data(): epistrefei ta dedomena tou komvou 20 | pou deixnei o deiktis p */ 21 | elem LL_data(LIST_PTR p) 22 | { 23 | return p->data; 24 | } 25 | 26 | /* LL_insert_start(): Eisagei to stoixeio x 27 | stin arxi tis listas */ 28 | int LL_insert_start(LIST_PTR *head,elem x) 29 | { 30 | LIST_PTR newnode; 31 | 32 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 33 | if (!newnode) 34 | { 35 | printf("Adynamia desmeusis mnimis"); 36 | return FALSE; 37 | } 38 | newnode->data=x; 39 | newnode->next=*head; 40 | *head=newnode; 41 | return TRUE; 42 | } 43 | 44 | /* LL_insert_after(): Eisagei to stoixeio x 45 | meta to stoixeio pou deixnei o p */ 46 | int LL_insert_after(LIST_PTR p,elem x) 47 | { 48 | LIST_PTR newnode; 49 | 50 | newnode=(LIST_NODE *)malloc(sizeof(LIST_NODE)); 51 | if (!newnode) 52 | { 53 | printf("Adynamia desmeusis mnimis"); 54 | return FALSE; 55 | } 56 | newnode->data=x; 57 | 58 | newnode->next=p->next; 59 | p->next=newnode; 60 | return TRUE; 61 | } 62 | 63 | /* LL_delete_start(): Diagrafei ton komvo poy deixnei 64 | i kefali tis listas */ 65 | int LL_delete_start(LIST_PTR *head, elem *x) 66 | { 67 | LIST_PTR current; 68 | 69 | if (*head==NULL) 70 | return FALSE; 71 | 72 | current=*head; 73 | *x=current->data; 74 | 75 | (*head)=(*head)->next; 76 | free(current); 77 | return TRUE; 78 | } 79 | 80 | /* LL_delete_after(): Diagrafei ton epomeno tou 81 | komvou poy deixnei o prev */ 82 | int LL_delete_after(LIST_PTR prev, elem *x) 83 | { 84 | LIST_PTR current; 85 | 86 | if (prev->next==NULL) 87 | return FALSE; 88 | 89 | current=prev->next; 90 | *x=current->data; 91 | 92 | prev->next=current->next; 93 | free(current); 94 | return TRUE; 95 | } 96 | 97 | /* LL_print(): Typwnei ta periexomena mias 98 | syndedemenis listas */ 99 | 100 | void LL_print(LIST_PTR head) 101 | { 102 | LIST_PTR current; 103 | 104 | current=head; 105 | while(current!=NULL) 106 | { 107 | printf("%d ",current->data); 108 | current=current->next; 109 | } 110 | } 111 | 112 | /* LL_destroy(): Apodesmeyei to xwro poy exei 113 | desmeusei i lista */ 114 | 115 | void LL_destroy(LIST_PTR *head) 116 | { 117 | LIST_PTR ptr; 118 | 119 | while (*head!=NULL) 120 | { 121 | ptr=*head; 122 | *head=(*head)->next; 123 | free(ptr); 124 | } 125 | } 126 | 127 | 128 | /* Deytereouses prakseis gia ti domi: grafos */ 129 | /* LL_insert: eisagei taksinomimena ena stoixeio sti lista */ 130 | int LL_insert(LIST_PTR *head, elem x) 131 | { 132 | LIST_PTR prev, cur; 133 | if (*head==NULL) 134 | return LL_insert_start(head, x); 135 | else if (x < (*head)->data) 136 | return LL_insert_start(head, x); 137 | else 138 | { 139 | cur = *head; 140 | while(1) 141 | { 142 | if (x==cur->data) 143 | { 144 | printf("H akmh yparxei hdh"); 145 | return FALSE; 146 | } 147 | else if (x>cur->data) 148 | { 149 | prev=cur; 150 | cur=cur->next; 151 | if (cur==NULL) 152 | return LL_insert_after(prev,x); 153 | } 154 | else // x < cur.data 155 | return LL_insert_after(prev, x); 156 | } 157 | } 158 | } 159 | --------------------------------------------------------------------------------