This presentation provides a brief introduction to data types and objects in R. I've not covered 'array' in the presentation, which is a multi-dimensional object [More general than matrix].
The document discusses data structures and algorithms related to arrays and linked lists. It covers key topics like:
1) Operations on arrays like insertion, deletion, and search. It also discusses multidimensional arrays and sparse matrices.
2) Linked list implementations including singly, doubly, and circular linked lists. Operations like insertion, deletion, and traversal are covered.
3) Linear list abstract data type (ADT) and its common operations like printing, making empty, finding, inserting, removing, and finding by index.
4) Implementation of linear lists using arrays and linked lists, including their pros and cons. Example code is provided for common array and linked list operations.
This presentation covers data structures including arrays, linked lists, and stacks. It discusses array types (one and multi-dimensional), linked list types (singly, doubly, circular), and common operations for each. Stack operations like push, pop, peek and applications for infix, prefix, postfix notation conversion are also explained with examples. Code snippets are provided for array traversal, insertion, deletion as well as linked list creation, insertion, deletion and traversal.
This document provides an introduction to data structures and algorithms. It defines data structures as a way of organizing data that considers both the items stored and their relationship. Common data structures include stacks, queues, lists, trees, graphs, and tables. Data structures are classified as primitive or non-primitive based on how close the data items are to machine-level instructions. Linear data structures like arrays and linked lists store data in a sequence, while non-linear structures like trees and graphs do not rely on sequence. The document outlines several common data structures and their characteristics, as well as abstract data types, algorithms, and linear data structures like arrays. It provides examples of one-dimensional and two-dimensional arrays and how they are represented in
The document presents information on arrays and do-while loops in programming. It discusses single and multi-dimensional arrays, how to declare and initialize them, and dynamic arrays. It also covers do-while loops, noting that they first test the condition and only execute the loop body if true, repeating until the condition becomes false. Examples are provided to demonstrate declaring arrays and using do-while loops to output numbers from 1 to 10.
The document discusses arrays, which are a fundamental data structure that store a collection of elements of the same type in contiguous memory locations that can be individually accessed via an index. It describes one-dimensional arrays as lists and two-dimensional arrays as matrices. Key aspects covered include the components of an array like elements, data type, subscript, and brackets. Operations on and applications of arrays are also summarized.
Homework Assignment – Array Technical DocumentWrite a technical .pdfaroraopticals15
Homework Assignment – Array Technical Document
Write a technical document that describes the structure and use of arrays. The document should
be 3 to 5 pages and include an Introduction section, giving a brief synopsis of the document and
arrays, a Body section, describing arrays and giving an annotated example of their use as a
programming construct, and a conclusion to revisit important information about arrays described
in the Body of the document. Some suggested material to include:
Declaring arrays of various types
Array pointers
Printing and processing arrays
Sorting and searching arrays
Multidimensional arrays
Indexing arrays of various dimension
Array representation in memory by data type
Passing arrays as arguments
If you find any useful images on the Internet, you can use them as long as you cite the source in
end notes.
Solution
Array is a collection of variables of the same type that are referenced by a common name.
Specific elements or variables in the array are accessed by means of index into the array.
If taking about C, In C all arrays consist of contiguous memory locations. The lowest address
corresponds to the first element in the array while the largest address corresponds to the last
element in the array.
C supports both single and multi-dimensional arrays.
1) Single Dimension Arrays:-
Syntax:- type var_name[size];
where type is the type of each element in the array, var_name is any valid identifier, and size is
the number of elements in the array which has to be a constant value.
*Array always use zero as index to first element.
The valid indices for array above are 0 .. 4, i.e. 0 .. number of elements - 1
For Example :- To load an array with values 0 .. 99
int x[100] ;
int i ;
for ( i = 0; i < 100; i++ )
x[i] = i ;
To determine to size of an array at run time the sizeof operator is used. This returns the size in
bytes of its argument. The name of the array is given as the operand
size_of_array = sizeof ( array_name ) ;
2) Initialisg array:-
Arrays can be initialised at time of declaration in the following manner.
type array[ size ] = { value list };
For Example :-
int i[5] = {1, 2, 3, 4, 5 } ;
i[0] = 1, i[1] = 2, etc.
The size specification in the declaration may be omitted which causes the compiler to count the
number of elements in the value list and allocate appropriate storage.
For Example :- int i[ ] = { 1, 2, 3, 4, 5 } ;
3) Multidimensional array:-
Multidimensional arrays of any dimension are possible in C but in practice only two or three
dimensional arrays are workable. The most common multidimensional array is a two
dimensional array for example the computer display, board games, a mathematical matrix etc.
Syntax :type name [ rows ] [ columns ] ;
For Example :- 2D array of dimension 2 X 3.
int d[ 2 ] [ 3 ] ;
A two dimensional array is actually an array of arrays, in the above case an array of two integer
arrays (the rows) each with three elements, and is stored row-wise in memory.
For Example :- Program to fill .
This is the second lecture in the CS 6212 class. Covers asymptotic notation and data structures. Also outlines the coming lectures wherein we will study the various algorithm design techniques.
This document provides an overview of common functions and operations in R including getting help, input and output, data creation and manipulation, variable conversion and information, plotting, and dates and times. It summarizes key functions for loading and saving data, reading from and writing to files, creating vectors, matrices and data frames, subsetting and manipulating data, performing mathematical and statistical operations, working with strings, and creating basic plots. The document is intended as a quick reference guide to common tasks in R.
This reference card summarizes common R functions for getting help, inputting and outputting data, creating and manipulating data, extracting and selecting data, converting variables, getting variable information, and performing mathematical operations. It provides the syntax and brief description for many basic and commonly used R functions across these categories in 3 sentences or less per function.
data structure programing language in c.pptLavkushGupta12
A data structure is a specialized format for organizing, processing, retrieving and storing data. There are several basic and advanced types of data structures, all designed to arrange data to suit a specific purpose
The document compares linear and non-linear data structures. Linear data structures have elements arranged sequentially that can each be accessed through a single traversal, while non-linear structures have hierarchical elements at multiple levels that require multiple traversals. Linear structures are easier to implement and traverse but use memory less efficiently, while non-linear structures use memory more efficiently but are more complex. Common examples of linear and non-linear structures provided are arrays/lists and graphs/trees respectively.
This document provides a concise reference card summarizing common functions and operations in R including getting help, input/output, data creation and manipulation, variable conversion and information, plotting, and dates/times. It covers essential functions for loading and saving data, accessing documentation, basic math operations, creating matrices and data frames, subsetting and selecting data, and creating basic plots and graphs.
This document provides a concise reference card summarizing common functions and operations in R including getting help, input and output, data creation, slicing and extracting data, variable conversion and information, data selection and manipulation, math operations, matrices, strings, dates and times, and plotting. It covers essential functions for loading and saving data, accessing documentation, basic data manipulation and common statistical analyses in R.
Arrays are a commonly used data structure that store multiple elements of the same type. Elements in an array are accessed using subscripts or indexes, with the first element having an index of 0. Multidimensional arrays can store elements in rows and columns, accessed using two indexes. Arrays are stored linearly in memory in either row-major or column-major order, which affects how elements are accessed.
The document discusses various data structures used in programming, including arrays, lists, linked lists, stacks, queues, and dictionaries. It provides definitions and summaries of each data structure, including their common operations and time complexities. For example, it notes that arrays provide O(1) direct access by index but fixed size, while lists are dynamically sized but insertion/deletion at non-end positions is O(n).
Numpy ndarrays are n-dimensional, homogeneous arrays that provide an efficient way to store and manipulate large multi-dimensional datasets. They are the fundamental data structure in NumPy that enables working with homogeneous data. An ndarray is created with a shape that defines its dimensions and a data type that specifies the type of data elements. It supports common operations like arithmetic, indexing/slicing, aggregation, reshaping and transposing. NumPy ndarrays are an essential tool for numerical computing and data analysis in Python.
This is a presentation on Arrays, one of the most important topics on Data Structures and algorithms. Anyone who is new to DSA or wants to have a theoretical understanding of the same can refer to it :D
Arrays in C++ in Tamil - TNSCERT SYLLABUS PPT LATHA LAKSHMI
This document provides an introduction and overview of arrays in C++. It discusses that an array allows storing multiple values of the same type referenced by a common name. The document then covers one-dimensional and multi-dimensional arrays. For one-dimensional arrays, it explains how they are stored contiguously in memory and how to declare, define, initialize, and access array elements. For two-dimensional arrays, it discusses how they store elements in a row-column matrix and how to define, initialize, and process 2D arrays using nested loops. The document also notes that strings can be implemented as character arrays in C++.
Here is the output of the given code segment:
int count = 0;
double sum = 0;
for (int row = 0; row <jagged.length; row++) {
count += jagged[row].length;
for(int col=0; col<jagged[row].length; col++) {
sum += jagged[row][col];
}
}
System.out.println("Number of elements: " + count);
System.out.println("Sum of all elements: " + sum);
The output would be:
Number of elements: 15
Sum of all elements: 52.0
The outer for loop iterates
Support vector machines (SVMs) are a type of supervised machine learning model used for classification and regression analysis. SVMs can handle both linearly separable and non-linearly separable data by mapping data points to a higher dimension feature space. Kernels are used to compute dot products between data points without explicitly computing coordinates in the feature space. SVMs select a subset of training points, called support vectors, to define the decision boundary. They have advantages like effectiveness in high dimensions and memory efficiency.
● Introduction to Arrays
● Declaration and initialization of one dimensional and two-dimensional
arrays.
● Definition and initialization of String
● String functions
An array is a collection of data items, all of the same type, accessed using a common name. A one-dimensional array is like a list; A two dimensional array is like a table; The C language places no limits on the number of dimensions in an array, though specific implementations may.
This document provides an overview of common functions and operations in R including getting help, input and output, data creation and manipulation, variable conversion and information, plotting, and dates and times. It summarizes key functions for loading and saving data, reading from and writing to files, creating vectors, matrices and data frames, subsetting and manipulating data, performing mathematical and statistical operations, working with strings, and creating basic plots. The document is intended as a quick reference guide to common tasks in R.
This reference card summarizes common R functions for getting help, inputting and outputting data, creating and manipulating data, extracting and selecting data, converting variables, getting variable information, and performing mathematical operations. It provides the syntax and brief description for many basic and commonly used R functions across these categories in 3 sentences or less per function.
data structure programing language in c.pptLavkushGupta12
A data structure is a specialized format for organizing, processing, retrieving and storing data. There are several basic and advanced types of data structures, all designed to arrange data to suit a specific purpose
The document compares linear and non-linear data structures. Linear data structures have elements arranged sequentially that can each be accessed through a single traversal, while non-linear structures have hierarchical elements at multiple levels that require multiple traversals. Linear structures are easier to implement and traverse but use memory less efficiently, while non-linear structures use memory more efficiently but are more complex. Common examples of linear and non-linear structures provided are arrays/lists and graphs/trees respectively.
This document provides a concise reference card summarizing common functions and operations in R including getting help, input/output, data creation and manipulation, variable conversion and information, plotting, and dates/times. It covers essential functions for loading and saving data, accessing documentation, basic math operations, creating matrices and data frames, subsetting and selecting data, and creating basic plots and graphs.
This document provides a concise reference card summarizing common functions and operations in R including getting help, input and output, data creation, slicing and extracting data, variable conversion and information, data selection and manipulation, math operations, matrices, strings, dates and times, and plotting. It covers essential functions for loading and saving data, accessing documentation, basic data manipulation and common statistical analyses in R.
Arrays are a commonly used data structure that store multiple elements of the same type. Elements in an array are accessed using subscripts or indexes, with the first element having an index of 0. Multidimensional arrays can store elements in rows and columns, accessed using two indexes. Arrays are stored linearly in memory in either row-major or column-major order, which affects how elements are accessed.
The document discusses various data structures used in programming, including arrays, lists, linked lists, stacks, queues, and dictionaries. It provides definitions and summaries of each data structure, including their common operations and time complexities. For example, it notes that arrays provide O(1) direct access by index but fixed size, while lists are dynamically sized but insertion/deletion at non-end positions is O(n).
Numpy ndarrays are n-dimensional, homogeneous arrays that provide an efficient way to store and manipulate large multi-dimensional datasets. They are the fundamental data structure in NumPy that enables working with homogeneous data. An ndarray is created with a shape that defines its dimensions and a data type that specifies the type of data elements. It supports common operations like arithmetic, indexing/slicing, aggregation, reshaping and transposing. NumPy ndarrays are an essential tool for numerical computing and data analysis in Python.
This is a presentation on Arrays, one of the most important topics on Data Structures and algorithms. Anyone who is new to DSA or wants to have a theoretical understanding of the same can refer to it :D
Arrays in C++ in Tamil - TNSCERT SYLLABUS PPT LATHA LAKSHMI
This document provides an introduction and overview of arrays in C++. It discusses that an array allows storing multiple values of the same type referenced by a common name. The document then covers one-dimensional and multi-dimensional arrays. For one-dimensional arrays, it explains how they are stored contiguously in memory and how to declare, define, initialize, and access array elements. For two-dimensional arrays, it discusses how they store elements in a row-column matrix and how to define, initialize, and process 2D arrays using nested loops. The document also notes that strings can be implemented as character arrays in C++.
Here is the output of the given code segment:
int count = 0;
double sum = 0;
for (int row = 0; row <jagged.length; row++) {
count += jagged[row].length;
for(int col=0; col<jagged[row].length; col++) {
sum += jagged[row][col];
}
}
System.out.println("Number of elements: " + count);
System.out.println("Sum of all elements: " + sum);
The output would be:
Number of elements: 15
Sum of all elements: 52.0
The outer for loop iterates
Support vector machines (SVMs) are a type of supervised machine learning model used for classification and regression analysis. SVMs can handle both linearly separable and non-linearly separable data by mapping data points to a higher dimension feature space. Kernels are used to compute dot products between data points without explicitly computing coordinates in the feature space. SVMs select a subset of training points, called support vectors, to define the decision boundary. They have advantages like effectiveness in high dimensions and memory efficiency.
● Introduction to Arrays
● Declaration and initialization of one dimensional and two-dimensional
arrays.
● Definition and initialization of String
● String functions
An array is a collection of data items, all of the same type, accessed using a common name. A one-dimensional array is like a list; A two dimensional array is like a table; The C language places no limits on the number of dimensions in an array, though specific implementations may.
The *nervous system of insects* is a complex network of nerve cells (neurons) and supporting cells that process and transmit information. Here's an overview:
Structure
1. *Brain*: The insect brain is a complex structure that processes sensory information, controls behavior, and integrates information.
2. *Ventral nerve cord*: A chain of ganglia (nerve clusters) that runs along the insect's body, controlling movement and sensory processing.
3. *Peripheral nervous system*: Nerves that connect the central nervous system to sensory organs and muscles.
Functions
1. *Sensory processing*: Insects can detect and respond to various stimuli, such as light, sound, touch, taste, and smell.
2. *Motor control*: The nervous system controls movement, including walking, flying, and feeding.
3. *Behavioral responThe *nervous system of insects* is a complex network of nerve cells (neurons) and supporting cells that process and transmit information. Here's an overview:
Structure
1. *Brain*: The insect brain is a complex structure that processes sensory information, controls behavior, and integrates information.
2. *Ventral nerve cord*: A chain of ganglia (nerve clusters) that runs along the insect's body, controlling movement and sensory processing.
3. *Peripheral nervous system*: Nerves that connect the central nervous system to sensory organs and muscles.
Functions
1. *Sensory processing*: Insects can detect and respond to various stimuli, such as light, sound, touch, taste, and smell.
2. *Motor control*: The nervous system controls movement, including walking, flying, and feeding.
3. *Behavioral responses*: Insects can exhibit complex behaviors, such as mating, foraging, and social interactions.
Characteristics
1. *Decentralized*: Insect nervous systems have some autonomy in different body parts.
2. *Specialized*: Different parts of the nervous system are specialized for specific functions.
3. *Efficient*: Insect nervous systems are highly efficient, allowing for rapid processing and response to stimuli.
The insect nervous system is a remarkable example of evolutionary adaptation, enabling insects to thrive in diverse environments.
The insect nervous system is a remarkable example of evolutionary adaptation, enabling insects to thrive
How to Manage Purchase Alternatives in Odoo 18Celine George
Managing purchase alternatives is crucial for ensuring a smooth and cost-effective procurement process. Odoo 18 provides robust tools to handle alternative vendors and products, enabling businesses to maintain flexibility and mitigate supply chain disruptions.
APM event hosted by the Midlands Network on 30 April 2025.
Speaker: Sacha Hind, Senior Programme Manager, Network Rail
With fierce competition in today’s job market, candidates need a lot more than a good CV and interview skills to stand out from the crowd.
Based on her own experience of progressing to a senior project role and leading a team of 35 project professionals, Sacha shared not just how to land that dream role, but how to be successful in it and most importantly, how to enjoy it!
Sacha included her top tips for aspiring leaders – the things you really need to know but people rarely tell you!
We also celebrated our Midlands Regional Network Awards 2025, and presenting the award for Midlands Student of the Year 2025.
This session provided the opportunity for personal reflection on areas attendees are currently focussing on in order to be successful versus what really makes a difference.
Sacha answered some common questions about what it takes to thrive at a senior level in a fast-paced project environment: Do I need a degree? How do I balance work with family and life outside of work? How do I get leadership experience before I become a line manager?
The session was full of practical takeaways and the audience also had the opportunity to get their questions answered on the evening with a live Q&A session.
Attendees hopefully came away feeling more confident, motivated and empowered to progress their careers
How to manage Multiple Warehouses for multiple floors in odoo point of saleCeline George
The need for multiple warehouses and effective inventory management is crucial for companies aiming to optimize their operations, enhance customer satisfaction, and maintain a competitive edge.
What makes space feel generous, and how architecture address this generosity in terms of atmosphere, metrics, and the implications of its scale? This edition of #Untagged explores these and other questions in its presentation of the 2024 edition of the Master in Collective Housing. The Master of Architecture in Collective Housing, MCH, is a postgraduate full-time international professional program of advanced architecture design in collective housing presented by Universidad Politécnica of Madrid (UPM) and Swiss Federal Institute of Technology (ETH).
Yearbook MCH 2024. Master in Advanced Studies in Collective Housing UPM - ETH
Title: A Quick and Illustrated Guide to APA Style Referencing (7th Edition)
This visual and beginner-friendly guide simplifies the APA referencing style (7th edition) for academic writing. Designed especially for commerce students and research beginners, it includes:
✅ Real examples from original research papers
✅ Color-coded diagrams for clarity
✅ Key rules for in-text citation and reference list formatting
✅ Free citation tools like Mendeley & Zotero explained
Whether you're writing a college assignment, dissertation, or academic article, this guide will help you cite your sources correctly, confidently, and consistent.
Created by: Prof. Ishika Ghosh,
Faculty.
📩 For queries or feedback: [email protected]
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 795 from Texas, New Mexico, Oklahoma, and Kansas. 95 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...Celine George
Analytic accounts are used to track and manage financial transactions related to specific projects, departments, or business units. They provide detailed insights into costs and revenues at a granular level, independent of the main accounting system. This helps to better understand profitability, performance, and resource allocation, making it easier to make informed financial decisions and strategic planning.
GDGLSPGCOER - Git and GitHub Workshop.pptxazeenhodekar
This presentation covers the fundamentals of Git and version control in a practical, beginner-friendly way. Learn key commands, the Git data model, commit workflows, and how to collaborate effectively using Git — all explained with visuals, examples, and relatable humor.
This chapter provides an in-depth overview of the viscosity of macromolecules, an essential concept in biophysics and medical sciences, especially in understanding fluid behavior like blood flow in the human body.
Key concepts covered include:
✅ Definition and Types of Viscosity: Dynamic vs. Kinematic viscosity, cohesion, and adhesion.
⚙️ Methods of Measuring Viscosity:
Rotary Viscometer
Vibrational Viscometer
Falling Object Method
Capillary Viscometer
🌡️ Factors Affecting Viscosity: Temperature, composition, flow rate.
🩺 Clinical Relevance: Impact of blood viscosity in cardiovascular health.
🌊 Fluid Dynamics: Laminar vs. turbulent flow, Reynolds number.
🔬 Extension Techniques:
Chromatography (adsorption, partition, TLC, etc.)
Electrophoresis (protein/DNA separation)
Sedimentation and Centrifugation methods.
Contact Lens:::: An Overview.pptx.: OptometryMushahidRaza8
A comprehensive guide for Optometry students: understanding in easy launguage of contact lens.
Don't forget to like,share and comments if you found it useful!.
2. Sequential Organization
Sequential organization allows storing data at a fixed
distance apart.
If the ith element is stored at location X, then the next
sequential (i+1)th
element is stored at location X+C, where C is
constant.
3. ARRAYS
If we intend to store a group of data together in a sequential manner in
computer’s memory, then arrays can be one of the possible data structures.
An array is a finite ordered collection of homogeneous data elements which
provides direct access (or random access) to any of its elements.
An array as a data structure is defined as a set of pairs (index, value) such
that with each index a value is associated.
• index — indicates the location of an element in an array.
• value - indicates the actual value of that data element.
• Declaration of an array in ‘C++’:
int A[20];
4. GENERIC DATA TYPE
Generic Data type is a data type where the
operations are defined but the types of the
items being manipulated are not
5. ARRAYS AS AN ADT
Formally ADT is a collection of domain, operations, and axioms (or rules)
For defining an array as an ADT, we have to define its very basic operations or
functions that can be performed on it
The basic operations of arrays are creation of an array, storing an element,
accessing an element, and traversing the array.
Let us specify ADT Array in which we provide specifications with operations to
be performed.
ADT ARRAY(Index, Value)
declare CREATE( ) array
ACCESS (array, index) value
STORE (array, index, value) array
for all Array_A ε array, x Î value, and i, j ε index let
ACCESS (CREATE, i) = error.
ACCESS (STORE (Array_A, i, x), j) = x if EQUAL (i, j)
else ACCESS (Array_A, j)
end
end ARRAY.
6. MEMORY REPRESENTATION & ADDRESS
CALCULATION
A0
A1
.
.
.
Ai
.
An-1
a i
ai+1
ai+2
:
:
an-1
X(Base)
X+1
X+2
X+(n-1)
Array A
The address of the ith
element is calculated by the following
formula
• (Base address) + (offset of the ith
element from base address)
• Here, base address is the address of the first element where
array storage starts.
7. Arrays support various operations such as traversal, sorting,
searching, insertion, deletion, merging, block movement, etc.
Insertion of an element into an array
Deleting an element
Memory Representation of Two-Dimensional Arrays
Row-major Representation
Column-major Representation
9. ROW-MAJOR REPRESENTATION
In row-major representation, the elements of
Matrix are stored row-wise, i.e., elements of 1st row,
2nd row, 3rd row, and so on till mth
row
(0,0) (0,1) (0,2) (0,3) (1,0) (1,1) (1,2) (1,3) (2,0) (2,1) (2,2) (2,3)
Row1 Row2 Row3
1 2 3 4 5 6 7 8 9 10 11 12
10. ROW MAJOR ARRANGEMENT
Address of A[i][j] = base addr + (col_index * total no. of rows +
row_index) element size
Row 0
Row 1
Row m-1
Row 0
Row 1
Row
m-1
Memory Location
Row-major arrangement in memory , in row major representation
11. COLUMN-MAJOR ARRANGEMENT
Address of A[i][j] = base addr + (row_index * total no. of columns +
col_index) *element size
col1 col2
Col
n-1
Col
0
Col
1
Col
2
Memory Location
…
Column-major arrangement in memory , in column major representation
12. (0,0) (1,0) (2,0) (0,1) (1,1) (2,1) (0,2) (1,2) (2,2) (0,3) (1,3) (2,3)
Col 1 Col 2 Col 3 Col 4
1 2 3 4 5 6 7 8 9 10 11 12
Column-Major Representation of 2-D array
17. ARRAYS USING TEMPLATE
The function is defined in similar way replacing int by T as
datatype of member of array
In all member functions header, Array is replaced by Array
<T> :: now
Following statements instantiate the template class Array to int
and float respectively. So P is array of ints and Q in array of
floats.
Array <int> P;
Array <float> Q;
In similar we can also have array of any user defined data type
18. CONCEPT OF ORDERED LIST
Ordered list is the most common and frequently used data object
Def: it is set of elements where set may be empty or it can be written as
collection of elements such as (a1, a2, a3 ………, an)
Linear elements of an ordered list are related with each other in a particular
order or sequence
Following are some examples of the ordered list.
• 1, 3,5,7,9,11,13,15
• January, February, March, April, May, June, July, August, September,
• October, November, December
• Red, Blue, Green, Black, Yellow
19. There are many basic operations that can be performed on the ordered list as
follows:
Finding the length of the list
Traverse the list from left to right or from right to left
Access the ith element in the list
Update (Overwrite) the value of the ith position
Insert an element at the ith location
Delete an element at the ith position
21. SINGLE VARIABLE POLYNOMIAL
Representation Using Arrays
Array of Structures
Polynomial Evaluation
Polynomial Addition
Multiplication of Two Polynomials
22. Polynomial as an ADT, the basic operations
are as follows:
Creation of a polynomial
Addition of two polynomials
Subtraction of two polynomials
Multiplication of two polynomials
Polynomial evaluation
25. STRUCTURE IS BETTER THAN ARRAY
FOR POLYNOMIAL:
Such representation by an array is both time and space efficient when
polynomial is not a sparse one such as polynomial P(x) of degree 3 where P(x)=
3x3+x2–2x+5.
But when polynomial is sparse such as in worst case a polynomial as A(x)= x99
+ 78 for degree of n =100, then only two locations out of 101 would be used.
In such cases it is better to store polynomial as pairs of coefficient and exponent.
We may go for two different arrays for each or a structure having two members
as two arrays for each of coeff. and Exp or an array of structure that consists of
two data members coefficient and exponent.
26. POLYNOMIAL BY USING STRUCTURE
Let us go for structure having two data
members coefficient and exponent and its
array.
27. AN ARRAY FOR FREQUENCY COUNT
We can use array to store the number of times a particular
element occurs in any sequence. Such occurrence of
particular element is known as frequency count.
void Frequency_Count ( int Freq[10 ], int A [ 100])
{
int i;
for ( i=0;i<10;i++)
Freq[i]=0;
for ( i=0;i<100;i++)
Freq[A[i] ++;
}
29. SPARSE MATRIX
In many situations, matrix size is very large but out of
it, most of the elements are zeros (not necessarily
always zeros).
And only a small fraction of the matrix is actually
used. A matrix of such type is called a sparse matrix,
35. Time complexity will be O (n . T)
= O (n . mn)
= O (mn2
)
which is worst than the conventional transpose with
time complexity O (mn)
Simple Sparse matrix transpose
36. FAST SPARSE MATRIX TRANSPOSE
In worst case, i.e. T= m × n (non-zero elements) the
magnitude becomes O (n +mn) = O (mn) which is the
same as 2-D transpose
However the constant factor associated with fast
transpose is quite high
When T is sufficiently small, compared to its maximum of
m . n, fast transpose will work faster
37. STRING MANIPULATION
Def: String is sequence of characters. The strings are defined with double quotes.
The string is stored in the memory with terminating character ‘0’.
There are various operations that can be performed on the string:
To find the length of a string (strlen)
To concatenate two strings (strcat)
To copy a string (strcpy)
To reverse a string (strrev)
String compare (strcmp, strcmpi)
Palindrome check
To recognize a sub string. (strstr)
38. BASICALLY A STRING IS STORED AS A SEQUENCE
OF CHARACTERS IN ONE-DIMENSIONAL
CHARACTER ARRAY SAY A.
CHAR A[10] ="STRING" ;
EACH STRING IS TERMINATED BY A SPECIAL
CHARACTER THAT IS NULL CHARACTER ‘0’.
THIS NULL CHARACTER INDICATES THE END OR
TERMINATION OF EACH STRING.
39. CHARACTERISTICS OF ARRAY
An array is a finite ordered collection of homogeneous data
elements.
In array, successive elements of list are stored at a fixed distance
apart.
Array is defined as set of pairs-( index and value).
Array allows random access to any element
In array, insertion and deletion of elements in between positions
requires data movement.
Array provides static allocation, which means space allocation
done once during compile time, can not be changed run time.
40. ADVANTAGE OF ARRAY
DATA STRUCTURE
Arrays permit efficient random access in constant time 0(1).
Arrays are most appropriate for storing a fixed amount of data and also for high
frequency of data retrievals as data can be accessed directly.
Wherever there is a direct mapping between the elements and there positions,
arrays are the most suitable data structures.
Ordered lists such as polynomials are most efficiently handled using arrays.
Arrays are useful to form the basis for several more complex data structures,
such as heaps, and hash tables and can be used to represent strings, stacks and
queues.
41. DISADVANTAGE OF
ARRAY DATA STRUCTURE
Arrays provide static memory management. Hence
during execution the size can neither be grown nor
shrunk.
Array is inefficient when often data is to inserted or
deleted as inserting and deleting an element in array
needs a lot of data movement.
Hence array is inefficient for the applications, which
very often need insert and delete operations in
between.
42. APPLICATIONS OF ARRAYS
Although useful in their own right, arrays also form the basis for
several more complex data structures, such as heaps, hash tables
and can be used to represent strings, stacks and queues.
All these applications benefit from the compactness and direct
access benefits of arrays.
Two-dimensional data when represented as Matrix and matrix
operations.