NPTEL Data Structure And Algorithms Using Java Week 8 Assignment Solutions

## NPTEL Data Structure And Algorithms Using Java Week 8 Assignment Answers 2023

**1. In the context of data structures, what is the primary purpose of an adjacency matrix?**a. To store the values associated with vertices in the graph.

b. To efficiently represent and store the relationships between vertices in a graph.

c. To determine the degree of a vertex in the graph.

d. To find the shortest path between two vertices.

Answer :- For AnswerClick Here

**2. When implementing a breadth-first search (BFS) algorithm on a graph, what data structure is typically used to keep track of vertices in the order they are visited?**a. Stack

b. Queue

с. Heap

d. Linked list

Answer :-For AnswerClick Here

**3. In the context of graph traversal, what is the time complexity of determining whether a graph is bipartite using depth-first search (DFS)?**a. O(V)

b. O(V + E)

c. O(V^2)

d. O(E log V)

Answer :-For AnswerClick Here

**4. Consider a weighted, directed graph with V vertices and E edges. Which data structure is most suitable for finding the shortest paths between all pairs of vertices efficiently?**a. Adjacency matrix

b. Priority queue

c. Stack

d. Hash table

Answer :-For AnswerClick Here

**5. Which Java Collection is commonly used to represent a graph as an adjacency list?**a. ArrayList

b. HashSet

c. TreeMap

d. HashMap

Answer :-For AnswerClick Here

**6. What is the time complexity of retrieving a value from a HashMap in Java?**a. O(1)

b. O(log m)

c. O(n)

d. O(n log n)

Answer :-For AnswerClick Here

**7. Which of the following statements about HashMap in Java is correct?**a. HashMap allows duplicate keys but not duplicate values.

b. HashMap allows duplicate values but not duplicate keys.

c. HashMap does not allow duplicate keys or values.

d. HashMap allows both duplicate keys and duplicate values.

Answer :-For AnswerClick Here

**8. What happens if you attempt to retrieve a value from a HashMap using a key that does not exist in the HashMap?**a. It returns null.

b. It throws a NoSuchElementException.

c. It throws a NullPointerException.

d. It returns the default value associated with the value type.

Answer :-For AnswerClick Here

**9. Which of the following statements) is(are) true?**a. If you put an object with the same key value, it will overwrite the previous one.

b. Always use generics and diamond operator to declare a new map.

c. keySet: returns a Set view of the keys contained in the map.

d. entrySetO: returns a Set view of the mappings contained in this map.

Answer :-For AnswerClick Here

**10. Consider an adjacency matris (M) representation for a simple unweighted graph having V vertices. What is the maximum number of non-zero entries possible in M?**a. V*

*V*

*b.*V*(V+1)

C. (V*(V+1))/2

d. V*(V-1)

Answer :-For AnswerClick Here

Course Name | Data Structure And Algorithms Using Java |

Category | NPTEL Assignment Answer |

Home | Click Here |

Join Us on Telegram | Click Here |