Algorithms and Data Structures Flashcards
Linked List
Access and insert O(n)
head insert O(I)
Best of sequencial access cases
Stacks (LIFO) and queues (FIFO)
Double Linked List
Inserts head and tail O(1)
Access O(n)
Deques
MRU: Most receent access to the head.
Binary Search Tree
Access is O(log(n)), O(n) worst case
Insert and delete O(log(n)), need of other search to rearrange things
Hash Table
Hash function maps key to a ‘bucket’
That bucket is then searched for the keys value
Hash collitions, when more than one key maps to the same bucket
Inser, lookups and delete O(1)
Hash collitons O(n)
Graphs
Social Network, Paths i a city
Vertices, Edges
bfs, dfs
Binary Search
Starts with a sorted list
Start in the middle, split list and lookup into the part you have to
O(log(n))
Search and Info retrieval
Forward inex of keywords of each doc
Generate inverted index that maps keywords to docs
Docs need to be ranked. ex. how often the word appears and where
TF-IDF
Term frenquency just measures how often a word occurs in a doc.
Document Frequency how often a word occurs in an entire set of docs.
Relevancy of a word in a doc: Term Frequency / Document Frequency.