- The elements of a two dimensional array are stored in computer’s memory row by row or column by column.
- If the array is stored as row by row, it is called row-major order.
- If the array is stored as column by column, it is called column-major order.
- Suppose there is a two-dimensional array of size 5 × 6. That means, there are 5 rows and 6 columns in the array.
- In row-major order, elements of a two dimensional array are ordered as –
- A11, A12, A13, A14, A15, A16, A21, A22, A23, A24, A25, A26, A31, ............, A46, A51, A52, .......,A56.
- and in column-major order, elements are ordered as –
- A11, A21, A31, A41, A51, A12, A22, A32, A42, A52, A13, ............, A55, A16, A26, .......,A56.
Two dimensional array representation in memory
Time complexity
This complexity is related to execution time of the algorithm.
It depends on the number of element (item) comparisons and number of element movement (movement of data from one place to another).
However, the complexity of the most of the algorithms described here related to the number of element comparisons.
That means, the complexity of the algorithm is computed with respect to the total number of element (item) comparisons needed for the algorithm
Preview <<<<<<
It depends on the number of element (item) comparisons and number of element movement (movement of data from one place to another).
However, the complexity of the most of the algorithms described here related to the number of element comparisons.
That means, the complexity of the algorithm is computed with respect to the total number of element (item) comparisons needed for the algorithm
Preview <<<<<<
Importance of data structure
- Computer science as well as computer engineering deals with two jargons which are software and hardware.
- Without software, hardware (electrical, mechanical, electronic parts of computer that we see and touch) is useless.
- So, study of software is very important in computer science, and software consists of programs which use different types of data.
- In a program we not only use elementary data items but also use different types of organized data. That means we use data structure in a program. As we know we write programs to solve problems. That is, to solve problems we have to use data structures. The different data structures give us different types of facilities.
- If we need to store data in such a way that we have to retrieve data directly irrespective of their storage location. We can get this facility using one type of data structure such as array gives us such facility.
program
Program
- Sequence of instructions of any programming language that can be followed to perform a particular task.
- For a particular problem, at first we may write an algorithm then the algorithm may be converted into a program.
- In a program usually we use a large amount of data. Most of the cases these data are not elementary items, where exists structural relationship between elementary data items.
That means the programs uses data structure(s).
Algorithm
Set or sequence of instructions (steps) that can be followed to perform a task (problem).
Do not strictly follow grammar of any particular programming language.
However its language may be near to a programming language.
preview <<
Do not strictly follow grammar of any particular programming language.
However its language may be near to a programming language.
q Each and every algorithm can be divided into three sections.
v First section is input section, where we show which data elements are to be given.
v The second section is very important one, which is operational or processing section. Here we have to do all necessary operations, such as computation, taking decision, calling other procedure (algorithm) etc.
v The third section is output, where we display the result found from the second section
preview <<
BackgRound2
Example of Data Structures:
Array, Linked List, Stack, Queue, Tree, Graph, Hash
Table etc.
Types of elementary data item:
Character, Integer, Floating point numbers etc.
Expressions of elementary data in C/C++
Elementary data item - Expression in C/C++
Character - char
Integer - int
Floating point number - float
preview <<
Array, Linked List, Stack, Queue, Tree, Graph, Hash
Table etc.
Types of elementary data item:
Character, Integer, Floating point numbers etc.
Expressions of elementary data in C/C++
Elementary data item - Expression in C/C++
Character - char
Integer - int
Floating point number - float
preview <<
BackgRound
Elementary items constitute a unit and that unit may be considered as a structure.
.>> structure may be treated as a frame or proforma where we organize some elementary items in different ways.
Data structure is a structure or unit where we organize elementary data items in different ways.
>>That means, a data structure is a means of structural relationships of elementary data items for storing and retrieving data in computer’s memory.
Usually elementary data items are the elements of a data structure.
However, a data structure may be an element of another data structure. That means a data structure may contain another data structure
.>> structure may be treated as a frame or proforma where we organize some elementary items in different ways.
Data structure is a structure or unit where we organize elementary data items in different ways.
>>That means, a data structure is a means of structural relationships of elementary data items for storing and retrieving data in computer’s memory.
Usually elementary data items are the elements of a data structure.
However, a data structure may be an element of another data structure. That means a data structure may contain another data structure
Identify data structure
Data structure
- Elementary items constitute a unit and that unit may be considered as a structure.
- Data structure is a structure or unit where we organize elementary data items in different ways.
- Usually elementary data items are the elements of a data structure.
- However, a data structure may be an element of another data structure. That means a data structure may contain another data structure.
Subscribe to:
Posts (Atom)
Followers
About Me
- ..
- Dhaka, Dhaka, Bangladesh
- ..