Here is the java version, C should be similar
// merges two Singly linked lists A and B, both sorted in increasing order of integers .
// Return a Singly linked list sorted in increasing order
// for ex if A = 1->2->3->6 and B = 2->4->7, returns 1->2->2->3->4->6->7
public LinkedList merge(LinkedList A, LinkedList B) {
Node 1A = A.head;
Node 1B = B.head;
Node P1A = NULL;
Node 2A = NULL;
Node 2B = NULL;
while ( 1A != NULL && 1B !=NULL){
2A = 1A.next;
2B = 1B.next;
if (1A.item >= 1B.item) {
if (P1A != NULL) {
P1A.next = 1B;
}
else if ( P1A == NULL){
P1A = 1B;
}
1B.next = 1A;
P1A = 1B;
1B = 2B;
}
else if ( 1A.item < 1B.item){
if ( 2A != NULL) {
P1A = 1A;
1A = 1A.next;
}
else{
1A.next = 1B;
break;
}
}
}
return A;
}
Which of the following data structures can be randomly accessed giving loc?A. linked list implemented using arrayB. singly linked listC. double linked listD. both single and double linked listThe answer is A.
Advantages of single linked list: # Decrease in storage space per linked list node # Simpler implementation Advantages of double linked list # Decrease in work when accessing a random node # Decrease in work when inserting or deleting a node
You copy a singly linked list into a doubly linked list by iterating over the singly linked list and, for each element, calling the doubly linked list insert function.
zsd
ok
Which of the following data structures can be randomly accessed giving loc?A. linked list implemented using arrayB. singly linked listC. double linked listD. both single and double linked listThe answer is A.
Advantages of single linked list: # Decrease in storage space per linked list node # Simpler implementation Advantages of double linked list # Decrease in work when accessing a random node # Decrease in work when inserting or deleting a node
Use merge sortUse tree sort
It is easier to insert into a singly linked list.
You copy a singly linked list into a doubly linked list by iterating over the singly linked list and, for each element, calling the doubly linked list insert function.
zsd
A linked list implemented with an array defeats the purpose of using a linked list, which is to address the memory allocation problems associated with arrays.
write a c program to circular queue
linked list are used for creation of stack,queues to use memory in optimum manner linked list are used as they are dynamic in nature
In_which_way_Doubly_linked_list_better_than_singly_linked_list
ok
A simple linked-list is an approach is to store the freelist of memory blocks, where each node of the linked list contains a pointer to a single free block in the memory pool.