(Double) Pointers and How to Use Them Effectively with Linked Data Structures
Welcome back to another video. In this video, I go over a topic I find many students struggle with. And that is pointers, double pointers and how to use them effectively with linked data structures. Find me elsewhere: Instagram: / jeff.no.zhao Github: https://github.com/kamiyaa At a basic level, a pointer is just a non-negative integer. A 32-bit number on a 32-bit system and a 64-bit number on a 64-bit system. But unlike a normal integer, a pointer represents more than just a number. It represents the memory address to another value. Pointers are useful because it allows us to not copy around data and share them instead, increasing performance. It also lets us have 'multiple returns' in C, something other languages take for granted. To get the address of a variable, we use the & symbol. To get the value an address points to, we use the * symbol. One question you might ask is: why are there different pointer types (char *, int *) if they all take up the same amount of space? And this is because by telling C what type of pointer it is, C will know how many bytes to read when we want to get the value our pointer is pointing to. It also lets C automatically do pointer arithmetic. For example, if we do += 1 to an int pointer, C will know to increment it by 4 bytes instead of 1 because it assumes we are incrementing by 1 unit size of int. And if we do += 1 to a char pointer, C will only increment it by 1 byte. A double pointer is just a pointer to a pointer. At face value, you might be wondering why we would ever need a double pointer. And the answer to that is: in linked data structures. In our example where we implemented an insert function for a linked list, the single pointer approach required us to write much more code and code thats much more prone to bugs. Constrast that to the double pointer approach that is significantly shorter and does not have any confusing conditionals. And this is the case for our delete function and our insert function for binary trees. Hope you guys learned something new! The Lean Startup by Eric Ries: https://amzn.to/3hwbg3J Late Bloomers by Rich Karlgaard: https://amzn.to/2DcmCLo Disclaimer, these are affiliate links. If you make a purchase, I will receive a commission. Music: Storybook by lukrembo Michikusa by PeriTune (Licensed under https://creativecommons.org/licenses/...) Timestamps: 0:00 Intro 0:49 What are pointers 1:36 Pointer diagram 2:16 Why do pointers have types 2:56 What are double pointers 3:57 Example 1: Linked List Insertion 9:27 Binary Tree Insertion 9:58 Example 2: Linked List Deletion

Iterators. And Why You Should Use Them (More)

you will never ask about pointers again after watching this video

Queue Data Structure & Operations (Linked List Based) | C Programming Example

What are double pointers in C?

How to Use the Two Pointer Technique

Master Pointers in C: 10X Your C Coding!

C Arrays and Pointers to Pointers

Data Structures Explained for Beginners - How I Wish I was Taught

Triple Ref Pointers - Computerphile

Understanding and implementing a Linked List in C and Java

How to insert a new node in a linked list in C++? (at the front, at the end, after a given node)

Pointers and dynamic memory - stack vs heap

Every Data Structure Simply Explained in 25 Minutes!

why do void* pointers even exist?

I Hacked This Temu Router. What I Found Should Be Illegal.

Project - How to use double pointers to emulate two-dimensional arrays in C. Part 1.

Introduction to Linked Lists, Arrays vs Linked Lists, Advantages/Disadvantages - C++ Data Structures

Introduction to Pointers | C Programming Tutorial

why is it illegal to use "goto"?

