0% found this document useful (0 votes)
2 views

Array Notes

The document provides an overview of dimensional arrays, including their definition, types (single and two-dimensional), and the need for them in organizing data. It outlines methods for creating and storing elements in arrays, basic operations such as searching and sorting, and compares linear and binary search as well as bubble sort and selection sort. Additionally, it explains the concept of composite data types and the differences between single and double dimensional arrays.

Uploaded by

nayakashutosh324
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Array Notes

The document provides an overview of dimensional arrays, including their definition, types (single and two-dimensional), and the need for them in organizing data. It outlines methods for creating and storing elements in arrays, basic operations such as searching and sorting, and compares linear and binary search as well as bubble sort and selection sort. Additionally, it explains the concept of composite data types and the differences between single and double dimensional arrays.

Uploaded by

nayakashutosh324
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Grade 10

Arrays - Notes
1. Dimensional Array:
A dimensional array is a structure created in the memory to represent a number of values of the same
data type with the variables having the same variable name along with different subscripts.
2. Two types of dimensional array:
Single dimensional array and Two dimensional array
3. What is the need of Dimensional Array? Explain
Variables are useful for keeping track of a single piece of information but as we collect more and more
information, keeping the variables organized can be complicated. In such situations, we need arrays to
solve the problems in a much better and efficient way.
4. A dimensional array is also called a subscripted variable.
5. An array with empty [] represents an unfixed number of cells in memory.
6. Index of an array having ‘n’ elements vary from 0 to n-1
7. Syntax for creating a single dimensional array:
<datatype> <variable>[]= new <datatype> <number of elements>;
Eg: int a[]= new int[10];
8. The different methods to store elements in an array are as follows:
a. Assignment statement:
int a[]= {1,2,3,4,5};
b. Using BlueJ system:
public static void main(int a[])
{//body
}
c. Using Scanner method:
The elements are accepted from the user using Scanner functions inside a loop.
for(i=0;i<5;i++)
{ a[i] = in.nextInt();
}
9. Name two basic operations performed on an array: Searching and Sorting
10. Name two types of searching techniques: Linear and Binary search
11. Name two types of sorting techniques: Selection sort and Bubble sort
12. Selection search is also known as Sequential search. It is the simplest technique in which an item is
searched from the starting position - one by one until the number is found or the end of the array.
13. Binary search is a technique used to find an element in the minimum possible time. It divides the
array into two halves and performs the search. The array needs to be sorted.
Algorithm/ Steps:
● Start with the middle element of the array as a current key.
● If the middle element value matches the target element then return the index of the middle
element.
● Else check if the target element is lesser than the middle element, then continue the search in
the left half.
● If the target element is greater than the middle element, then continue the search in the right
half.
● Check from the second point repeatedly until the value is found or the array is empty.
● If still unable to find the target, display search not successful

14. Difference between linear and binary search?

Linear search Binary search

The linear search starts searching It finds the position of the searched
from the first element and element by finding the middle element
compares each element with a array.
searched element till the element
found.
In a linear search, the elements don't The pre-condition for the binary search is
need to be arranged in sorted order. that the elements must be arranged in a
order.

It is based on the sequential approach. It is based on the divide and conquer


approach.

It is preferrable for the small-sized data It is preferrable for the large-size data sets.

15. Difference between selection sort and bubble sort?

Bubble Sort Selection Sort

Bubble sort is a simple sorting Selection sort is a sorting algorithm


algorithm which continuously which takes either smallest value
moves through the list and (ascending order) or largest value
compares the adjacent pairs for (descending order) in the list and
proper sorting of the elements. place it at the proper position in the
list.

Bubble sort compares the Selection sort selects the smallest


adjacent elements and move element from the unsorted list and
accordingly. moves it at the next position of the
sorted list.
Bubble sort performs a large Selection sort performs
number of swaps or moves to comparatively less number of swaps
sort the list. or moves to sort the list.

Bubble sort is relatively slower. Selection sort is faster as compared to


bubble sort.

The efficiency of the bubble sort The efficiency of the selection sort is
is less. high.

Bubble sort performs sorting of Selection sort performs sorting of a


an array by exchanging list by the selection of element.
elements.

16. Array is called a composite datatype. Why?


The data type that represents a number of similar or different data under single declaration
is called as composite data type. An array is a group or a collection of same type of
variables. Hence, Array is a composite data type
17. Difference between single dimensional arrays and double dimensional array?

SDA DDA

It is represented along X-axis It is represented along X-axis and


Y-axis

The variables with same name The variables with the same name
have single subscript have two subscripts representing row
number and column number.

It is called single subscripted It is called double subscripted


variable variable

18. Syntax for creating a double dimensional array:


<datatype> <variable>[] []= new <datatype> [number of elements in row] [number of elements in
column];
Eg: int a[] []= new int[2] [3];
8. The different methods to store elements in an array are as follows:
d. Assignment statement:
int a[]= {{1,2{, {3,4}, {5,6}};
e. Using BlueJ system:
public static void main(int a[] [])
{//body
}
f. Using Scanner method:
The elements are accepted from the user using Scanner functions inside a loop.
for(i=0;i<2;i++)
for(j=0;j<3;j++)
{ a[i] [j] = in.nextInt();
}

You might also like