General Data Structures Flashcards
What is the toString() method?
A special method that returns a string representation of an object
How to use the toString() method in our classes?
public String toString(){
return constructor1 + “ “ + data1;
}
Must include the method toString to our class object and edit how we want it to act
Include an @Override before the method
Why do we use toString()?
So we can print out an object in the form of a string rather than the address of the object
What is an Array?
A fixed size that stores elements in a linear set
What is a Dynamic Array? Array Lists
Resizeable Array
What is a linked list?
Nodes linked via pointers
What is a Stack?
LIFO, think of a stack of books
What is deque? queue
Double-ended queue
What is a Queue?
FIFO, think of a line
What is a Hash Table?
Stores key-value pairs
What is a Hash Set?
Unordered set, unique elements
What is a Binary Tree?
Each node has ≤2 children
What is a Binary Search Tree BST?
Ordered binary tree
What is an AVL Tree?
Self-balancing BST
What is a Red-Black tree?
Balanced BST used in TreeSet, TreeMap
What is a Segment Tree?
Used for range queries
What is a Fenwick Tree?
Efficient prefix sum computation
What is a Trie?
Used for string prefix searches
What is a Min Heap?
Smallest element at the root
What is a Max Heap?
Largest element at the root
What is a priority Queue?
Supports Efficient Retrieval of min/max
What is an Adjacency Matrix?
Graphs as a 2D Array
What is an Adjacency List?
Graph as a list of lists
How to implement basic Array?
int[] array = new int[10];