Skip to content

hegek87/Data-Structures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository provides a set of basic, generic data structures. These data structures store all data as void pointers and expect certain functions to be provided in order to work properly. It is the programmers responsibility to ensure that the data type stored in a data structure is properly cast.

Below we have more detailed descriptions of the data structures, which include the structure of each element in the data structure. We will describe the type of functions which must be implemented in order for the data structure to work properly.

WARNING WARNING WARNING

Currently it is very important that the directory structure remains as is. We use inlcludes which are based on current and previous directories currently.

Binary Search Tree ----
	Each element in our Binary Search Tree (bst for short) is stored inside  of a node which has a reference to nodes representing the parent node, and a  left, right child. Each node also contains a void pointer to the actual data being stored. The actual tree is represented as an object which points to the root of the tree and manages the size of the tree. The following two functions are required for a proper implementation of a bst:
		typedef int (*comp)(void *, void *);
		typedef void (*print)(void *);
	The print function is provided in a way which allows us to print the tree as preorder, postorder, and inorder. We've provided a default implementatation which assumes integer data, and simply prints the element as if it where an integer. As is normal with a binary tree, we expect for any node x in the tree, the following inequality holds:
			x->left->data < x->data < x->right->data.
	The implementation of the comp function allows the inequality to hold. We must have:
				eq(a,b)  <  0 if a <  b
				eq(a,b)  == 0 if a == b
				eq(a,b)  >  0 if a >  b,
	where eq is of type comp.
	
Double Linked List ----
	Each element in our list is stored in a node containng a previous and next node. As with the bst, we require the print function andcomparison function. The list itself bs_list has a pointer to the head and tail of the list.
	
Linked List ----
	Each element in this singly linked list is contained in a node which has a void * for the data. The node has a link to the next node in the list. We require a comparison function to be defined for the given data type.
	
Hash Table ----
	The hash table stores any element as a void *, we represent the hash table as a list of lists (dl_list **), and we use chaining for elements with the same hash. We require users to define a comparison function to compare two void * as above, as well as a hash function, which tells us where to index into our file.
	
Heap ----
	Depending on how we define HEAP_TYPE, we have a max heap and a min heap. For ease, our heap current stores integer data.
	
Queue ----
	This FIFO queue is represented by a dl_list, and gives operations to remove from the head and insert at the tail.
	
Stack ----
	This stack is LIFO, and is again represented by a dl_list, allowing us to push and pop by inserting and deleting at the head.

About

Data Structures

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published