Skip to content

Commit cdbb119

Browse files
jar3mBlindCentaur
andauthored
Heaps (#19)
* Logs - Added Array based Circular Queues * Commit Logs - Enabled heaps - Array based heap support enabled - Heap operations such as Heapify and delete max tested - Heap Sort tested * Tested heap insert and heap delete root operations * Added #define Flags for Data Structures * Logs - Added Array based Circular Queues * Added generic print for queue * Commit Logs - Enabled heaps - Array based heap support enabled - Heap operations such as Heapify and delete max tested - Heap Sort tested * Tested heap insert and heap delete root operations * Added #define Flags for Data Structures * Added generic print for heaps and bug fix of heap ptr not being set * q peek added and fn gent ptrs added * changed to genric fn ptrs * Cosmetic changes for Heaps to enable Doxygen * Squashed commit of the following: commit f4377ef Author: Meraj <[email protected]> Date: Fri Jul 2 01:11:53 2021 +0530 Update README.md Build and run commands commit 93ce3e7 Author: Meraj <[email protected]> Date: Fri Jul 2 01:02:16 2021 +0530 Queues (#17) * Logs - Added Array based Circular Queues * Logs - Added Array based Circular Queues * Added generic print for queue * q peek added and fn gent ptrs added * Squashed commit of the following: commit 151df29 Author: BlindCentaur <[email protected]> Date: Mon Jun 14 23:15:53 2021 +0530 Added functions for Link list based stacks commit aa327c3 Merge: 640429c 9a3759b Author: BlindCentaur <[email protected]> Date: Mon Jun 14 21:48:11 2021 +0530 Merge branch 'link_list' into stacks commit 9a3759b Author: jar3m <[email protected]> Date: Mon Jun 14 21:38:25 2021 +0530 moved destroy to end commit de18fc1 Author: BlindCentaur <[email protected]> Date: Sat Jun 12 01:03:29 2021 +0530 rectified del_idx and added tests, WIP: Circular count is incorrect commit d5adfab Author: jar3m <[email protected]> Date: Wed Jun 9 10:48:21 2021 +0530 added function ptr for destroy and print in linklist commit 12990f5 Author: BlindCentaur <[email protected]> Date: Tue Jun 8 22:41:14 2021 +0530 print for XOR LL and fixed compilation issues commit a8da18d Author: BlindCentaur <[email protected]> Date: Thu Jun 3 23:55:01 2021 +0530 fixed xor ll delete commit 5f393cc Author: BlindCentaur <[email protected]> Date: Mon May 31 16:12:24 2021 +0530 WIP : Added index delete and xor based linked list commit 8fd459a Author: jar3m <[email protected]> Date: Sun May 30 15:40:30 2021 +0530 Generic ptr compare added to link list commit e80c089 Author: jar3m <[email protected]> Date: Fri May 21 19:19:53 2021 +0530 cosmetics * Cosmetic changes for Queues to enable Doxygen * Enabled link list based queue * Added Doxygen for queues Co-authored-by: BlindCentaur <[email protected]> Co-authored-by: jar3m <[email protected]> commit a334403 Merge: a7e5b0d 8921cbc Author: jar3m <[email protected]> Date: Thu Jul 1 23:34:08 2021 +0530 Merge branch 'stacks' commit 8921cbc Merge: 071f86a a7e5b0d Author: jar3m <[email protected]> Date: Thu Jul 1 23:33:24 2021 +0530 Merge branch 'master' into stacks commit 071f86a Author: jar3m <[email protected]> Date: Thu Jul 1 00:11:53 2021 +0530 Enabled Doxygen commit 33269f9 Author: jar3m <[email protected]> Date: Wed Jun 30 23:56:50 2021 +0530 Cosmetics and Merge Master commit a7e5b0d Author: Meraj <[email protected]> Date: Wed Jun 30 23:27:37 2021 +0530 Link List & Common Libs (#15) * Configuring build for link -list * Added struct def to linklist * Commit Logs - Added backtrace on coredump - changed declaration of del_mem to free_mem - added/cleaned up link_list struct and function def * Create/destroy Link List api' * Defs.make updated to select tuning params * moved t_elem datatype to common * Added get_node and added rule for stacks * Add end fn (append) defined for SLL,DLL,SCLL,DCLL * added add_begin functions for SLL,DLL,SCLL,DCLL * Stack structure definition * stack source file created * added full, empty and size fn declartions to stacks * adding delete functions to link list * Stack structure definition * stack source file created * added full, empty and size fn declartions to stacks * updated stack structure * - Cosmetic changes: Added Function headers and comments - Bug fixed in Add begin tail ptr not being updated - Tail & Head ptr not set to NULL in after del resulting in empty list causing corruption of data on reusing the list * COMMIT DETAILS - Enabled Generic support for link list - Added generic_def.h/c as helper functions for data type generic lists - Added Comments - Test file updated to show link list of diff types such as char, int, float and string - All link list operations are now data type independent * Commit Logs - Fixed bug in delete in SLL * Moved free fn ptr defn to typedefs.h * Added generic print for data * changed generic fn routines * cosmetics * Generic ptr compare added to link list * WIP : Added index delete and xor based linked list * fixed xor ll delete * print for XOR LL and fixed compilation issues * added function ptr for destroy and print in linklist * rectified del_idx and added tests, WIP: Circular count is incorrect * moved destroy to end * Commit Logs - Added new struct to be passed along create that populates data type spefic fn ptrs required for maintaining data struct - two different links for just printing the data and the other for getting detailed info of linklist inlcuding count , addresses and links * Commit Logs - Added generic fn ptrs - Defined get head, tail, end, next and prv fn ptrs in ll struct implementation to be done - defined get and find node struct in ll - fn names changed and cosmetic changes * * defined api's for ll head, tail, end, prev and next * changed destroy and print api's using head, end and next ll routines * TODO implement the above 2 points for xor link list * cosmetics funtion headers and indentations * Added get next and prev for xor ll. works only when iterating from start to end o f list not otherwise Del node and del i th node in xor ll need to be debugged * added find function for linked list * added get ith node function in the linked list * Cosmetic changes for Doxygen support - Added function headers - Added Structure feild descriptions - Added File headers - Added Macro and Enums description comments * Added util api for printing link_list type * Del node xor list fixed * cosmetics * added delete index for xor link list * Test link list clean up * Added Link list get data routine Co-authored-by: BlindCentaur <[email protected]> commit 6c911e5 Author: jar3m <[email protected]> Date: Tue Jun 29 22:10:41 2021 +0530 Stack Cleanup & Cosmetics commit 7320cf3 Author: jar3m <[email protected]> Date: Tue Jun 29 21:23:18 2021 +0530 Squashed commit of the following: commit 5cfadc0 Author: BlindCentaur <[email protected]> Date: Sun Jun 27 20:59:00 2021 +0530 added delete index for xor link list commit c3f0fa8 Author: jar3m <[email protected]> Date: Sun Jun 27 19:47:11 2021 +0530 cosmetics commit db91b61 Author: jar3m <[email protected]> Date: Sun Jun 27 19:35:55 2021 +0530 Del node xor list fixed commit 14e1fa6 Author: jar3m <[email protected]> Date: Sat Jun 26 00:35:56 2021 +0530 Added util api for printing link_list type commit c8d0022 Author: jar3m <[email protected]> Date: Fri Jun 25 01:18:01 2021 +0530 Cosmetic changes for Doxygen support - Added function headers - Added Structure feild descriptions - Added File headers - Added Macro and Enums description comments commit 0902742 Author: kamalakannan-s <[email protected]> Date: Thu Jun 24 00:34:30 2021 -0700 added get ith node function in the linked list commit c3001d0 Author: kamalakannan-s <[email protected]> Date: Wed Jun 23 23:58:07 2021 -0700 added find function for linked list commit 0dffa25 Author: jar3m <[email protected]> Date: Thu Jun 24 01:22:25 2021 +0530 Added get next and prev for xor ll. works only when iterating from start to end o f list not otherwise Del node and del i th node in xor ll need to be debugged commit 7360706 Author: jar3m <[email protected]> Date: Wed Jun 23 01:01:09 2021 +0530 * defined api's for ll head, tail, end, prev and next * changed destroy and print api's using head, end and next ll routines * TODO implement the above 2 points for xor link list * cosmetics funtion headers and indentations commit 4a0f4f3 Author: jar3m <[email protected]> Date: Sun Jun 20 23:02:16 2021 +0530 Commit Logs - Added generic fn ptrs - Defined get head, tail, end, next and prv fn ptrs in ll struct implementation to be done - defined get and find node struct in ll - fn names changed and cosmetic changes commit 8ebd61f Author: jar3m <[email protected]> Date: Sun Jun 20 12:54:47 2021 +0530 Commit Logs - Added new struct to be passed along create that populates data type spefic fn ptrs required for maintaining data struct - two different links for just printing the data and the other for getting detailed info of linklist inlcuding count , addresses and links commit 4519c94 Author: jar3m <[email protected]> Date: Sat Jun 26 22:36:22 2021 +0530 Changed routine name commit f3b5339 Author: jar3m <[email protected]> Date: Sat Jun 26 00:37:41 2021 +0530 cosmetics indentation commit ee10cdb Author: jar3m <[email protected]> Date: Sat Jun 26 00:27:53 2021 +0530 Cosmetic changes for Stacks to enable Doxygen commit 151df29 Author: BlindCentaur <[email protected]> Date: Mon Jun 14 23:15:53 2021 +0530 Added functions for Link list based stacks commit aa327c3 Merge: 640429c 9a3759b Author: BlindCentaur <[email protected]> Date: Mon Jun 14 21:48:11 2021 +0530 Merge branch 'link_list' into stacks commit 9a3759b Author: jar3m <[email protected]> Date: Mon Jun 14 21:38:25 2021 +0530 moved destroy to end commit de18fc1 Author: BlindCentaur <[email protected]> Date: Sat Jun 12 01:03:29 2021 +0530 rectified del_idx and added tests, WIP: Circular count is incorrect commit d5adfab Author: jar3m <[email protected]> Date: Wed Jun 9 10:48:21 2021 +0530 added function ptr for destroy and print in linklist commit 12990f5 Author: BlindCentaur <[email protected]> Date: Tue Jun 8 22:41:14 2021 +0530 print for XOR LL and fixed compilation issues commit a8da18d Author: BlindCentaur <[email protected]> Date: Thu Jun 3 23:55:01 2021 +0530 fixed xor ll delete commit 5f393cc Author: BlindCentaur <[email protected]> Date: Mon May 31 16:12:24 2021 +0530 WIP : Added index delete and xor based linked list commit 8fd459a Author: jar3m <[email protected]> Date: Sun May 30 15:40:30 2021 +0530 Generic ptr compare added to link list commit e80c089 Author: jar3m <[email protected]> Date: Fri May 21 19:19:53 2021 +0530 cosmetics Co-authored-by: Harshadeva P <[email protected]>
1 parent f4377ef commit cdbb119

10 files changed

Lines changed: 406 additions & 21 deletions

File tree

Defs.make

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ SEGFAULT_BACKTRACE=true
2121
LINK_LIST=true
2222
STACK=true
2323
QUEUE=true
24+
HEAP=true
25+
TREE=true
26+
27+
#data struct define
28+
DS_FLAGS = -DLINK_LIST=$(LINK_LIST) -DSTACK=$(STACK) \
29+
-DQUEUE=$(QUEUE) -DHEAP=$(HEAP) -DTREE=$(TREE)
30+
2431

2532
.show:
2633
@echo "PROJ_PATH= $(PROJ_PATH)"
@@ -30,3 +37,5 @@ QUEUE=true
3037
@echo "LINK_LIST= $(LINK_LIST)"
3138
@echo "STACKS= $(STACK)"
3239
@echo "QUEUES= $(QUEUE)"
40+
@echo "HEAPS= $(HEAP)"
41+
@echo "TREES= $(TREE)"

Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
include Defs.make
22

33
CC=gcc
4+
CFLAGS+=$(DS_FLAGS)
5+
LDLIBS= -lm -pg
6+
47
TEST_FILE_DIRECTORY="$(PROJ_PATH)/test/src"
58

6-
LDLIBS= -lm -pg
79
ifeq ($(SEGFAULT_BACKTRACE), true)
810
LDLIBS+=-rdynamic
911
endif
@@ -16,7 +18,6 @@ ds_ARCHIVE=$(PROJ_PATH)/ds/bin/ds.a
1618
algo_ARCHIVE=$(PROJ_PATH)/algo/bin/algo.a
1719
test_ARCHIVE=$(PROJ_PATH)/test/bin/test.a
1820

19-
MODULE_ARCHIVES += $(common_ARCHIVE)
2021

2122
ifeq ($(MODULE), ds)
2223
MODULE_ARCHIVES += $(ds_ARCHIVE)
@@ -27,15 +28,16 @@ MODULE_ARCHIVES += $(algo_ARCHIVE)
2728
endif
2829

2930
ifeq ($(MODULE), test)
30-
MODULE_ARCHIVES += $(ds_ARCHIVE)
3131
MODULE_ARCHIVES += $(test_ARCHIVE)
32+
MODULE_ARCHIVES += $(ds_ARCHIVE)
3233
endif
3334

3435
ifeq ($(MODULE), all)
35-
MODULE_ARCHIVES += $(algo_ARCHIVE)
36-
MODULE_ARCHIVES += $(ds_ARCHIVE)
3736
MODULE_ARCHIVES += $(test_ARCHIVE)
37+
MODULE_ARCHIVES += $(ds_ARCHIVE)
38+
MODULE_ARCHIVES += $(algo_ARCHIVE)
3839
endif
40+
MODULE_ARCHIVES += $(common_ARCHIVE)
3941

4042
export
4143

common/inc/common.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ typedef struct data_params {
2424
f_assign assign; ///< Routine used for creating memory for storing the data
2525
f_swap swap; ///< Routine used for swaping two elemnts of goven data
2626
f_free free; ///< Routine used for freeing elements of said data
27-
f_cmp_idx cmp_idx; ///< Routine used for comparing elems in given array indicies
28-
f_swp_idx swp_idx; ///< Routine used for swapring elems in given array indicies
29-
f_cpy_idx cpy_idx; ///< Routine used for copying elems in given array indicies
27+
28+
f_cmp_idx cmpr_idx; ///< Routine used for comparing elems in given array indicies
29+
f_swp_idx swap_idx; ///< Routine used for swapring elems in given array indicies
30+
f_cpy_idx copy_idx; ///< Routine used for copying elems in given array indicies
31+
3032
f_get_idx get_idx; ///< Routine used for getting elem in given array index
3133
f_print print_data; ///< Routine used for printing elem data
3234
} t_dparams;

common/src/common.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ void init_data_params(t_dparams *prms, e_data_types data_type)
1919
//char list;
2020
prms->cmpr = compare_char;
2121
prms->swap = swap_char;
22-
prms->cmp_idx = compare_idx_char;
23-
prms->swp_idx = swap_idx_char;
24-
prms->cpy_idx = copy_idx_char;
22+
prms->cmpr_idx = compare_idx_char;
23+
prms->swap_idx = swap_idx_char;
24+
prms->copy_idx = copy_idx_char;
2525
prms->get_idx = get_idx_char;
2626
prms->print_data = print_char;
2727
prms->free = FREE_MEM;
@@ -30,9 +30,9 @@ void init_data_params(t_dparams *prms, e_data_types data_type)
3030
//int list;
3131
prms->cmpr = compare_int;
3232
prms->swap = swap_int;
33-
prms->cmp_idx = compare_idx_int;
34-
prms->swp_idx = swap_idx_int;
35-
prms->cpy_idx = copy_idx_int;
33+
prms->cmpr_idx = compare_idx_int;
34+
prms->swap_idx = swap_idx_int;
35+
prms->copy_idx = copy_idx_int;
3636
prms->get_idx = get_idx_int;
3737
prms->print_data = print_int;
3838
prms->free = FREE_MEM;
@@ -41,9 +41,9 @@ void init_data_params(t_dparams *prms, e_data_types data_type)
4141
//float list;
4242
prms->cmpr = compare_float;
4343
prms->swap = swap_float;
44-
prms->cmp_idx = compare_idx_float;
45-
prms->swp_idx = swap_idx_float;
46-
prms->cpy_idx = copy_idx_float;
44+
prms->cmpr_idx = compare_idx_float;
45+
prms->swap_idx = swap_idx_float;
46+
prms->copy_idx = copy_idx_float;
4747
prms->get_idx = get_idx_float;
4848
prms->print_data = print_float;
4949
prms->free = FREE_MEM;

ds/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
link_list_ARCHIVE=$(PROJ_PATH)/ds/link_list/link_list.o
33
stack_ARCHIVE=$(PROJ_PATH)/ds/stack/stack.o
44
queue_ARCHIVE=$(PROJ_PATH)/ds/queue/queue.o
5+
heap_ARCHIVE=$(PROJ_PATH)/ds/heap/heap.o
6+
57
ds_ARCHIVE=$(PROJ_PATH)/ds/bin/ds.a
68

79
export
@@ -21,10 +23,15 @@ INCLUDES += -I $(PROJ_PATH)/ds/queue/
2123
sub_ARCHIVE += $(queue_ARCHIVE)
2224
endif
2325

26+
ifeq ($(HEAP), true)
27+
INCLUDES += -I $(PROJ_PATH)/ds/heap/
28+
sub_ARCHIVE += $(heap_ARCHIVE)
29+
endif
30+
2431
all: $(ds_ARCHIVE)
25-
@echo "building $(ds_ARCHIVE) from $(sub_ARCHIVE)"
2632

2733
$(ds_ARCHIVE): $(sub_ARCHIVE)
34+
@echo "building $(ds_ARCHIVE) from $(sub_ARCHIVE)"
2835
ar rcs $(ds_ARCHIVE) $(sub_ARCHIVE)
2936
# cp $(sub_ARCHIVE) $(ds_ARCHIVE)
3037

@@ -37,6 +44,9 @@ $(stack_ARCHIVE) :
3744
$(queue_ARCHIVE) :
3845
make -C queue/ all
3946

47+
$(heap_ARCHIVE) :
48+
make -C heap/ all
49+
4050
clean:
4151
rm -rf $(ds_ARCHIVE) $(sub_ARCHIVE)
4252

ds/heap/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
heap_SRC=heap.c
2+
heap_OBJ=heap.o
3+
4+
OBJS=$(heap_OBJ)
5+
6+
all: $(OBJS)
7+
8+
$(heap_OBJ): $(heap_SRC)
9+
$(CC) $(INCLUDES) -c $^ $(CFLAGS)
10+
11+
12+
.PHONY: clean
13+
14+
clean:
15+
rm -rf $(heap_ARCHIVE) $(OBJS)

0 commit comments

Comments
 (0)