0% found this document useful (0 votes)
3 views4 pages

G10. Ln3

The document provides an overview of dimensional arrays, explaining single and double dimensional arrays, their constructs, and the need for them in organizing data. It differentiates between various terms related to arrays, such as subscript and subscripted variable, and discusses sorting and searching algorithms. Additionally, it compares linear and binary search methods, as well as sorting techniques like selection sort and bubble sort.
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)
3 views4 pages

G10. Ln3

The document provides an overview of dimensional arrays, explaining single and double dimensional arrays, their constructs, and the need for them in organizing data. It differentiates between various terms related to arrays, such as subscript and subscripted variable, and discusses sorting and searching algorithms. Additionally, it compares linear and binary search methods, as well as sorting techniques like selection sort and bubble sort.
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/ 4

Lesson 3: Arrays ( Single dimensional and Double dimensional)

Write short answers

1.​ What is meant by dimensional array?


Ans:- 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.
A Dimensional array is also called a subscripted variable.

2.​ Name the two types of dimensional array.


Ans:- a) Single dimensional array
b) Double dimensional array.

3.​ What is the need of dimensional array? Explain


Ans:- 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.​ ‘Array is a composite data type’. Explain this statement.


Ans:- Composite data type represents a set of similar or different data type .A
array use number of variables declared within the same data type this is the reason
why a array is said to be composite data type.

5.​ Define the following with their constructs.


a.​ Single dimensional array.
Single dimensional array is a structure that
is represented along the x axis by using a number of variables with the same
name having different subscripts.
Single dimensional array is also called a single subscripted variable
because each element of an array is represented using the same variable
name along with the single subscript.
Construct:-
<Data type><variable>[ ]= new <Data type>
<Number of values to be stored>;

b.​ Double dimensional array


Double dimensional array is a structure represented along the x axis and y
axis.
X axis - rows, y axis - columns .
The elements of a double dimensional array can be addressed using row
number and column number.
A Double dimensional array is also
referred to as a double subscripted variable because it uses two types of
subscripts.
Construct:-
<Data type>< variable>[ ] [ ]= new <Data type>
[Number of rows][Number of columns];

VI. Differentiate between the following

1.​ Subscript and subscripted variable


Ans :-

Subscript Subscripted variable

1)Subscript is the 1)Subscripted variable is


index of the element the name of the array
in the array. when it is used with a
subscript to access a
single element of the
array.

2.​ Char a [5] and int a[5]


Ans:-

char a[5] int a [5]

1)char a[5] is an 1)int a[5] is an array of int


array of char data data type.
type.
2)This array can hold 2)This array can hold 5
5 characters. integer values.

3.​ Ordinary variable and array variable


Ans:-

Ordinary variable Array variable

1)An ordinary 1)An array variable can


variable can hold refer to a group of values
only one value. of the same data type by
using a subscript.
2)For example: 2)For example:
int a; int a[ ] = new int[5];
Here variable a Here variable a[ ] can store
holds one int type 5 integer type values which
value. will be accessed as a[0],
a[1], a[2], a[3] and a[4];

4.​ String a [5] and String a [ ]


Ans:-
String a[5] String a [ ]

1)This declares an array 1)This declares an array


named a that can hold 5 named a that can hold
string values. Each strings, but the size of the
position in the array array is not fixed at the time
(indexed from 0 to 4) can of declaration
store a string.

2)The size of the array is 2)The array's size can be


fixed at 5 when it's determined later, when you
created. create the array with new
String[size] where size is the
desired number of strings.

5.​ Sorting and Searching


Ans :-

Sorting Searching

1) Sorting is a system of 1) searching is used to


arranging elements in a determine whether the given
specific order. It can be in number or character or word
ascending or descending or name is present in the array
order or not

2)Ex:- Selection sort 2)Ex:- Linear search


Bubble sort Binary search

6.​ Linear search and Binary search


Ans:-

Linear search Binary search


1)Linear search works 1)Binary search works on only
on sorted and sorted arrays (ascending or
unsorted arrays descending)

2)Each element of the 2)Array is successively divided


array is checked against into 2 halves and the target
the target value until the element is searched either in
element is found or end the first half or in the second
of the array is reached half

3)Linear Search is 3)Binary Search is faster


slower

7.​ Sequential sort and bubble sort


Ans:-

Sequential sort Bubble sort

1)Selection Sort selects 1)Bubble Sort compares adjacent


the smallest element from elements and swaps them if they
an unsorted subarray and are in the wrong order.
swaps it with the leftmost
unsorted element.

2)Performs lesser number 2)Performs more number of swaps


of swaps to sort the same to sort the array
array relative to Bubble
Sort

3)Selection Sort is faster 3)Bubble Sort is slower

8.​ length and length ( )


Ans:-

length length ( )

1)length is an attribute 1)length() is a member


i.e. a data member of method of String class.
array.

2)It gives the length of 2)It gives the number of


an array i.e. the number characters present in a
of elements stored in string.
an array.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy