Data Structures Flashcards

1
Q

Data Structures

A

Data structures are organized ways to store and manage data. Common data structures include arrays, linked lists, stacks, queues, hash tables, heaps (priority queues), tries, and disjoint sets (union-find).

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

Arrays

A

An array is a fixed-size, ordered collection of elements (values or variables), each identified by an index or a key. Arrays are used to store and retrieve data efficiently, with elements accessed by their numerical position.

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

Linked Lists

A

A linked list is a linear data structure consisting of nodes, where each node points to the next node in the sequence. Linked lists come in various forms, such as singly linked lists (each node points to the next node), doubly linked lists (each node points to both the next and previous nodes), and circular linked lists (the last node points back to the first).

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

Stacks

A

A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle. In a stack, elements are added and removed from the same end, known as the top. Common operations on a stack include push (add an element) and pop (remove the top element).

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

Queues

A

A queue is a linear data structure that follows the First-In-First-Out (FIFO) principle. In a queue, elements are added at one end (rear) and removed from the other end (front). Common operations on a queue include enqueue (add an element) and dequeue (remove the front element).

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

Hash Tables

A

A hash table (hash map) is a data structure that stores key-value pairs in an associative array. It uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found. Hash tables provide fast access to values based on their keys and are widely used in data storage and retrieval.

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

Heaps (Priority Queues)

A

A heap is a specialized tree-based data structure that satisfies the heap property. A binary heap, for example, can be implemented as a complete binary tree where each node has a value greater (or smaller) than or equal to the values of its children. Heaps are commonly used to implement priority queues, where the highest (or lowest) priority element is always at the root.

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

Trie

A

A trie (pronounced “try”) is a tree-like data structure used for efficiently storing and searching for a dynamic set of strings, such as words in a dictionary. Each node in the trie represents a character or a partial string, and common prefixes are shared among nodes.

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

Disjoint Set (Union-Find)

A

A disjoint set (also known as Union-Find or Disjoint-Set-Union) is a data structure that keeps track of a collection of disjoint sets, often used for solving problems involving dynamic connectivity. It supports two main operations: union (merging two sets into one) and find (determining the set to which an element belongs).

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