LambdaClass Profile picture
Jan 11 12 tweets 3 min read
ARRAYS VS. HASH MAPS

(1/12) As promised, we will continue with twitter threads about different concepts. Today we are going to explain the differences between ARRAYS and HASH MAPS, in both structures and uses. 👇🧵 Image
(2/12) What is the difference between arrays and hash maps? Arrays are faster for accessing an element at a specific position, and if you need to perform the same operation on all elements in the array, while hash maps are faster for looking up a value given a key.
(3/12) Arrays and hash maps are both data structures that are used to store and retrieve data. However, they differ in several ways:
▪️ Indexing
▪️ Search time
▪️ Insertion and deletion Image
(4/12) They are also dissimilar in:
▪️ Size
▪️ Order Image
(5/12) Overall, arrays are more suitable for situations where you need to access elements using a contiguous sequence of integers and you don’t need to frequently insert or delete elements.
(6/12) Hash maps are more suitable for situations where you need to access elements using keys and you need to perform frequent insertions and deletions.
(7/9) So… When should I use an array and when should I use a hash map?
It depends on what you need to do. Use an array for quick access to specific elements or ordered sequences. Use a hash map for quick look-up of values by key.
(8/12) Also, use an array if you don’t need to frequently insert or delete elements. Hash maps are more suitable for situations where you need to perform frequent insertions and deletions.
(9/12) You’d want to use hash maps in situations where you want to associate two pieces of data with one another.
(10/12) Cache locality better for arrays: using arrays can improve cache locality and lead to better performance because they allow the cache to store more data in a single cache line, increasing the chances that the data the program needs will be in the cache when it is needed.
(11/12) Remember! Hash maps do not allow for duplicate keys.
(12/12) That’s it! Both data structures have their time and place. We hope you’ve learned something about arrays and hash maps. Do you have any more questions? Let us know! #programming #datastructures #hashmaps #arrays #lambdathread

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with LambdaClass

LambdaClass Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @ClassLambda

Jan 16
(1/15) TRIES

Let’s dive into the world of data structures! Today, we’ll talk about Tries. Trie is used because it is the fastest for auto-complete suggestions. 🧵

#DataStructures #Lambdathread Image
(2/15) A trie (or prefix tree) is a tree-like data structure that is often used to store a collection of strings. Each node in the trie represents a character in a string, and the path from the root to a particular node represents a prefix of one of the strings in the collection. Image
(3/15) Its main advantages are related to efficient insertion, search, and deletion operations, as well as the ability to quickly find all strings that start with a particular prefix.
Read 15 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(