NPTEL Data Structure and Algorithms using Java Week 10 Assignment Answers 2024

Sanket
By Sanket

NPTEL Data Structure and Algorithms using Java Week 10 Assignment Answers 2024

1. Which of the following statements is true for class randomAccessFile?

a. It allows us to handle files randomly.
b. We can move the file pointer to any position in the file and perform read, write, or read-write operations at that position.
c. This class doesn’t provide flexibility to perform read and write operations simultaneously
d. It allows read or write or read-write simultaneously.

Answer :- For Answers Click Here 

2. What does the following Java program do?

image 126

What is the main purpose of the provided Java program?

a. It writes data to a file named “NPTEL.txt”.
b. It reads the entire content of a file named “NPTEL.txt”.
c. It reads a specified portion of a file named “NPTEL.txt” and prints it to the console.
d. It creates a new file named “NPTEL.txt” and stores data in it.

Answer :- For Answers Click Here 

3. Fill in the blanks in the context of Linear Searching.

image 127

Choose the best option for different cases:

image 128
Answer :- For Answers Click Here 

4. Linear searching with linked list in the best case will have an asymptotic complexity?

a. O(logn)
b. O(1)
c. O(n)
d. O(n/2)

Answer :- 

5. Which of the following statements about interpolation search is/are Incorrect?

a. Interpolation search works efficiently on sorted arrays.
b. Interpolation search is a type of binary search.
c. Interpolation search always outperforms linear search.
d. Interpolation search uses a fixed mid-point for dividing the search space.

Answer :- 

6. Which of the following is TRUE in case of Hashing?

a. Hashing is a mapping from the Key to its index(location).
b. Division Method
H(k) = k (mod h) if indices start from 0
H(k) = k (mod h)+1 if indices start from 1
c. Collision resolution techniques are Closed hashing and Open hashing
d. linear probing and chaining are not collision resolution techniquesZ

Answer :- For Answers Click Here 

7. Which of the following is/are a condition for Closed Hashing to stop from searching?

a. The key value is found.
b. An unoccupied (or empty) location is encountered.
c. It reaches the location where the search was started.
d. The hash table is resized.

Answer :- 

8. Which sorting technique is shown in the illustration below?

image 129

a. Merge
b. Bubble
c. Insertion
d. Selection

Answer :- 

9. What does the following code represent?

image 130

Choose the correct option.

a. A binary search algorithm
b. A bubble sort algorithm
c. A selection sort algorithm
d. A quicksort algorithm

Answer :- 

10. What does the following pseudocode represent, and what is its purpose?

image 131

Choose the correct answer.

a. This pseudocode represents a sorting algorithm called Bubble Sort, used to sort elements in ascending order.
b. This pseudocode represents an algorithm for inserting a new element into an existing list and maintaining the list’s sorted order.
c. This pseudocode represents a stack-based data structure used for storing and retrieving elements in a last-in, first-out (LIFO) manner.
d. This pseudocode represents a binary search algorithm for finding a specific element in a sorted list.

Answer :- For Answers Click Here 
Share This Article
Leave a comment