SlideShare une entreprise Scribd logo
1  sur  25
1D ARRAYS POONAM WALIA KV SHALIMAR BAGH
WHAT IS AN ARRAY ,[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]
NEED   FOR   AN ARRAY ,[object Object],[object Object],[object Object]
TYPES OF ARRAYS ,[object Object],[object Object]
One – Dimensional Array ,[object Object],[object Object],Base type of array Name of array No. of elements that can be stored: Can be a integer value without the sign
Ex :  MARKS [50] 0 1 2 3 49 MARKS [1] MARKS [3] . . .
ARRAY   INITIALIZATION ,[object Object],[object Object],[object Object],[object Object],[object Object]
Implementation of 1Dimensional Array in Memory  ,[object Object],[object Object],[object Object],[object Object]
Ex : What will be the adresses of element Marks[-1] and marks[2] of the following array with element size as 2 bytes and base address as 1000. Marks  -3 -2 -1 0 1 2 3 1000
SOL :  Address of Marks [I] = Base Address + ES ( I – L)  L  = -3 ES = 2 Base Address  = 1000 Address of Marks[-1]= 1000 + 2(-1-(-3))   = 1000+ 2(2)= 1004 Address of Marks[2]= 1000 + 2(2-(-3))   = 1000+ 2(5)= 1010
[object Object],[object Object],[object Object],Basic Operation on 1 Dimensional Arrays
[object Object],[object Object],[object Object],[object Object],[object Object],Linear Search or Sequential Search
Algorithm to perform a Sequential Search ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Binary Search  ,[object Object],[object Object],[object Object],[object Object],[object Object]
Algorithm to perform Binary Search ,[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]
Example of a Binary Search ,[object Object],[object Object]
Binary Search Example (con't) ,[object Object],[object Object]
Binary Search Example (con't) ,[object Object],[object Object]
Binary Search: Finding the search key ,[object Object],[object Object]
Binary Search Example 2 ,[object Object],[object Object]
Binary Search Example 2 (con't) ,[object Object],[object Object]
Binary Search Example 2 (con't) ,[object Object],[object Object]
Binary Search Example 2 (con't) ,[object Object],[object Object]
Binary Search 2: search key is not found ,[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Tendances (20)

Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
Data structure
Data structureData structure
Data structure
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
concept of Array, 1D & 2D array
concept of Array, 1D & 2D arrayconcept of Array, 1D & 2D array
concept of Array, 1D & 2D array
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
 
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]
 
Strings in c
Strings in cStrings in c
Strings in c
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 
Arrays
ArraysArrays
Arrays
 
Strings in c language
Strings in  c languageStrings in  c language
Strings in c language
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
Python set
Python setPython set
Python set
 
One Dimensional Array
One Dimensional Array One Dimensional Array
One Dimensional Array
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
 

En vedette (9)

C++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLESC++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLES
 
Array in C
Array in CArray in C
Array in C
 
1 d array
1 d array1 d array
1 d array
 
358 33 powerpoint-slides_5-arrays_chapter-5
358 33 powerpoint-slides_5-arrays_chapter-5358 33 powerpoint-slides_5-arrays_chapter-5
358 33 powerpoint-slides_5-arrays_chapter-5
 
Arrays Class presentation
Arrays Class presentationArrays Class presentation
Arrays Class presentation
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 

Similaire à 1 D Arrays in C++

Searching Sorting
Searching SortingSearching Sorting
Searching Sorting
guest2cb109
 
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 à 1 D Arrays in C++ (20)

Searching Sorting
Searching SortingSearching Sorting
Searching Sorting
 
Chap10
Chap10Chap10
Chap10
 
9 Arrays
9 Arrays9 Arrays
9 Arrays
 
Data Structures- Part3 arrays and searching algorithms
Data Structures- Part3 arrays and searching algorithmsData Structures- Part3 arrays and searching algorithms
Data Structures- Part3 arrays and searching algorithms
 
Searching
SearchingSearching
Searching
 
Sorting
SortingSorting
Sorting
 
advanced searching and sorting.pdf
advanced searching and sorting.pdfadvanced searching and sorting.pdf
advanced searching and sorting.pdf
 
ARRAY in python and c with examples .pptx
ARRAY  in python and c with examples .pptxARRAY  in python and c with examples .pptx
ARRAY in python and c with examples .pptx
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
 
arrays in c
arrays in carrays in c
arrays in c
 
MODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingMODULE 5-Searching and-sorting
MODULE 5-Searching and-sorting
 
9781439035665 ppt ch09
9781439035665 ppt ch099781439035665 ppt ch09
9781439035665 ppt ch09
 
Arrays
ArraysArrays
Arrays
 
DS Unit 1.pptx
DS Unit 1.pptxDS Unit 1.pptx
DS Unit 1.pptx
 
Arrays in C.pptx
Arrays in C.pptxArrays in C.pptx
Arrays in C.pptx
 
search_sort Search sortSearch sortSearch sortSearch sort
search_sort Search sortSearch sortSearch sortSearch sortsearch_sort Search sortSearch sortSearch sortSearch sort
search_sort Search sortSearch sortSearch sortSearch sort
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arrays
 
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
 
Array.pdf
Array.pdfArray.pdf
Array.pdf
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 

Plus de poonam.rwalia (7)

Inheritance
InheritanceInheritance
Inheritance
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Computer Ethics
Computer EthicsComputer Ethics
Computer Ethics
 
IT
ITIT
IT
 
Benefits Of Computer Software
Benefits Of Computer SoftwareBenefits Of Computer Software
Benefits Of Computer Software
 
Internet
InternetInternet
Internet
 
GIS
GISGIS
GIS
 

Dernier

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Dernier (20)

Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 

1 D Arrays in C++

  • 1. 1D ARRAYS POONAM WALIA KV SHALIMAR BAGH
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. Ex : MARKS [50] 0 1 2 3 49 MARKS [1] MARKS [3] . . .
  • 8.
  • 9.
  • 10. Ex : What will be the adresses of element Marks[-1] and marks[2] of the following array with element size as 2 bytes and base address as 1000. Marks -3 -2 -1 0 1 2 3 1000
  • 11. SOL : Address of Marks [I] = Base Address + ES ( I – L) L = -3 ES = 2 Base Address = 1000 Address of Marks[-1]= 1000 + 2(-1-(-3)) = 1000+ 2(2)= 1004 Address of Marks[2]= 1000 + 2(2-(-3)) = 1000+ 2(5)= 1010
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.