Array Ppt
- A common data structure, in particular in imperative programming languages, is that of an array. An array can be used to store and process a fixed number of data elements that all have the same type. We will also take a first detailed look at the issue of program safety.
- Arrays in Visual Basic.; 28 minutes to read +6; In this article. An array is a set of values, which are termed elements, that are logically related to each other.For example, an array may consist of the number of students in each grade in a grammar school; each element of the array is the number of students in a single grade.
What number sentences could you write to go with this array? 2 x 6 = 12 6 x 2 = 12 6 + 6 = 12 2 + 2 + 2 + 2 + 2 + 2 = 12 Can you think of any other ways to arrange the counters? What number sentences could you write to go with this array? 4 x 3 = 12 3 x 4 = 12 4 + 4 + 4 = 12 3 + 3 + 3 + 3 = 12 Could you arrange 20 counters?
Arrays, multiplication and division
Jennie Pennant, with the help of Jenni Way and Mike Askew, explores how the array can be used as a thinking tool to help children develop an in-depth understanding of multiplication and division.
Using Arrays to Explore Numbers
Arrays are useful models for multiplication which can be used in a variety of ways, ranging from highly structured lessons to games and open investigations.
An array is formed by arranging a set of objects into rows and columns. Each column must contain the same number of objects as the other columns, and each row must have the same number as the other rows.
The following array, consisting of four columns and three rows, could be used to represent the number sentence 3 x 4 = 12, 4 x 3 =12, 3 + 3 + 3 + 3 = 12 and 4 + 4 + 4 =12.
Building Multiplication Facts and Tables
Arrays can be used for building multiplication facts in a meaningful way. Before drilling and memorising tables, children must understand how these facts are derived. For example, by progressively adding another column of three objects, children can build the three-times tables for themselves. This representation not only assists in understanding the process, but provides a visual image forchildren to draw upon as they begin to use and memorise the basic number facts.
Using arrays to explore larger numbers
Arrays can be helpfully used to explore calculations such as 13 x 5 where the array can be split into useful chunks such as 10 and 3. This means that children can use their known number facts to work out calculations.
Here 13 x 5 = (10 x 5) + (3 x 5).
After a while drawing all the dots can get very tedious! The blank array then becomes a very useful tool for helping children model their thinking and work out how to do more complex multiplications in an informal way.
Here's a child using the blank array, as a thinking tool, to help them work out 15 x 14.
The blank array helps children to use other strategies, such as compensating, when carrying out multiplication. Here, to work out 34 x 9, the child has decided to do 34 x 10 and then take off the 34 x 1.
Beyond the blank array this 'dividing the multiplication into easy parts' strategy can be formalised into the grid method. The children can see how the 'abstract' grid method overlays the array and formalises the blank array into a standard form.
Division as the Inverse Operation of Multiplication
Of the four operations, division is the most troublesome for young students. Full understanding of division tends to lag well behind the other operations. For many children opportunities to explore the concept with concrete materials are curtailed well before they perceive the relationships between division and the other three operations. One such relationship, the inverse relationshipbetween division and multiplication, can be effectively illustrated using arrays.
For example; 3×5=15 or 3 rows of 5 make 15, can be represented by the following array.
Looking at the array differently reveals the inverse, that is
15÷3=5 or 15 put into 3 rows makes 5 columns - or 5 in each row.
Language clearly plays an important role in being able to express the mathematical relationships and the physical array supports this aspect of understanding by giving the children a concrete image to talk about.
Placing the mathematics into a real-life context through word problems can facilitate both understanding of the relationship and its expression through words.
For example, 'The gardener planted 3 rows of 5 seeds. How many seeds did she plant?' poses quite a different problem to 'The gardener planted 15 seeds in 3 equal rows. How many seeds in each row?' yet both these word problems can be modelled using the same array.
Further exploration of the array reveals two more ways of expressing inverse relationships: 5×3=15 and 15÷3=5 .
The word problems can be adapted to describe these operations and highlight the similarities and differences between the four expressions modelled by the one array.
Using the blank array
Suppose you want to figure out 176 ÷ 8. We can set this up as an array with the value of one side missing.
Using known multiplication facts the value of the missing side can be built up.
So the child can see that 22 lots of 8 is the same as 176.
The array is a very powerful tool for supporting the development of children's thinking around both multiplication and division.
Further reading
To read about the use of the arrays to illustrate number properties go here to read Jenni Way's article entitled Illustrating Number Properties with Arrays.
Here is a PDF version of this article.
An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array). The base value is index 0 and the difference between the two indexes is the offset.
For simplicity, we can think of an array a fleet of stairs where on each step is placed a value (let’s say one of your friends). Here, you can identify the location of any of your friends by simply knowing the count of the step they are on.
Remember: “Location of next index depends on the data type we use”.
The above image can be looked at as a top-level view of a staircase where you are at the base of the staircase. Each element can be uniquely identified by their index in the array (in a similar way as you could identify your friends by the step on which they were on in the above example).
Array’s size
In C language array has the fixed size meaning once size is given to it. It can’t change i.e. can’t shrink it, can’t expand it. The reason was that for expanding if we change the size we can’t be sure ( it’s not possible every time) that we get the next memory location to us as free. The shrinking will not work because array, when declared, it gets memory statically, and thus compiler is the only one to destroy it.
Types of indexing in array:
- 0 (zero-based indexing): The first element of the array is indexed by subscript of 0
- 1 (one-based indexing): The first element of the array is indexed by subscript of 1
- n (n-based indexing): The base index of an array can be freely chosen. Usually programming languages allowing n-based indexing also allow negative index values and other scalar data types like enumerations, or characters may be used as an array index.
Advantages of using arrays:
- Arrays allow random access of elements. This makes accessing elements by position faster.
- Arrays have better cache locality that can make a pretty big difference in performance.
- Arrays represent multiple data items of the same type using a single name.
Disadvantages of using arrays:
You can’t change the size i.e. once you have declared the array you can’t change its size because of static memory allocated to it. Here Insertion and deletion is difficult as the elements are stored in consecutive memory locations and the shifting operation is costly too.
Now if take an example of implementation of data structure Stack using array there are some obvious flaw.
Let’s take the POP operation of the stack. The algorithm would go something like this.
- Check for the stack underflow
- Decrement the top by 1
So there what we are doing is that the pointer to the topmost element is decrement meaning we are just bounding our view actually that element stays there talking up of the memory space if you have any primitive datatype then it might be ok but the object of an array would take a lot of memory.
Examples –
Usually, an array of characters is called a ‘string’, whereas an array of ints or floats is called simply an array.
Applications on Array
- Array stores data elements of the same data type.
- Arrays can be used for CPU scheduling.
- Used to Implement other data structures like Stacks, Queues, Heaps, Hash tables etc.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Teaching Multiplication Using Arrays
Recommended Posts:
Improved By : Shubhamlamichane, EmperorFlames, AayushDiwan, mishraakshat2610, gupta_shrinath, more