2
Most read
​GVK Chinmaya Vidyalaya
Inserting an element in a sorted array using traditional algorithm
Approach 1:
C. Vijaya Kumar
​B.Tech,MBA
​GVK Chinmaya Vidyalaya
Explanation:
item=80
10 20 30 40 50 60 70
80<ar[0]
False
​pos=-1
10 20 30 40 50 60 70
i = 0 ar[0]<=80 and 80<=ar[1]
​False
10 20 30 40 50 60 70
i = 1 ar[ 1 ] <= 80 and 80 <= ar[ 2 ]
​ False
C. Vijaya Kumar
​B.Tech,MBA
​GVK Chinmaya Vidyalaya
10 20 30 40 50 60 70
i = 2 ar [2]<= 80 and 80 <=ar[3]
​ False
10 20 30 40 50 60 70
i = 3 ar[3]<=80 and 80<=ar[4]
​ False
10 20 30 40 50 60 70
i = 4 ar[4]<=80 and 80<=ar[5]
​ False
10 20 30 40 50 60 70
i = 5 ar[5]<=80 and 80<=ar[6]
​False
10 20 30 40 50 60 70
i = 6 while condition ​False
C. Vijaya Kumar
​B.Tech,MBA
​GVK Chinmaya Vidyalaya
If (pos==-1 and i<=size-1): True and True
Pos = 7
return pos
ar=[10, 20, 30, 40, 50, 60, 70]
pos = 7
ar.append(​None​)
10 20 30 40 50 60 70 None
Size = 8
i = 7
While 7>=7:
ar[ 7 ] = ar[ 6 ]
i = 6
10 20 30 40 50 60 70 70
While 6>=7: False
mylist [ 7 ] = 80
10 20 30 40 50 60 70 80
C. Vijaya Kumar
​B.Tech,MBA

More Related Content

PDF
Toyota 62-6FD20 Forklift Service Repair Manual
PDF
Partek sisu diesel engine 420 series service repair manual
PPTX
Data Structures_Searching and Sorting.pptx
PDF
Insertion sort
PPTX
Sorting Algorithm and different types of sorting algorithm
PPTX
366 it elective 4 (analysis of algoritm)
PPTX
Insertion Sort, Quick Sort And Their complexity
PPT
insertion sort.ppt
Toyota 62-6FD20 Forklift Service Repair Manual
Partek sisu diesel engine 420 series service repair manual
Data Structures_Searching and Sorting.pptx
Insertion sort
Sorting Algorithm and different types of sorting algorithm
366 it elective 4 (analysis of algoritm)
Insertion Sort, Quick Sort And Their complexity
insertion sort.ppt

Similar to Inserting an element in a sorted array using traditional algorithm (20)

PPTX
Data structures (Array 1 dimensional).pptx
PPTX
Insertion sort algorithm power point presentation
PPT
DSSchapt13.ppt
PPTX
Advanced Sorting Algorithms
PPTX
Complexity in array
PPTX
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
PPTX
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
PPTX
All Searching and Sorting Techniques in Data Structures
PPSX
Lecture 2 data structures & algorithms - sorting techniques
PDF
PDF
Study on Sorting Algorithm and Position Determining Sort
PDF
Quick sort,bubble sort,heap sort and merge sort
PPTX
9.Sorting & Searching
PPT
SEARCHING AND SORTING ALGORITHMS
PDF
Lecture12,13,14.pdf
PPT
PPTX
Arrays
PDF
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
PPTX
sorting-160810203705.pptx
PPT
Sorting
Data structures (Array 1 dimensional).pptx
Insertion sort algorithm power point presentation
DSSchapt13.ppt
Advanced Sorting Algorithms
Complexity in array
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
All Searching and Sorting Techniques in Data Structures
Lecture 2 data structures & algorithms - sorting techniques
Study on Sorting Algorithm and Position Determining Sort
Quick sort,bubble sort,heap sort and merge sort
9.Sorting & Searching
SEARCHING AND SORTING ALGORITHMS
Lecture12,13,14.pdf
Arrays
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
sorting-160810203705.pptx
Sorting
Ad

More from chinthala Vijaya Kumar (11)

PDF
GVKCV Computer Science(083) Pre board sample paper 2 Class 12 (20-21) with so...
PDF
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12
PDF
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
PDF
Binary search in Python using recursion
PDF
Linear search python CBSE Class 12
PDF
Data visualization pyplot
PDF
Data handling CBSE PYTHON CLASS 11
PDF
PDF
Python Fundamentals Class 11
PDF
File handling CBSE CLASS 12
PDF
Recursion CBSE Class 12
GVKCV Computer Science(083) Pre board sample paper 2 Class 12 (20-21) with so...
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
Binary search in Python using recursion
Linear search python CBSE Class 12
Data visualization pyplot
Data handling CBSE PYTHON CLASS 11
Python Fundamentals Class 11
File handling CBSE CLASS 12
Recursion CBSE Class 12
Ad

Recently uploaded (20)

PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Empowerment Technology for Senior High School Guide
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
My India Quiz Book_20210205121199924.pdf
PDF
IGGE1 Understanding the Self1234567891011
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PPTX
Computer Architecture Input Output Memory.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
Uderstanding digital marketing and marketing stratergie for engaging the digi...
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
Complications of Minimal Access-Surgery.pdf
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
International_Financial_Reporting_Standa.pdf
PPTX
20th Century Theater, Methods, History.pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Empowerment Technology for Senior High School Guide
Weekly quiz Compilation Jan -July 25.pdf
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
My India Quiz Book_20210205121199924.pdf
IGGE1 Understanding the Self1234567891011
Share_Module_2_Power_conflict_and_negotiation.pptx
What if we spent less time fighting change, and more time building what’s rig...
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
Computer Architecture Input Output Memory.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Paper A Mock Exam 9_ Attempt review.pdf.
Uderstanding digital marketing and marketing stratergie for engaging the digi...
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Complications of Minimal Access-Surgery.pdf
TNA_Presentation-1-Final(SAVE)) (1).pptx
Introduction to pro and eukaryotes and differences.pptx
International_Financial_Reporting_Standa.pdf
20th Century Theater, Methods, History.pptx

Inserting an element in a sorted array using traditional algorithm

  • 1. ​GVK Chinmaya Vidyalaya Inserting an element in a sorted array using traditional algorithm Approach 1: C. Vijaya Kumar ​B.Tech,MBA
  • 2. ​GVK Chinmaya Vidyalaya Explanation: item=80 10 20 30 40 50 60 70 80<ar[0] False ​pos=-1 10 20 30 40 50 60 70 i = 0 ar[0]<=80 and 80<=ar[1] ​False 10 20 30 40 50 60 70 i = 1 ar[ 1 ] <= 80 and 80 <= ar[ 2 ] ​ False C. Vijaya Kumar ​B.Tech,MBA
  • 3. ​GVK Chinmaya Vidyalaya 10 20 30 40 50 60 70 i = 2 ar [2]<= 80 and 80 <=ar[3] ​ False 10 20 30 40 50 60 70 i = 3 ar[3]<=80 and 80<=ar[4] ​ False 10 20 30 40 50 60 70 i = 4 ar[4]<=80 and 80<=ar[5] ​ False 10 20 30 40 50 60 70 i = 5 ar[5]<=80 and 80<=ar[6] ​False 10 20 30 40 50 60 70 i = 6 while condition ​False C. Vijaya Kumar ​B.Tech,MBA
  • 4. ​GVK Chinmaya Vidyalaya If (pos==-1 and i<=size-1): True and True Pos = 7 return pos ar=[10, 20, 30, 40, 50, 60, 70] pos = 7 ar.append(​None​) 10 20 30 40 50 60 70 None Size = 8 i = 7 While 7>=7: ar[ 7 ] = ar[ 6 ] i = 6 10 20 30 40 50 60 70 70 While 6>=7: False mylist [ 7 ] = 80 10 20 30 40 50 60 70 80 C. Vijaya Kumar ​B.Tech,MBA