Don’t worry, unlock all articles / blogs on PrepInsta by just simply logging in on our website
Type atleast 3 characters
Popular Searches
Trending Pages
Notifications Mark All Read
No New notification
Capgemini Menu9>
PREPINSTA PRIME
Get Hiring Updates right in your inbox from PrepInsta
Question 1
1. add(int k) 2. { 3. heap_size++; 4. int i = heap_size - 1; 5. harr[i] = k; 6. while (i != 0 && harr[parent(i)] < harr[i]) 7. { 8. swap(&harr[i], &harr[parent(i)]); 9. i = parent(i); 10. } 11. }
Line -3
Line – 5
Line – 6
Line -7
Start
Question 2
1,3,4,5,7,8,9,10
1,4,3,8,9,5,7,10
1,3,4,5,8,7,9,10
None of these
Question 3
build(A,i) left-> 2*i right->2*i +1 temp- > i if(left<= heap_length[A] ans A[left] >A[temp]) temp -> left if (right = heap_length[A] and A[right] > A[temp]) temp->right if temp!= i swap(A[i],A[temp]) build(A,temp)
It is the build function of the max heap.
It is the build function of min heap.
It is general build function of any heap.
None of the mentioned
Question 4
dynamic size
ease of insertion/deletion
ease in randomly accessing a node
both dynamic size and ease of insertion/deletion
Question 5
void print(tree *root,tree *node) { if(root ==null) return 0 if(root-->left==node || root-->right==node || print(root->left,node)||printf(root->right,node) { print(root->data) } }
just printing all nodes
not a valid logic to do any task
printing ancestors of a node passed as the argument
printing nodes from the leaf node to a node passed as the argument
Question 6
i)-find random node, replace with the node to be deleted. iii)- delete the node
ii)-find node to be deleted. iii)- delete the node at the found location
ii)-find deepest node, replace with the node to be deleted. iii)- delete a node
ii)-find deepest node, replace with the node to be deleted. iii)- the deepest node
Question 7
breadth first search
depth-first search
dijkstra’s algorithm
prims algorithm
Question 8
void xor-linked-list insert(struct node **head_ref, int value) { node *new_node = new (struct node); new_node->value = value; new_node->nodepointerxored = xor (*head_ref, NULL); if (*head_pointer == NULL) { printf("invalid"); } else { let b,c,d are nodes and a is to be inserted at beginning, a address field must contain NULL xor b and b address filed must be a xor c. } *head_pointer = new_node; }
node* next = XOR ((*head_ref)->npx, NULL); (*head_ref)->npx = XOR (new_node, next);
node* next = XOR ((*head_ref)->npx, NULL); (*head_ref) = XOR (new_node, next);
node* next = XOR ((*head_ref)->npx, NULL); (*head_ref)->npx->npx = XOR (new_node, next);
node* next = XOR ((*head_ref), NULL); (*head_ref)->npx = XOR (new_node, next);
Question 9
linked list. because we can swap elements easily
arrays. because we can swap elements easily
xor linked list. because there is no overhead of pointers and so memory is saved
doubly linked list. because you can traverse back and forth
Question 10
NULL xor A and B xor NULL
NULL and NULL
A and B
NULL xor A and B
Please login to report
Buy Capgemini Pseudo Code Paid Materials
Join Capgemini Online Classes