Grokking 75: Top Coding Interview Questions
Vote

0% completed

​

Introduction to Arrays

Array is one of the fundamental data structures and is used extensively in software development. Arrays provide a means of storing and organizing data in a systematic, computer-memory-efficient manner. t2

Essentially, an array is a collection of elements, each identified by an array index. The array elements are stored in contiguous memory locations, meaning they are stored in a sequence.

Static vs. Dynamic Sized Arrays

Arrays can be categorized into two types based on whether their size can change during runtime: static-sized arrays and dynamic-sized arrays.

.....

.....

.....

Like the course? Get enrolled and start learning!
A

Anonymous

· 2 years ago

In the Array introduction section we have the following piece of code, saying that staticArray has fixed size:

from array import array # Static Array (Using the array module for strictly typed arrays; # however, lists are more commonly used and can be considered dynamic.) staticArray = array('i', [0]*5) # Array of integers with a fixed size of 5 staticArray[0] = 1

That's actually not true. Because it's still possible to append an item there:

staticArray.append(10) print(staticArray) # output: array('i', [1, 0, 0, 0, 0, 10])
A

Anonymous

· 2 years ago

The week 1 material introduces the data structures "Arrays" and "Matrices". I don't recall any specific algorithms were covered though. It seems like when running code that exploits an array or matrix, the main takeaways are:

  1. Write the code in a way that minimizes the amount of times it has to loop over the array/matrix.
  2. Write the code in a way that minimizes (and ideally eliminates) duplicate operations. For example, when building an array with cumulative sums, calculate each value as the previous index's cumulative sum, plus the next value.

Does everyone concur with this? Are there any other takeaways for writing code that uses arrays/matrices? Were there specific algorithms that I missed?

Reading Progress

0%


Vote for new content