Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Transcript

# 1st Semester - Academic Year: 2024-2025 ## Data Structures (DS) ### I. Data Structures 1. Which of the following data structures allows insertion and deletion at both ends? * A) Stack * B) Queue * C) Linked List * **D) Deque** 2. What is the primary difference between an ArrayLi...

# 1st Semester - Academic Year: 2024-2025 ## Data Structures (DS) ### I. Data Structures 1. Which of the following data structures allows insertion and deletion at both ends? * A) Stack * B) Queue * C) Linked List * **D) Deque** 2. What is the primary difference between an ArrayList and a LinkedList in Java? * A) ArrayList allows duplicate values, Linked List does not * **B) ArrayList uses dynamic arrays, LinkedList uses doubly linked nodes** * C) ArrayList is faster for inserting/removing elements at the beginning, LinkedList is faster at accessing elements * D) LinkedList is backed by arrays, ArrayList by nodes. 3. Which primitive data type has a precision of approximately 15 decimal digits? * A) float * **B) double** * C) int * D) char 4. How many bits does the short primitive data type occupy in Java? * A) 8 * **B) 16** * C) 32 * D) 64 5. Which primitive data type has a range of -2^31 to 2^31-1 in Java? * A) short * **B) int** * C) long * D) byte 6. What is the size (in bytes) of the long primitive data type in Java? * A) 2 * B) 4 * **C) 8** * D) 16 7. Which of the following primitive types is the smallest in terms of storage size? * A) byte * B) short * C) int * **D) long** ### II. Characteristics of DS 1. Which of the following is a characteristic of an array? * **A) Fixed size** * B) Dynamic resizing * C) Supports only primitive data types * D) Allows duplicate keys 2. What is the main characteristic of a stack data structure? * A) First-In-First-Out (FIFO) * **B) Last-in-First-Out (LIFO)** * C) Random access * D) Hierarchical structure 3. Which of the following data structures does NOT allow duplicate elements? * A) Array * **B) HashSet** * C) LinkedList * D) Stack 4. In which data structure is each element associated with a key and a value? * A) Queue * **B) HashMap** * C) Stack * D) Array 5. Which of the following data structures is the best for implementing a priority queue? * A) Stack * B) Array * C) HashMap * **D) Heap** 6. What is the main advantage of using a linked list over an array? * A) Random access to elements * B) Faster access time * **C) Dynamic size** * D) Easier to sort 7. Which data structure is known for its hierarchical relationship among its elements? * A) Tree * B) Stack * C) Array * D) Queue 8. Which of the following characteristics describes a circular queue? * A) Unlimited size * B) Elements can only be dequeued from the front and enqueued at the rear * **C) Front and rear pointers wrap around when they reach the end of the array** * D) Allows insertion and deletion from both ends. 9. Which characteristic is unique to a doubly linked list? * **A) Each node has a link to both the previous and next nodes** * B) Nodes only link to the next node * C) Access to elements is O(1) * D) Fixed memory allocation 10. What is the primary feature of a dynamic array (like ArrayList in Java)? * A) Fixed size at the time of declaration * **B) Automatically resizes when needed** * C) Elements can only be added at the end * D) Requires a predefined capacity

Tags

data structures Java programming computer science
Use Quizgecko on...
Browser
Browser