Data Structures Flashcards
to learn
What are the common data structures?
Queues
Lists
Stack,
Arrays
Hash Tables
Graphs
Trees
Binary Search Trees
What is an abstract data type?
Logical representation of the data and enforced behaviour where the user does not know how the data structure is actually implemented.
Operations of a queue
Enqueue
Dequeue
IsFull
IsEmpty
Peek
Operations of a stack
Push
Pop
IsFull
IsEmpty
Peek
What is the difference between static and dynamic data structures?
Static data structure - fixed size
Dynamic data structure - grows and shrinks to match its contents
Definition of a queue
-Abstract data structure
-First thing to be added to queue is first out (FIFO)
-Front and rear pointer
Types of queue
Linear
Circular
Priority
Describe a linear queue
-Has front and rear pointer
-Queue can run out of space as front pointer reaches end of available addresses
-Follows First In First Out (FIFO) approach
Describe a circular queue
Front and rear pointer can point at index zero when it reaches end of available address
More memory efficient because it can reuse a previously used space
Describe a priority queue
Item given priority
Item with highest priority dequeued before the items with lower priority
2 items with same priority follow First In First Out (FIFO)
Definition of a stack
-Abstract data structure
-First item to be pushed is last to be popped (First In Last Out)
-Top Pointer (Bottom is always index 0, so no need for bottom pointer)
Definition of a hash table
Used to change data with a one way transformation with a mathematical process (different to encryption as it cannot be reversed)
If two inputs hash to the same index, collision occurs and skip value is added on to destination index to get a new index (repeat process again)
Modulus operator is used if you reach the last index to go to the starting index
Skip value is set as part of table
Hash table ideally 2/3 full because reduces odds of collisions without being too memory inefficient
Explain the process of resizing a hash table
Take the number of items in hash table and multiply by 1.5
Create new hash table of that size and traverse old hash table, rehashing each item
Definition of a tree
A connected, undirected graph with no cycles
Definition of a binary tree
A rooted tree in which each node has at most 2 children