Working with Arrays

Arrays are an important construct of any programming language. To keep data of a similar type together, we need arrays. Arrays are heavily used in applications where elements have to be accessed at random. Arrays are also a prime choice when you need to sort elements, look for desired data in a collection, and find common or unique data between two sets. Arrays are assigned contiguous memory locations and are a very popular structure for sorting and searching data collections because any element of an array can be accessed by simply specifying its subscript or index location. This chapter will cover recipes that include operations commonly applied to arrays.

In this chapter, we will learn how to make the following recipes using arrays:

  • Inserting an element into a one-dimensional array
  • Multiplying two matrices
  • Finding the common elements in two arrays
  • Finding the difference between two sets or arrays
  • Finding the unique elements in an array
  • Finding whether a matrix is sparse
  • Merging two sorted arrays into one

Let's begin with the first recipe!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset