Data Structures

Queues:

It follow a FIFO (First-In-First-Out) property.
It has 2 operations:
- Enqueue
- Dequeue

Enqueue code:

const int CAPACITY = 50;

typedef struct
{
	person people[CAPACITY];
	int size;
} queue;
Stack

It follows a LIFO property (last-in-first-out). (Gmail -->Where new emails end up at the top)
It was 2 properties:

const int CAPACITY = 50;

typedef struct
{
	person people[CAPACITY];
	int size;
} stack;

Same as the queue implementation , but because the last element will finish at index 0 of the array, it will be easier to pop and push.

dictionaries

Another abstract data type that follow a key-value type of association, which is its main property.

array

A chuck of memory where values can be stored contiguously.
(Exercises start from list.c)

hardcoded array:

#include <stdio.h>

int main(void)
{
    int list[4];
    list[0] = 1;
    list[1] = 2;
    list[2] = 3;
    list[3] = 4;
    
    for (int i = 0; i < 4; i++)
    {
        printf("%i\n", list[i]);
    }
}
Powered by Forestry.md