vi. Assume that a linked list stores the data, 20, 11, 13, 19, 12, 14 in that order. Assume that Node head references the first item in the list. What is the result to the linked list of the following instructions? Assume that newNode is a Node, already constructed.
newNode.data = 1;
newNode.next = head.next;
head = newNode;
a. The value 1 is inserted into the linked list before 20
b. The value 1 is inserted into the linked list after 11 and before 13
c. The value 1 is inserted into the linked list before 11 and it is now at the head of the list
d. The value 1 is inserted into the linked list after 20 and the rest of the list is lost
e. None of the above
Queue Q;
S.push(3); S.push(2); S.push(1)
Q.enqueue(3); Q.enqueue(2); Q.enqueue(1);
int x = S.pop(); int y = Q.dequeue();
Q.enqueue(x); S.push(y);
Q.enqueue(Q.dequeue());
S.push(Q.peek()); // peek() function reads the front of a queue without deleting it
a+((b+3)-(c*d)+e
30, 70, 10, 15, 80, 20, 90, 11, 12
10 |
5 |
11 |
8 |
7 |
When is it appropriate to use an array data structures?
Ans - In arrays, the elements can be accessed randomly by using the
index number.
What is the major disadvantage of using an array data
structure?
Ans -
Write the differences between a linked list and an array?
Ans -
Array -
Array elements can be accessed randomly using the array index. |
Memory is allocated during the compile time (Static memory allocation).
LinkedList -
Random accessing is not possible in linked lists. The elements will have to be accessed sequentially. |
Memory is allocated during the run-time (Dynamic memory
allocation)
4. Answer the following questions:
i. It is easy to insert and delete elements in Linked List over Array. True
ii. Random data access is not allowed in a typical implementation of Linked Lists. True
iii. The size of an array has to be pre-decided whereas the size of a linked list can change during run time. True
iv. Which of the following is not a dynamic data structure?
c. Array.
v. In general, Linked Lists allow (choose the correct one) :
a. Insertions and removals anywhere.
vi. Assume that a linked list stores the data, 20, 11, 13, 19, 12, 14 in that order. Assume that Node head references the first item in the list. What is the result to the linked list of the following instructions? Assume that newNode is a Node, already constructed.
newNode.data = 1;
newNode.next = head.next;
head = newNode;
c. The value 1 is inserted into the linked list before 11 and it is now at the head of the list
Following ss are the answers of the questions until the last one
-
Get Answers For Free
Most questions answered within 1 hours.