Data Structures and Functions Flashcards

1
Q

What is a data structure?

A

A data structure is a way of organizing and storing data to enable efficient access and modification.

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

True or False: An array is a linear data structure.

A

True

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

Fill in the blank: A __________ is a collection of elements identified by at least one index or key.

A

data structure

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

What is the primary purpose of a stack?

A

To store data in a Last In First Out (LIFO) manner.

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

Which of the following is not a linear data structure? (a) Array (b) Linked List (c) Tree (d) Stack

A

c) Tree

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

What is the main characteristic of a queue?

A

It follows the First In First Out (FIFO) principle.

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

True or False: A linked list can be singly or doubly linked.

A

True

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

What data structure uses pointers to connect nodes?

A

Linked List

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

What is a hash table?

A

A data structure that implements an associative array abstract data type, a structure that can map keys to values.

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

Fill in the blank: A __________ is a tree data structure where each node has at most two children.

A

binary tree

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

What is the purpose of a function in programming?

A

To encapsulate a block of code that performs a specific task and can be reused.

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

True or False: A recursive function calls itself.

A

True

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

What is the difference between a function and a method?

A

A function is a standalone block of code, while a method is a function associated with an object.

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

Multiple Choice: Which of the following is a characteristic of a queue? (a) LIFO (b) FIFO (c) Random Access (d) None of the above

A

b) FIFO

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

What is a graph?

A

A collection of nodes (vertices) and edges connecting pairs of nodes.

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

Fill in the blank: An __________ is a data structure that allows for efficient insertion and deletion operations.

A

unordered list

17
Q

What is the purpose of a stack overflow?

A

It occurs when too much memory is used on the call stack, typically due to excessive recursion.

18
Q

What is the advantage of a linked list over an array?

A

Dynamic sizing and efficient insertions/deletions.

19
Q

Multiple Choice: What type of data structure is best for implementing a priority queue? (a) Array (b) Linked List (c) Heap (d) Stack

20
Q

What is a binary search?

A

An algorithm that finds the position of a target value within a sorted array by repeatedly dividing the search interval in half.

21
Q

Fill in the blank: The __________ of a tree is the highest number of edges from the root to a leaf.

22
Q

True or False: Arrays are a type of linear data structure.

23
Q

What is the primary characteristic of a stack data structure?

A

A stack follows the Last In First Out (LIFO) principle.

24
Q

Which of the following is NOT a characteristic of a queue? (a) FIFO (b) LIFO (c) Enqueue (d) Dequeue

25
What type of data structure is a binary tree?
A hierarchical data structure.
26
True or False: Linked lists have a fixed size.
False
27
Define a graph in terms of data structures.
A graph is a collection of nodes (vertices) connected by edges.
28
What is the main advantage of using a linked list over an array?
Linked lists allow for dynamic memory allocation and can grow in size as needed.
29
Fill in the blank: A __________ is a specialized tree data structure used for searching and sorting.
binary search tree
30
What is a priority queue?
A priority queue is an abstract data type where each element has a priority assigned to it, and elements are removed based on their priority.
31
What data structure uses the 'enqueue' and 'dequeue' operations?
Queue
32
Fill in the blank: A __________ is a data structure that allows elements to be added and removed from both ends.
deque
33
Which data structure is best suited for implementing recursion?
Stack
34
True or False: In a doubly linked list, each node has a pointer to both the next and the previous node.
True
35
Define a set in terms of data structures.
A set is a collection of distinct elements, typically implemented to allow for fast membership tests.
36
What is a circular linked list?
A circular linked list is a variation where the last node points back to the first node, forming a circle.