SlideShare une entreprise Scribd logo
1  sur  24
Linear Data Structures ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Representation of Single Dimensional Arrays ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],elem n-1 … elem i … elem 2 elem 1 elem 0
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],float sum (float list[], int n)‏ { float temp = 0; int i; for (i = 0; i < n; i++)‏ temp = temp + list[i]); return temp; }
Representation of Two Dimensional Array ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Representations of Table ,[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],What’s wrong?
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Why?
[object Object],Offset of a[i][j]? 54 345 106 0 99 82 76 22 64 38 2 3 6 3 5 1 User’s view (abstraction)‏ 54 345 106 0 99 82 76 22 64 38 2 3 6 3 5 1 System’s view (implementation)‏
[object Object],Offset of a[i][j]? Number of elements in each row? i th  row  total elements in the previous rows? j th  element in i th  row Offset (in units)  N i * N i * N + j The addressing formula needs to know the number of columns but does not need the number of rows! 54 345 106 0 99 82 76 22 64 38 2 3 6 3 5 1 User’s view (abstraction)‏
[object Object],[object Object],[object Object],Two Dimensional Array
[object Object],[object Object],[object Object],[object Object],Multi-Dimensional Arrays A[D 0 ] [D 1 ]…[D n-1 ] (…((d 0 *D 1  + d 1 )*D 2  + d 2 )*D 3  + …) + d n-1
Simple View ,[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],Special Matrices
Ordered Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Operations Defined on an Ordered List ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Representation of an Ordered List ,[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Linear List Using Arrays
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],void LinearList :: readjust(int index) { if ((index < (size - 1)) &&  (ListArray[index] > ListArray[index + 1]))‏ moveForward(index); else if ((index > 0)  &&  (ListArray[index] < ListArray[index - 1]))‏ moveBackward(index); }
void LinearList :: moveForward(int index) { int temp = ListArray[index]; int i = index; while ((i < (size - 1)) &&  (ListArray[i] > ListArray[i + 1])) { ListArray[i] = ListArray[i+1]; i = i + 1; } if (i != index)  ListArray[i] = temp; } void LinearList :: moveBackward(int index) { int temp = ListArray[index]; int i = index; while ((i > 0 ) &&  (ListArray[i] < ListArray[i - 1])) { ListArray[i] = ListArray[i-1]; i = i - 1; } if (i != index)  ListArray[i] = temp; }
Assignment# 1  last date of submission :  02-09-2008 (Tuesday)‏ ,[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Tendances (20)

Singly & Circular Linked list
Singly & Circular Linked listSingly & Circular Linked list
Singly & Circular Linked list
 
Insertion sort algorithm power point presentation
Insertion  sort algorithm power point presentation Insertion  sort algorithm power point presentation
Insertion sort algorithm power point presentation
 
Binary tree and operations
Binary tree and operations Binary tree and operations
Binary tree and operations
 
Sparse matrix
Sparse matrixSparse matrix
Sparse matrix
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 
Binary Tree in Data Structure
Binary Tree in Data StructureBinary Tree in Data Structure
Binary Tree in Data Structure
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Singly link list
Singly link listSingly link list
Singly link list
 
Binary search tree in data structures
Binary search tree in  data structuresBinary search tree in  data structures
Binary search tree in data structures
 
Linear Search Data Structure
Linear Search Data StructureLinear Search Data Structure
Linear Search Data Structure
 
Stack a Data Structure
Stack a Data StructureStack a Data Structure
Stack a Data Structure
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
 
Tuple in python
Tuple in pythonTuple in python
Tuple in python
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
Binary tree
Binary tree Binary tree
Binary tree
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Data structure
Data structureData structure
Data structure
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Queue in Data Structure
Queue in Data StructureQueue in Data Structure
Queue in Data Structure
 

En vedette

Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithmsLecture 3 data structures and algorithms
Lecture 3 data structures and algorithms
Aakash deep Singhal
 
Lecture 8 data structures and algorithms
Lecture 8 data structures and algorithmsLecture 8 data structures and algorithms
Lecture 8 data structures and algorithms
Aakash deep Singhal
 
Representation of binary tree in memory
Representation of binary tree in memoryRepresentation of binary tree in memory
Representation of binary tree in memory
Rohini Shinde
 

En vedette (13)

2D Array
2D Array2D Array
2D Array
 
Arrays
ArraysArrays
Arrays
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
 
Arrays
ArraysArrays
Arrays
 
Spoj Hints
Spoj HintsSpoj Hints
Spoj Hints
 
Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithmsLecture 3 data structures and algorithms
Lecture 3 data structures and algorithms
 
Lecture 8 data structures and algorithms
Lecture 8 data structures and algorithmsLecture 8 data structures and algorithms
Lecture 8 data structures and algorithms
 
Representation of binary tree in memory
Representation of binary tree in memoryRepresentation of binary tree in memory
Representation of binary tree in memory
 
Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modes
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 
Array in C
Array in CArray in C
Array in C
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 

Similaire à 02 Arrays And Memory Mapping

9781439035665 ppt ch09
9781439035665 ppt ch099781439035665 ppt ch09
9781439035665 ppt ch09
Terry Yoast
 
Python Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfPython Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdf
MCCMOTOR
 

Similaire à 02 Arrays And Memory Mapping (20)

DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCEDATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
 
Array
ArrayArray
Array
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
 
Aj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructuresAj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructures
 
Data structure
Data  structureData  structure
Data structure
 
Abstract Algebra and Category Theory
Abstract Algebra and Category Theory Abstract Algebra and Category Theory
Abstract Algebra and Category Theory
 
Data structures: linear lists
Data structures: linear listsData structures: linear lists
Data structures: linear lists
 
Data structure array
Data structure  arrayData structure  array
Data structure array
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
DS Unit 1.pptx
DS Unit 1.pptxDS Unit 1.pptx
DS Unit 1.pptx
 
9781439035665 ppt ch09
9781439035665 ppt ch099781439035665 ppt ch09
9781439035665 ppt ch09
 
Python list
Python listPython list
Python list
 
GE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_NotesGE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_Notes
 
Chap09
Chap09Chap09
Chap09
 
lec4.ppt
lec4.pptlec4.ppt
lec4.ppt
 
Python Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfPython Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdf
 
1st lecture.ppt
1st lecture.ppt1st lecture.ppt
1st lecture.ppt
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

02 Arrays And Memory Mapping

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23. void LinearList :: moveForward(int index) { int temp = ListArray[index]; int i = index; while ((i < (size - 1)) && (ListArray[i] > ListArray[i + 1])) { ListArray[i] = ListArray[i+1]; i = i + 1; } if (i != index) ListArray[i] = temp; } void LinearList :: moveBackward(int index) { int temp = ListArray[index]; int i = index; while ((i > 0 ) && (ListArray[i] < ListArray[i - 1])) { ListArray[i] = ListArray[i-1]; i = i - 1; } if (i != index) ListArray[i] = temp; }
  • 24.

Notes de l'éditeur

  1. One of the most common data object is an ordered list. An ordered list has elements with definite ordering. The simplest example of an ordered list is an ordered pair which has only two elements. Following are some examples of ordered lists: Months of the years (Jan, Feb, Mar, Apr, May,…., Dec)‏ English Alphabets (A, B, C, …, Z)‏ Words in a sentence (“This is a book on data structures.”)‏ Names of the students in a class stored in the order of their roll numbers. It may be noted that the elements in an ordered-list must maintain a specified order. For example, changing the orders of words in a sentence will change the sentence. That is, it will no longer be the same sentence. As an abstract data type, an ordered-list will typically support the following operations: Create a new empty list. Delete a list. Find the number of elements in the list or length of the list. Check if the list is empty. Check if more elements can be added to the list or whether the list is full. Traverse the list in some order. Get the i th elements in the list. Change the value of the i th element. Insert a new element at the i th position. Insert a new element according to the specified order. Delete the i th element. The easiest way to represent an ordered list is by an one-dimensional array where we store the i th element of the list in the array element with index i. This is called sequential or linear mapping. That is mapping a one-dimensional vector onto a one-dimensional space.
  2. It is always a very good idea to explicitly keep track of the number elements in a list. This will make your life more comfortable. Your algorithms simpler and will be more independent of the data type stored in your list.