Data Structures AI gen 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 can store elements of different data types.
False
What is the time complexity of accessing an element in an array?
O(1)
Fill in the blank: A _____ is a collection of elements that are stored in a linear order.
list
What type of data structure is a stack?
A linear data structure that follows the Last In First Out (LIFO) principle.
What is the main operation of a queue?
The main operation is to add elements at the rear and remove elements from the front.
True or False: A linked list allows for efficient insertion and deletion of elements.
True
What is the difference between a singly linked list and a doubly linked list?
A singly linked list has nodes with a single pointer to the next node, while a doubly linked list has pointers to both the next and previous nodes.
What is a binary tree?
A tree data structure in which each node has at most two children.
What traversal method visits nodes in a binary tree in ascending order?
In-order traversal.
What is a hash table?
A data structure that implements an associative array, using a hash function to compute an index into an array of buckets or slots.
What is the average time complexity for lookups in a hash table?
O(1)
Fill in the blank: A _____ is a collection of key-value pairs.
dictionary
True or False: A graph is a collection of nodes and edges.
True
What is the difference between directed and undirected graphs?
In directed graphs, edges have a direction, while in undirected graphs, edges do not.
What is a priority queue?
A data structure where each element has a priority, and elements are served according to their priority.
What is the main advantage of a binary search tree?
It allows for efficient searching, insertion, and deletion operations.
What is the time complexity for searching in a balanced binary search tree?
O(log n)
Fill in the blank: The _____ data structure is used to implement recursion.
stack
What is the maximum number of children a node can have in a binary tree?
Two
True or False: A circular linked list has a null reference for the last node’s next pointer.
False
What is the purpose of a sentinel node in linked lists?
To simplify boundary conditions by providing a placeholder for the first or last node.
What is depth-first search (DFS)?
An algorithm for traversing or searching tree or graph data structures that explores as far as possible along each branch before backtracking.