Insertion at a Certain Position (Singly Linked List vs. Arrays) - Part 2

preview_player
Показать описание
Data Structures: Inserting a Node at a certain position (Singly Linked List vs. Arrays)
Topics discussed:
1) The time complexity of an array when the data is inserted at a certain position.

Music:
Axol x Alex Skrindo - You [NCS Release]

#DataStructuresByNeso #DataStructures #LinkedList #SingleLinkedList
Рекомендации по теме
Комментарии
Автор

This is the best channel in explination i have ever seen and that voice too..:)

vijay
Автор

Thanks jaspreet for you teaching with clean and clear explanation

lohithneerukattu
Автор

i think it gets confusing because of another variable int j, i think it will be less confusing if we stick with for(i=index, i<n+1, i++) then inside this for loop will just be arr2[i+1] = arr[i]

either way output will still be the same

marbles
Автор

way of presenting is realy nice...

Btw do u use MSpowerpoint for making this presentation or some another app??

AdityaSharma-wgrj
Автор

Instead of creating a new array, can we choose 10 size larger than original size of arr[]?

sumainakyasar
Автор

U used n without defining it, only it’s data type was declared. Or am I missing something? Is n=size?

carletonbate
Автор

Hello sir, please complete the analog electronics full part

souravghosh
Автор

Sir is it important to learn same thing by an array and by linked the time complexity is same of both.

shreyanshdwivedi
Автор

At 7:13 the 3rd point is that we are passing the address of arr, that's correct, but if we are passing address shouldn't we collect it to a pointer variable sir ?
Please reply sir

aman
Автор

Couldn't we create the array within the function using malloc like we did with nodes and then return that from the function?

jackmenirons
Автор

void insert (Node *root, int val, int pos) {
Node *newNode = (Node *) malloc(sizeof(Node));
newNode->data = val;
newNode->link = NULL;

if (root == NULL) {
root = newNode;
} else {
Node* temp = root;
Node* prev = NULL;

for (int i = 0; i < pos; i++) {
if (temp->link == NULL) {
temp->link = newNode;
break;
} else {
if (i == pos-1) {
prev = temp;
newNode->link = temp->link;
prev->link = newNode;
}
temp = temp->link;
}
}
}
}


In the above function you don't require to have any other function to insert nodes, this function can insert at any position, if position is greater than the length then it insert the node at the end. it just cannot add at position 0

bossysmaxx
Автор

sir i request you pls provide me your computer networking lacture's ( 97 lactures ) PPT ..please i humbly request you 😖😖😭 if u provide me i sent my Gmail ID ..

jayeshpobari