NPTEL Data Structure And Algorithms Using Java Week 4 Assignment Answers 2024
1. Consider the given Java code snippet that implements a singly linked list:
a. To execute various operations on the linked list.
b. To perform an operation in the middle of the linked list.
c. To insert a new element at the start of the linked list.
d. To insert a new element at the end of the linked list.
Answer :- For Answer Click Here
2. What does the following function do given a linked list with the first node as head?
a. Prints all nodes of linked lists.
b. Prints alternate nodes of linked list
c. Prints all nodes of the linked list in reverse order
d. Prints alternate nodes in reverse order
Answer :- For Answer Click Here
3. In the worst case, the number of comparisons needed to search an item stored in a single linked list structure of length 101 is
a. 98
b. 101
c. 99
d. 100
Answer :-
4. Which of the following statements accurately describes the differences between arrays and linked lists?
a. Arrays store elements in contiguous memory locations, are static data structures, and are generally faster for random access. Linked lists store elements in non-contiguous memory locations, are dynamic data structures, and are better for operations like insertion and deletion.
b. Arrays and linked lists both store elements in contiguous memory locations but differ in that arrays are dynamic while linked lists are static.
c. Arrays and linked lists are both dynamic data structures and store elements in non-contiguous memory locations, but arrays are faster for insertion and deletion operations.
d. Arrays are dynamic and store elements in non-contiguous memory locations, while linked lists are static and store elements in contiguous memory locations.
Answer :-
5. What is the time complexity of deletion from the end in a circular doubly linked list?
a. O(1)
b. O(n)
c. O(log n)
d. O(log log n)
Answer :-
6. Which of the following statement(s) is(are) false about Java LinkedList?
a. Java LinkedList class cannot contain duplicate elements.
b. Java LinkedList class maintains insertion order.
c. Java LinkedList class is non synchronized.
d. Java LinkedList class cannot be used as a list, stack or queue.
Answer :- For Answer Click Here
7. For which of the following applications Linkedlist may be a good choice?
. Sparse matrix manipulation
b. Random Access Requirements
c. Polynomial manipulation
d. memory management
Answer :-
8. Which of the following statements about arrays and linked lists in Java is/are Incorrect ?
a. Arrays are always faster than linked lists.
b. Linked lists are always faster than arrays.
c. Arrays are better for random access, while linked lists are better for sequential access.
d. Arrays and linked lists have the same performance for both random and sequential access.
Answer :-
9. Suppose you have a linked list of integers and you want to delete the first node in the list. Which of the following statements is/ are Incorrect?
a. The time complexity of the deletion operation is O(1).
b. The time complexity of the deletion operation is O(logn).
c. The time complexity of the deletion operation depends on the size of the integer to be deleted.
d. The time complexity of the deletion operation depends on the location of the deletion point.
Answer :-
10. Which of the following is/are not a valid declaration of a collection of type List (as per syntax)?
a. LinkedList a = new LinkedList()
b. LinkedList b = new LinkedList<>()
c. LinkedList c = new LinkedList()
d. LinkedList d = new LinkedList<>{1, 2, 3, 4, 5}
Answer :- For Answer Click Here
NPTEL Data Structure And Algorithms Using Java Week 4 Assignment Answers 2023
Q1. In the worst case, the number of comparisons needed to search an item stored in a single linked list structure of length 100 is
а. 98
b. 101
c. 99
d. 100
Answer:- d
Q2. What does the following function do given a linked list with the first node as head?
Answer:- For Answer Click Here
Q3. Consider the given Java code snippet that implements a singly linked list:
Answer:-
4. Which of the following operations is performed more efficiently by a doubly linked list than by linear linked list?
a. Deletion after a node
b. Insertion after a node
c. Searching
d. Traversal
Answer:- Answer:- For Answer Click Here
5. What is the time complexity of deletion from the end in a circular doubly linked list?
a. O(1)
b. O(n)
c. O(log n)
d. O(log log n)
Answer:-
6. Which of the following statements) is(are) true about Java LinkedList?
a. Java LinkedList class cannot contain duplicate elements.
b. Java LinkedList class maintains insertion order.
C. Java LinkedList class is non synchronized.
d. Java LinkedList class cannot be used as a list, stack or queue.
Answer:- Answer:- For Answer Click Here
7. For which of the following applications, Linkedlist may not be the good choice?
a. Sparse matrix manipulation
b. Random Access Requirements
C. Polynomial manipulation
d. memory management
Answer:-
8. Which of the following statements is true about arrays and linked lists in Java?
a. Arrays are always faster than linked lists.
b. Linked lists are always faster than arrays.
c. Arrays are better for random access, while linked lists are better for sequential access.
d. Arrays and linked lists have the same performance for both random and sequential access.
Answer:- Answer:- For Answer Click Here
9. Suppose you have a linked list of integers and you want to delete the first node in the list. Which of
the following statements is true?
a. The time complexity of the deletion operation is O(1).
b. The time complexity of the deletion operation is O(n).
c. The time complexity of the deletion operation depends on the size of the integer to be deleted.
d. The time complexity of the deletion operation depends on the location of the deletion point.
Answer:-
10. Which of the following is not a valid declaration of a collection of type List?
a. LinkedList<String> a = new LinkedList<string>();
b. LinkedList<String> b = new LinkedList <>();
c. LinkedList<int> c = new LinkedList<string>();
c = new LinkedList<Integer> d = new LinkedList<>(1, 2, 3, 4, 5);
Answer:- Answer:- For Answer Click Here