Skip to content

42-Madrid-HUB/Data_Structures_Lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

13 Essential Data Structures in C

image

This repository contains implementations of the 13 fundamental data structures in C. These structures are crucial for a variety of algorithms and real-world applications. Each directory contains an implementation of a specific data structure along with an example of how to use it. Below is a brief description of each data structure.

Table of Contents

  • 2D Array
  • AST Tree
  • Array
  • Double Linked List
  • Graph
  • HashMap
  • HashSet
  • Linked List
  • Max Heap
  • Queue
  • Stack
  • Tree
  • Trie

2D Array

Description:

A 2D array is a collection of elements organized in rows and columns. It can be seen as an array of arrays and is commonly used to represent matrices or tables.

Files:

  • 2D_array.h: Header file with the structure and functions for a 2D array.
  • Example_1.c: Example usage of the 2D array.

AST Tree

Description:

An Abstract Syntax Tree (AST) is a tree representation of the structure of code. Each node in the AST represents a construct from the source code (e.g., expressions, variables, operations). It is widely used in compilers and interpreters for code analysis.

Files:

  • ast_tree.h: Header file for the AST tree structure.
  • Example_1.c: Example showing how to create and manipulate an AST.

Array

Description:

An array is a collection of elements, all of the same type, stored at contiguous memory locations. It is one of the most basic data structures and is used for storing lists of items.

Files:

  • Array.h: Header file defining the array structure and related functions.
  • Example_1.c: Example usage of arrays.

Double Linked List

Description:

A doubly linked list is a type of linked list where each node contains a reference to both the next and previous node. This structure allows traversal in both directions.

Files:

  • doubly_linked_list.h: Header file defining the doubly linked list structure.
  • Example_1.c: Example usage of the doubly linked list.

Graph

Description:

A graph is a collection of nodes (vertices) and edges connecting pairs of nodes. It is used to represent relationships between objects, such as social networks, routing algorithms, etc.

Files:

  • graph.h: Header file defining the graph structure.
  • Example_1.c: Example demonstrating graph traversal.

HashMap

Description:

A HashMap (or hash table) is a data structure that stores key-value pairs. It uses a hash function to compute an index (hash) into an array of buckets or slots, from which the desired value can be found.

Files:

  • HashMap.h: Header file defining the hash map structure.
  • Example_1.c: Example showing how to use a hash map.

HashSet

Description:

A HashSet is a set data structure implemented using a hash map. It allows for efficient membership checking, insertion, and deletion of unique items.

Files:

  • HashSet.h: Header file for the hash set structure.
  • Example_1.c: Example demonstrating operations on a hash set.

Linked List

Description:

A linked list is a linear data structure where each element (node) contains a value and a reference to the next node. It is efficient for inserting or deleting elements at arbitrary positions.

Files:

  • linked_list.h: Header file defining the linked list structure.
  • Example_1.c: Example usage of a linked list.

Max Heap

Description:

A Max Heap is a binary tree-based data structure where the value of each node is greater than or equal to the values of its children. It is commonly used in priority queues.

Files:

  • Max_Heap.h: Header file defining the max heap structure.
  • Example_1.c: Example showing how to use a max heap.

Queue

Description:

A queue is a linear data structure that follows the FIFO (First In, First Out) principle. It is used in scenarios like task scheduling, managing requests, etc.

Files:

  • queue.h: Header file defining the queue structure.
  • Example_1.c: Example demonstrating queue operations.

Stack

Description:

A stack is a linear data structure that follows the LIFO (Last In, First Out) principle. It is used in scenarios such as expression evaluation, backtracking, and function call management.

Files:

  • stack.h: Header file for the stack structure.
  • Example_1.c: Example usage of a stack.

Tree

Description:

A tree is a hierarchical data structure where each node has a value and zero or more children. It is widely used in file systems, databases, and parsing expressions.

Files:

  • tree.h: Header file defining the tree structure.
  • Example_1.c: Example usage of tree operations.

Trie

Description:

A Trie (or prefix tree) is a tree-like data structure used to efficiently store and retrieve strings. It is often used in autocomplete systems and dictionary implementations.

Files:

  • trie.h: Header file defining the trie structure.
  • Example_1.c: Example usage of a trie.

Extras

This repository serves as a valuable resource for anyone looking to deepen their understanding of essential data structures and their implementation in C. The 13 core data structures included—ranging from arrays and linked lists to more complex structures like graphs and tries—are fundamental building blocks for solving a wide variety of algorithmic challenges and real-world problems. Whether you're building compilers, managing memory efficiently, or optimizing data retrieval, these structures will provide a solid foundation for your coding skills.

We encourage all members to contribute by expanding upon the examples provided. Each data structure has room for additional functionality, edge cases, and optimizations.

-Born2code 42madrid

About

The 13 main Data Structures

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages