Data Structures – Full Course Using C and C++



Learn about data structures in this comprehensive course. We will be implementing these data structures in C or C++.

You should have a good understanding of pointers in C. If you need to learn about pointers, watch this course:

✏️ Course developed by Harsha and Animesh from MyCodeSchool.
🔗 Read all about their amazing story here:
🔗 Check out the MyCodeSchool channel:
🔗 Check out the MyCodeSchool website:

❤️ Try interactive Algorithms courses we love, right in your browser: (Made possible by a grant from our friends at Scrimba)

⭐️ Course Contents ⭐️
⌨️ (0:00:00) Introduction to data structures
⌨️ (0:06:33) Data Structures: List as abstract data type
⌨️ (0:19:40) Introduction to linked list
⌨️ (0:36:50) Arrays vs Linked Lists
⌨️ (0:49:05) Linked List – Implementation in C/C++
⌨️ (1:03:02) Linked List in C/C++ – Inserting a node at beginning
⌨️ (1:15:50) Linked List in C/C++ – Insert a node at nth position
⌨️ (1:31:04) Linked List in C/C++ – Delete a node at nth position
⌨️ (1:43:32) Reverse a linked list – Iterative method
⌨️ (1:57:21) Print elements of a linked list in forward and reverse order using recursion
⌨️ (2:11:43) Reverse a linked list using recursion
⌨️ (2:20:38) Introduction to Doubly Linked List
⌨️ (2:27:50) Doubly Linked List – Implementation in C/C++
⌨️ (2:43:09) Introduction to stack
⌨️ (2:51:34) Array implementation of stacks
⌨️ (3:04:42) Linked List implementation of stacks
⌨️ (3:15:39) Reverse a string or linked list using stack.
⌨️ (3:32:03) Check for balanced parentheses using stack
⌨️ (3:46:14) Infix, Prefix and Postfix
⌨️ (3:59:14) Evaluation of Prefix and Postfix expressions using stack
⌨️ (4:14:00) Infix to Postfix using stack
⌨️ (4:32:17) Introduction to Queues
⌨️ (4:41:35) Array implementation of Queue
⌨️ (4:56:33) Linked List implementation of Queue
⌨️ (5:10:48) Introduction to Trees
⌨️ (5:26:37) Binary Tree
⌨️ (5:42:51) Binary Search Tree
⌨️ (6:02:17) Binary search tree – Implementation in C/C++
⌨️ (6:20:52) BST implementation – memory allocation in stack and heap
⌨️ (6:33:55) Find min and max element in a binary search tree
⌨️ (6:39:41) Find height of a binary tree
⌨️ (6:46:50) Binary tree traversal – breadth-first and depth-first strategies
⌨️ (6:58:43) Binary tree: Level Order Traversal
⌨️ (7:10:05) Binary tree traversal: Preorder, Inorder, Postorder
⌨️ (7:24:33) Check if a binary tree is binary search tree or not
⌨️ (7:41:01) Delete a node from Binary Search Tree
⌨️ (7:59:27) Inorder Successor in a binary search tree
⌨️ (8:17:23) Introduction to graphs
⌨️ (8:34:05) Properties of Graphs
⌨️ (8:49:19) Graph Representation part 01 – Edge List
⌨️ (9:03:03) Graph Representation part 02 – Adjacency Matrix
⌨️ (9:17:46) Graph Representation part 03 – Adjacency List

Learn to code for free and get a developer job:

Read hundreds of articles on programming:

source

49 Comments

  1. ⭐ Course Contents ⭐

    ⌨ (0:00:00) Introduction to data structures

    ⌨ (0:06:33) Data Structures: List as abstract data type

    ⌨ (0:19:40) Introduction to linked list

    ⌨ (0:36:50) Arrays vs Linked Lists

    ⌨ (0:49:05) Linked List – Implementation in C/C++

    ⌨ (1:03:02) Linked List in C/C++ – Inserting a node at beginning

    ⌨ (1:15:50) Linked List in C/C++ – Insert a node at nth position

    ⌨ (1:31:04) Linked List in C/C++ – Delete a node at nth position

    ⌨ (1:43:32) Reverse a linked list – Iterative method

    ⌨ (1:57:21) Print elements of a linked list in forward and reverse order using recursion

    ⌨ (2:11:43) Reverse a linked list using recursion

    ⌨ (2:20:38) Introduction to Doubly Linked List

    ⌨ (2:27:50) Doubly Linked List – Implementation in C/C++

    ⌨ (2:43:09) Introduction to stack

    ⌨ (2:51:34) Array implementation of stacks

    ⌨ (3:04:42) Linked List implementation of stacks

    ⌨ (3:15:39) Reverse a string or linked list using stack.

    ⌨ (3:32:03) Check for balanced parentheses using stack

    ⌨ (3:46:14) Infix, Prefix and Postfix

    ⌨ (3:59:14) Evaluation of Prefix and Postfix expressions using stack

    ⌨ (4:14:00) Infix to Postfix using stack

    ⌨ (4:32:17) Introduction to Queues

    ⌨ (4:41:35) Array implementation of Queue

    ⌨ (4:56:33) Linked List implementation of Queue

    ⌨ (5:10:48) Introduction to Trees

    ⌨ (5:26:37) Binary Tree

    ⌨ (5:42:51) Binary Search Tree

    ⌨ (6:02:17) Binary search tree – Implementation in C/C++

    ⌨ (6:20:52) BST implementation – memory allocation in stack and heap

    ⌨ (6:33:55) Find min and max element in a binary search tree

    ⌨ (6:39:41) Find height of a binary tree

    ⌨ (6:46:50) Binary tree traversal – breadth-first and depth-first strategies

    ⌨ (6:58:43) Binary tree: Level Order Traversal

    ⌨ (7:10:05) Binary tree traversal: Preorder, Inorder, Postorder

    ⌨ (7:24:33) Check if a binary tree is binary search tree or not

    ⌨ (7:41:01) Delete a node from Binary Search Tree

    ⌨ (7:59:27) Inorder Successor in a binary search tree

    ⌨ (8:17:23) Introduction to graphs

    ⌨ (8:34:05) Properties of Graphs

    ⌨ (8:49:19) Graph Representation part 01 – Edge List

    ⌨ (9:03:03) Graph Representation part 02 – Adjacency Matrix

    ⌨ (9:17:46) Graph Representation part 03 – Adjacency List

  2. List ADT code in C:

    #include <stdio.h>
    #define SIZE 10

    int append(int *ptr, int index);
    int insert(int *ptr, int index);
    int remove_element(int *ptr, int index);
    void print(int *ptr, int index);

    int main() {

    char op;
    int array[SIZE] = {}, index = -1;

    do {

    printf("nOptions:");
    printf("nn1.> Append.");
    printf("n2.> Insert.");
    printf("n3.> Remove.");
    printf("n4.> Print.");
    printf("n5.> Exit.");
    printf("nnEnter your option: ");

    scanf(" %c", &op);

    switch(op) {

    case '1':
    index = append(array, index);
    break;

    case '2':
    index = insert(array, index);
    break;

    case '3':
    index = remove_element(array, index);
    break;

    case '4':
    print(array, index);
    break;
    }

    } while(op != '5');

    return 0;
    }

    int append(int *ptr, int index) {

    if (index == SIZE – 1) {

    printf("nThe array is full.n");
    return index;
    }

    int num;
    printf("Enter the number to append: ");
    scanf(" %d", &num);

    index++;
    ptr[index] = num;

    return index;
    }

    void print(int *ptr, int index) {

    if (index == -1) {

    printf("nThe array is empty.n");
    return;
    }

    int i;
    printf("n");
    for(i=0;i<=index;i++) {

    printf("%d ",ptr[i]);
    }
    printf("n");
    }

    int insert(int *ptr, int index) {

    if (index == SIZE – 1) {

    printf("nThe array is full.n");
    return index;
    }

    int position;
    do {

    printf("nEnter the position to insert into (0 to %d): ", SIZE – 1);
    scanf(" %d", &position);

    } while(position < 0 || position > SIZE – 1);

    int num;
    printf("nEnter the number: ");
    scanf(" %d", &num);

    if (position > index) {

    ptr[position] = num;
    return position;
    }

    int tmp_index = index;
    while (index >= position) {

    ptr[index + 1] = ptr[index];
    index–;
    }

    ptr[position] = num;
    return tmp_index + 1;
    }

    int remove_element(int *ptr, int index) {

    if (index == -1) {

    printf("nThe array is empty.n");
    return index;
    }

    int position;
    do {
    printf("nEnter the position to remove element from(0 to %d): ", index);
    scanf(" %d", &position);

    } while(position < 0 || position > index);

    while(position < index) {

    ptr[position] = ptr[position + 1];
    position++;
    }
    index–;

    return index;
    }

  3. for the last exercise we could:

    1. encode the string identifiers of the vertices to which we connect ("A" -> 65, "B" -> 66, …)

    2. create a binary search tree where the comparison value is the encoded int value (using the example from earlier: one person can only befriend another person only once, so we have a graph without multi-edges)

    3. store the binary tree as a doubly linked list

    4. searching takes log_2 of n

    5. adding is searching + O(1)

    6. deleting leaf is just removing its address

    7. deleting parent of 1 child: we just put the child in place of the parent (we already preserve a complete tree

    8. deleting parent of 2 children: put the min node of the right subtree in place of the parent (right subtree is preferred because a complete tree would be greater on the left side and we want to keep the tree complete)

    9. we may balance the tree after adding and deleting

    * traverse the current tree inorder -> copying elements into a new array of size n O(n) -> quicksort (nlogn) -> delete the current tree -> create a new tree by picking middle values from the array recursively O(n)

    i may have made an accidental mistake somewhere

  4. Om Shanti 🕉🕉

    If you’re searching for DSA using C, brother, you’re at the right place. No teacher on YouTube has explained the concepts the way Harsha and Animesh have. Mark my words—this course is totally worth your time.

  5. ⭐ Course Contents ⭐

    ⌨ (0:00:00) Introduction to data structures

    ⌨ (0:06:33) Data Structures: List as abstract data type

    ⌨ (0:19:40) Introduction to linked list

    ⌨ (0:36:50) Arrays vs Linked Lists

    ⌨ (0:49:05) Linked List – Implementation in C/C++

    ⌨ (1:03:02) Linked List in C/C++ – Inserting a node at beginning

    ⌨ (1:15:50) Linked List in C/C++ – Insert a node at nth position

    ⌨ (1:31:04) Linked List in C/C++ – Delete a node at nth position

    ⌨ (1:43:32) Reverse a linked list – Iterative method

    ⌨ (1:57:21) Print elements of a linked list in forward and reverse order using recursion

    ⌨ (2:11:43) Reverse a linked list using recursion

    ⌨ (2:20:38) Introduction to Doubly Linked List

    ⌨ (2:27:50) Doubly Linked List – Implementation in C/C++

    ⌨ (2:43:09) Introduction to stack

    ⌨ (2:51:34) Array implementation of stacks

    ⌨ (3:04:42) Linked List implementation of stacks

    ⌨ (3:15:39) Reverse a string or linked list using stack.

    ⌨ (3:32:03) Check for balanced parentheses using stack

    ⌨ (3:46:14) Infix, Prefix and Postfix

    ⌨ (3:59:14) Evaluation of Prefix and Postfix expressions using stack

    ⌨ (4:14:00) Infix to Postfix using stack

    ⌨ (4:32:17) Introduction to Queues

    ⌨ (4:41:35) Array implementation of Queue

    ⌨ (4:56:33) Linked List implementation of Queue

    ⌨ (5:10:48) Introduction to Trees

    ⌨ (5:26:37) Binary Tree

    ⌨ (5:42:51) Binary Search Tree

    ⌨ (6:02:17) Binary search tree – Implementation in C/C++

    ⌨ (6:20:52) BST implementation – memory allocation in stack and heap

    ⌨ (6:33:55) Find min and max element in a binary search tree

    ⌨ (6:39:41) Find height of a binary tree

    ⌨ (6:46:50) Binary tree traversal – breadth-first and depth-first strategies

    ⌨ (6:58:43) Binary tree: Level Order Traversal

    ⌨ (7:10:05) Binary tree traversal: Preorder, Inorder, Postorder

    ⌨ (7:24:33) Check if a binary tree is binary search tree or not

    ⌨ (7:41:01) Delete a node from Binary Search Tree

    ⌨ (7:59:27) Inorder Successor in a binary search tree

    ⌨ (8:17:23) Introduction to graphs

    ⌨ (8:34:05) Properties of Graphs

    ⌨ (8:49:19) Graph Representation part 01 – Edge List

    ⌨ (9:03:03) Graph Representation part 02 – Adjacency Matrix

    ⌨ (9:17:46) Graph Representation part 03 – Adjacency List

  6. 2:20:28

    I think we can't delete the last line of the code, "p->next = NULL" . because it makes the last Node (address: 100) point to NULL!
    can anyone tell me whether I'm right or wrong?

  7. I've learn Data Structure, Algorithms and C from this exact video 5 years ago when I was starting out without a proper CS major. But now, I am building amazing things with it. Got a well respected job. I can't thanks the teacher enough. Hearing he die of accident breaks my heart.

  8. Indian engineers, doctors, scientists and teachers are ruling the world.
    Just see the amount of Indian teachers on YouTube providing high quality free education to people all over the world.

Leave a Reply

Your email address will not be published. Required fields are marked *

You might like

© 2026 Cantinho do Vídeo - WordPress Video Theme by WPEnjoy