PRELIM DSAA Flashcards

1
Q

What is a data structure?

A) A way to store and organize data
B) A type of programming language
C) A part of the operating system
D) A machine learning algorithm

A

A way to store and organize data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following is NOT a goal of data structures?

A) Correctness
B) Efficiency
C) Randomness
D) Fast searching and sorting

A

Randomness

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an entity in data structures?

A) A specific type of file
B) A class of objects with attributes
C) A field in a database
D) A function in Java

A

A class of objects with attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following is a collection of various records of one type of entity?

A) Field
B) File
C) Record
D) Data

A

File

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an array?

A) A collection of variables with different data types
B) A collection of items stored in contiguous memory locations
C) A dynamic data structure
D) A type of linked list

A

A collection of items stored in contiguous memory locations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following statements about arrays is true?

A) Arrays can store only primitive data types
B) Arrays are always dynamically resizable
C) Arrays can contain objects as well as primitive types
D) Arrays use linked nodes for storage

A

Arrays can contain objects as well as primitive types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the index of the last element in an array of size 10?

A) 9
B) 10
C) 0
D) 1

A

9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What will happen if you try to access an index that is out of bounds in Java?

A) The program runs normally
B) The array automatically resizes
C) An ArrayIndexOutOfBoundsException is thrown
D) The compiler converts it to the nearest valid index

A

An ArrayIndexOutOfBoundsException is thrown

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which Java package contains the ArrayList class?

A) java.lang
B) java.util
C) java.io
D) java.math

A

java.util

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following is true about ArrayLists?

A) They are static in size
B) They use dynamic memory allocation
C) They do not allow duplicates
D) They store elements in a tree structure

A

They use dynamic memory allocation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the difference between an Array and an ArrayList?
A) Array has a fixed size, while ArrayList can grow dynamically
B) Array stores only objects, while ArrayList stores only primitive types
C) Array is a class, while ArrayList is a function
D) They are both identical

A

Array has a fixed size, while ArrayList can grow dynamically

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which method is used to remove an element from an ArrayList at a specific index?
A) remove(index)
B) delete(index)
C) erase(index)
D) clear(index)

A

remove(index)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What principle does a stack follow?
A) First In, First Out (FIFO)
B) Last In, First Out (LIFO)
C) Random access retrieval
D) Hierarchical storage

A

Last In, First Out (LIFO)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which operation adds an element to the top of the stack?
A) enqueue()
B) pop()
C) push()
D) insert()

A

push()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which operation removes the top element from the stack?
A) delete()
B) dequeue()
C) pop()
D) remove()

A

pop()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the peek() method do in a stack?
A) Removes the top element
B) Returns the top element without removing it
C) Searches for an element
D) Returns the size of the stack

A

Returns the top element without removing it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Which method checks if a stack is empty?
A) isEmpty()
B) clear()
C) hasElements()
D) exists()

18
Q

Which of the following is an example of an application of stacks?
A) Database indexing
B) Job scheduling
C) Infix to Postfix conversion
D) Network routing

A

Infix to Postfix conversion

19
Q

Which of the following is true about the Stack class in Java?
A) It extends the ArrayList class
B) It implements the Queue interface
C) It extends the Vector class
D) It does not allow duplicate elements

A

It extends the Vector class

20
Q

What is the main purpose of studying data structures?

A) To learn new programming languages
B) To understand how data is organized and managed efficiently
C) To improve network security
D) To create hardware components

A

To understand how data is organized and managed efficiently

21
Q

What defines a data structure?

A) A structural representation of the logical relationship between data elements
B) A type of database management system
C) A high-level programming language
D) A type of file system

A

A structural representation of the logical relationship between data elements

22
Q

Which of the following is NOT a feature of data structures?

A) Data storage
B) Data organization
C) Data destruction
D) Data retrieval

A

Data destruction

23
Q

What is an entity in data structures?

A) A data type
B) A class of objects with attributes
C) A function in Java
D) A type of array

A

A class of objects with attributes

24
Q

Which term refers to a collection of various data items?

A) Field
B) Record
C) File
D) Group

25
What is a field in data structures? A) A collection of related records B) A single unit of information representing an attribute C) A type of linked list D) A database query
A single unit of information representing an attribute
26
Which of the following best describes a file? A) A collection of various records of one type of entity B) A function that stores data in memory C) A group of related fields D) A type of primitive data structure
A collection of various records of one type of entity
27
What is an array? A) A collection of elements stored in contiguous memory locations B) A dynamic data structure that can change size C) A linked list of data elements D) A collection of unrelated data types
A collection of elements stored in contiguous memory locations
28
Which of the following statements about arrays is FALSE? A) Arrays are fixed in size once declared B) Arrays store elements of the same data type C) Arrays can store elements at non-contiguous memory locations D) Arrays allow indexed access to elements
Arrays can store elements at non-contiguous memory locations
29
How are elements accessed in an array? A) Using a linked list traversal B) Using an index C) Using a hash function D) Using binary search
Using an index
30
What is the index of the first element in an array? A) 0 B) 1 C) -1 D) n-1
0
31
Which operation retrieves an element from an array? A) insert() B) delete() C) get(index) D) update()
get(index)
32
Which package contains the ArrayList class in Java? A) java.lang B) java.util C) java.io D) java.math
java.util
33
What makes an ArrayList different from an array? A) It can store primitive data types directly B) It has a fixed size C) It dynamically resizes D) It does not allow duplicates
It dynamically resizes
34
Which method adds an element to an ArrayList? A) insert() B) add() C) append() D) push()
add()
35
Which method removes an element from an ArrayList? A) delete() B) remove() C) erase() D) clear()
remove()
36
What is the principle of a stack? A) First In, First Out (FIFO) B) Last In, First Out (LIFO) C) Random access retrieval D) Hierarchical storage
Last In, First Out (LIFO)
37
Which operation inserts an element into a stack? A) enqueue() B) pop() C) push() D) insert()
push()
38
Which method removes the top element of the stack? A) delete() B) pop() C) remove() D) extract()
pop()
39
What does the peek() method do in a stack? A) Removes the top element B) Returns the top element without removing it C) Searches for an element D) Returns the size of the stack
Returns the top element without removing it
40
Which stack method checks if the stack is empty? A) isEmpty() B) clear() C) hasElements() D) exists()
isEmpty()
41
Which is a common application of stacks? A) Sorting data B) Database indexing C) Infix to Postfix conversion D) Network routing
Infix to Postfix conversion