-
Notifications
You must be signed in to change notification settings - Fork 0
yew011/Sparse_Array
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Sparse_Array This project aims to implement the sparse array in C. Sparse array is defined as a data structure that is sparsely filled. We want to be able to access the array via indices. And the complexity of indexing should be constant. Design: Trie is used. Assume the index is by a unsigned int array (32-bit). Therein, each 8 bits are used for selecting the nodes in next level. e.g. bits 0-7 are used to select among the 256 children of root, bits 8-15 are used to select among the children of next level. The data structure is designed as follow: struct Trie{ union Content { struct Trie **children_; int value_; }content_; }; There will be 5 functions designed (pseudocode) as follows: construct_trie_( ) : constructor function === create the root node of the trie and initialized the pointers to NULL. destruct_trie_( struct Trie * ) : destruct all dynamically created variables === post order traversal and free the dynamically allocated memory. insert_( struct Trie *, index, value ) : insert or update the value at the provided index === check the passed in parameters === check from the root (level 0) to the corresponding leaf. if any node is not === created, create it (malloc). if the node has no children, create 256 children === and assign the pointer to the pointer (trie ** children). get_( struct Trie *, index ) : return the value at the provided index === check the exsitance of element, if existed, return the value, otherwise, return -1 iterate( struct Trie * ) : iterate through the sparse array and print the elements ============
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published