Data Structure Must Know

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/36

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:53 PM on 6/5/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

37 Terms

1
New cards

What is an array?

  • ordered collection of items

  • every item sits in a numbered position

  • Fixed size

  • contiguous

2
New cards

Time Complexity of Array given index

O(1)

3
New cards

Important constraint of arrays

  • Size is fixed from moment of creation

  • Stays fixed since expanding size of arrays is hard because new region of contiguous memory must be found that is of the new size. This is O(n) since all data must be copied over. Similar problem with inserting data as well

4
New cards

Data Structure that is fast to read from but slow and rigid when data keeps changing

Array

5
New cards

examples of where arrays are used

pixels on a screen, frames in a video stream, situations where position of data is fixed and known in advance

6
New cards

What is Linked List?

  • data structure made of collection of nodes that contain the value they are meant to store along with reference to the next node

  • not contiguous, stays connected via pointers

  • easy to insert (so O(1) ) or change size of, harder to read because must start in beginning and traverse node pointers (so O(n))

7
New cards

Slow to read, fast to change

Linked List

8
New cards

What is a Stack?

  • data structure

  • LIFO (Last item In is First item Out)

  • 2 operations: push (adds item to top) and pop (removes item from top) , both operations O(1), no other operations

9
New cards

Stack only cares about data added recently

true

10
New cards

What is Queue?

  • Data Structure

  • FIFO, think: its like a line at a checkout at a store

  • 2 operations: enqueue (adds to back) and dequeue (removes from front), both O(1), no other operations

11
New cards

What is a Deque?

  • data structure

  • (double ended que) = deque

  • can easily add or remove from the front

  • can easily add or remove from the back

12
New cards

Deque acting as stack

add or remove only from front or only from back

13
New cards

Deque acting as queue

add to back, remove front (or vice versa)

14
New cards

What is a hash map?

  • data structure

  • stores data as key value pairs

  • retrieve data by searching via relevant key which has desired data aka the value. if key is known, retrieval is instant O(1)

  • hash function: takes in key, computes number, number points to specific memory address where associated value is located

15
New cards

What problem does hash map solve?

Problem:

  • Huge collection

  • involve lots of checking of elements to find desired element

Solution:

  • Have a treasure map aka dictionary aka a way to map a key to a value instantly

  • possible via hash function.

16
New cards

What has more memory footprint, hashmap or array?

hashmap because they store key,value, and other metadata (the hashcode,pointers to buckets for avoiding collisions,etc)

17
New cards

What is a hashset?

  • data structure

  • hash map with no values, just keys

  • entire purpose: does a particular element exist in set or no

  • checking/reading, adding, deleting data is all O(1)

  • no duplicates

18
New cards

What is a Tree?

  • Data Structure

  • hierarchical

  • has root, nodes (that can have children nodes) connected via branches, and leaf Nodes at the very bottom with no children

  • natural data structure for anything that can be modelled via parent child relationship

19
New cards

Plain Tree

  • tree with no rules about where values go

  • searching could involve potentially checking every single node thus run time complexity could be O(n)

20
New cards

Binary Search Tree

  • tree but with the rule that root and any other node can have at most 2 children

  • parent’s left child contains value lesser than parent node’s value

  • parent’s right child contains value more than parent node’s value

21
New cards

What happens when you add items to BST in already sorted order?

It acts like a linked list, searching becomes O(n) as in the case of an ordinary linked list

22
New cards

Self Balancing BST

  • Type of BST

  • solves the problem of encountering data in sorted order by doing rotations of data to make sure no branch is way longer than the other. Uses algorithms like red-black trees and AVL

  • search runtime complexity is O(log(n))

23
New cards

What is Heap?

  • tree-based data structure that keeps highest priority item at the top

  • reorganizes automatically every time new data is added to still have highest priority data at the top as root

  • used when the goal isnt search but instant access to most important element

24
New cards

Max Heap

largest value is at root

25
New cards

Min Heap

smallest value is at root

26
New cards

Finding top priority element without heap…..

sort whole list by priority, then find highest priority data. This is inefficient compared to heap for this task.

27
New cards

What are Graphs?

  • data structure

  • made up of nodes and edges, where nodes connected/related via edges.

28
New cards

Undirected Graphs

involves edges that relate nodes bidirectionally (so no general direction)

29
New cards

Directed Graphs

involves edges that are unidirectional where one node may relate to another but not vice versa

30
New cards

Adjascent Nodes

neighboring nodes connected via edges.

31
New cards

How to store a Graph in memory

  • adjascency matrix: rows and columns are nodes, values within stored in 0 or 1, signalling no edge or edge.

  • Adjascency List: each node keeps a list of its neighbors. This is more memory efficient

32
New cards

What can be done with graphs?

  • search via DFS and BFS

  • finding paths between nodes

  • checking for cycles between nodes

  • detecting nearby nodes

33
New cards

What is a Trie?

  • variation of a tree

  • each level represents one character in a word

  • shows branches to possible chars based on preceding chars typed by user, works like n-gram contex

34
New cards

What is a Disjoint Set aka Union -Find?

  • data structure

  • purpose is to track group membership efficiently

  • every element starts as its own group. When elements get connected, they merge into one group, with each group having a representative called “leaders”.

  • to check if two elements in same group, you check if they have same leader. This check is O(1)

35
New cards

What is a bloom filter?

  • data structure

  • O(1) search

  • little memory

  • answers yes or no when something is searched. If no, this is a guranteed correct answer (no false negatives), but if yes, there is a chance it is a false positive

36
New cards

how are bloom filters used

used to rule out answers to search query with reasonable certainty. for example bloom filter on search term is used before actual search is done on database to reduce number of database reads

37
New cards

What is LRU (least recently used) Cache?

  • data structure

  • used in cases where memory is running low and some data must be discarded to make space. Least recently used data is what is made to be discarded or removed from cache

  • built from combination of hash map and doubly lined list

  • most recently used data is made to be in front, least recently used made to stay in back and discarded when when memory is low

  • get(key) and put(key,val) is O(1) time