Algo - mehul-m-prajapati/python-algorithms GitHub Wiki
Common Operations
- Insert
- Delete
- Update
- Search
Arrays
int num[100];
Linked list
typedef struct node {
int n;
struct node *next;
} node;
Hash map (AKA hash table)
#define MAX_NUM_ALPHA 26
#define LENGTH 32
typedef struct alpha
{
char word[LENGTH];
struct alpha *pNext;
}
node;
// Hash Table (Chaining using linked-list)
node *pTable[MAX_NUM_ALPHA] = { NULL };
Tree
typedef struct node {
int n;
struct node *left;
struct node *right;
} node;
Stack (last-in, first-out)
typedef struct {
int *numbers;
int size;
} stack;
Operations
- Push
- Pop
Queue (first-in, first-out)
typeded struct {
int front;
int *numbers;
int size;
} queue;
Operations
- Enqueue
- Dequeue
A stack and queue are both abstract data types, where we can implement them in any number of different ways but expect the same properties and operations.