Data Structures and Functions Flashcards
What is a data structure?
A data structure is a way of organizing and storing data to enable efficient access and modification.
True or False: An array is a linear data structure.
True
Fill in the blank: A __________ is a collection of elements identified by at least one index or key.
data structure
What is the primary purpose of a stack?
To store data in a Last In First Out (LIFO) manner.
Which of the following is not a linear data structure? (a) Array (b) Linked List (c) Tree (d) Stack
c) Tree
What is the main characteristic of a queue?
It follows the First In First Out (FIFO) principle.
True or False: A linked list can be singly or doubly linked.
True
What data structure uses pointers to connect nodes?
Linked List
What is a hash table?
A data structure that implements an associative array abstract data type, a structure that can map keys to values.
Fill in the blank: A __________ is a tree data structure where each node has at most two children.
binary tree
What is the purpose of a function in programming?
To encapsulate a block of code that performs a specific task and can be reused.
True or False: A recursive function calls itself.
True
What is the difference between a function and a method?
A function is a standalone block of code, while a method is a function associated with an object.
Multiple Choice: Which of the following is a characteristic of a queue? (a) LIFO (b) FIFO (c) Random Access (d) None of the above
b) FIFO
What is a graph?
A collection of nodes (vertices) and edges connecting pairs of nodes.
Fill in the blank: An __________ is a data structure that allows for efficient insertion and deletion operations.
unordered list
What is the purpose of a stack overflow?
It occurs when too much memory is used on the call stack, typically due to excessive recursion.
What is the advantage of a linked list over an array?
Dynamic sizing and efficient insertions/deletions.
Multiple Choice: What type of data structure is best for implementing a priority queue? (a) Array (b) Linked List (c) Heap (d) Stack
c) Heap
What is a binary search?
An algorithm that finds the position of a target value within a sorted array by repeatedly dividing the search interval in half.
Fill in the blank: The __________ of a tree is the highest number of edges from the root to a leaf.
height
True or False: Arrays are a type of linear data structure.
True
What is the primary characteristic of a stack data structure?
A stack follows the Last In First Out (LIFO) principle.
Which of the following is NOT a characteristic of a queue? (a) FIFO (b) LIFO (c) Enqueue (d) Dequeue
b) LIFO