Data structures Flashcards
What is an array?
An array is a collection of items of same data type stored at contiguous memory locations
What is a Linked List?
a linked list consists of nodes where each node contains a data field and a reference(link) to the next node in the list. (look a like an array but on different memory locations)
Downsides of a Linked List?
- Searching is slow (linear search)
- Takes more memory (because it also stores the memory location and value.
- relative difficult to sort
Upside of Linked List?
Faster to add or remove items
What is a hashtable (hashmap)
Hash Table is a data structure which stores data in an associative manner. In a hash table, data is stored in an array format, where each data value has its own unique index value.
Upside of a hashtable?
Fast searching, fast inserting
Downside of a hashtable
Takes more memory
What is a trie?
A trie (derived from retrieval) is a multiway tree data structure used for storing strings over an alphabet. It is used to store a large amount of strings. The pattern matching can be done efficiently using tries.
Upside of using a Trie
- In tries the keys are searched using common prefixes. Hence it is faster. The lookup of keys depends upon the height in case of binary search tree.
- Tries take less space when they contain a large number of short strings. As nodes are shared between the keys.
- Tries help with longest prefix matching, when we want to find the key.
What a 3 downsides of using an Array?
- insertion is bad
- deleting items is bad
- stuck with a fixxed size
What are 3 upsides of using an array?
- Looking up items is good
- relative easy to sort an array
- Relative small in memory-size