Sorted linked list

  Рет қаралды 16,879

CodeVault

CodeVault

4 жыл бұрын

Check out our Discord server: / discord

Пікірлер: 15
@cryptoWorldever
@cryptoWorldever Жыл бұрын
Your explanations are undoubtedly the best sir, thank you very much.
@udarue
@udarue 7 ай бұрын
very helpful!
@user-vx8me1lu9h
@user-vx8me1lu9h 7 ай бұрын
do you have a video about how to sort a linked list? Because in this video you have already sorted list, but what if you woudn`t?
@CodeVault
@CodeVault 6 ай бұрын
I will look into it
@Miguel-mv5yc
@Miguel-mv5yc 3 жыл бұрын
Once again, excellent content! Thank you for such a great effort, do you have a patreon I could make a contribution to?
@CodeVault
@CodeVault 3 жыл бұрын
Not yet, but expect something like Patreon appearing soon on our website. For the time being we have the store, maybe you fancy buying something from there: code-vault.net/shop
@ahmeta.112
@ahmeta.112 3 жыл бұрын
Hi sir, I wonder what kind of coupling is in this example? Is it ok to use a function within a function? Does it cause a regression effect? I'm just trying to understand.
@CodeVault
@CodeVault 3 жыл бұрын
I'm not sure what you mean by regression effect. Can you elaborate on that?
@jota1858
@jota1858 3 жыл бұрын
you can call a function within a function but you cannot create a function within a function (like nested loops). Here we called a function(instert_beggining) inside insert_sorted that was already created, so not a nested function.
@synacktra
@synacktra 2 жыл бұрын
I still haven't watched this video yet, tried to do it myself: void sorted_insert(Node** root, int vl) { if((*root == NULL) || vl ch)){ //if root is null or value is lesser than or equal to roots' ch member, insert at beginning. beginsert(root, vl); return; } Node* current = *root; Node* aux; while(current->ch < vl && current->next != NULL) { // aux stores the previous node, thanks to your deallocating linked list memory video CodeVault :), // you're a great teacher, I am improving drastically :)) aux = current; current = current->next; } if(current->ch
@CodeVault
@CodeVault 2 жыл бұрын
Looks perfectly fine. Good job!
@zouzou6164
@zouzou6164 2 жыл бұрын
Made my own modification: void insert_sorted(Node** head, int value) { // inserts a node to the list based on its numeric value Node* new_node = malloc(sizeof(Node)); if(new_node == NULL) exit(1); new_node->x = value; new_node->next = NULL; Node* curr = *head; if(*head == NULL) { *head = new_node; return; } while(curr->next != NULL) { if(curr->next->x >= new_node->x) { new_node->next = curr->next; curr->next = new_node; return; } curr = curr->next; } curr->next = new_node; free(new_node); } is this good?
@CodeVault
@CodeVault 2 жыл бұрын
That free(new_node) will break your code. Do not free the memory you are adding to the linked list. Otherwise it looks good
@pauloskalyvas1590
@pauloskalyvas1590 3 жыл бұрын
hi...is this a good way to write it ? void insert_element_in_a_shorted_list(Node** root,int value){ if((*root==NULL) || ((*root)->x >= value) ){ insert_at_the_beginning(root, value); return; } Node* curr=*root; Node* temp=NULL; while(curr->x next; if(curr==NULL) break; } insert_after_a_specific_node(temp,value); }
@CodeVault
@CodeVault 3 жыл бұрын
Yea, that looks good. Good job!
Removing an element from a linked list
13:15
CodeVault
Рет қаралды 14 М.
Finding loops/cycles in a linked list
9:26
CodeVault
Рет қаралды 4,2 М.
Gym belt !! 😂😂  @kauermotta
00:10
Tibo InShape
Рет қаралды 18 МЛН
Nastya and SeanDoesMagic
00:16
Nastya
Рет қаралды 41 МЛН
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
Best KFC Homemade For My Son #cooking #shorts
00:58
BANKII
Рет қаралды 71 МЛН
why do void* pointers even exist?
8:17
Low Level Learning
Рет қаралды 344 М.
C# LinkedList Tutorial How to Use A Linked List
17:00
Journey To Programming
Рет қаралды 48 М.
Array-Based Sorted List Tutorial
32:55
Professor Hank Stalica
Рет қаралды 195
Arrays as function parameters in C
13:28
CodeVault
Рет қаралды 12 М.
Iterating over a linked list in C
11:45
CodeVault
Рет қаралды 35 М.
How different are C and C++? Can I still say C/C++?
10:25
Jacob Sorber
Рет қаралды 220 М.
How to return and pass a struct to a function
13:30
CodeVault
Рет қаралды 30 М.
Gym belt !! 😂😂  @kauermotta
00:10
Tibo InShape
Рет қаралды 18 МЛН