SlideShare a Scribd company logo
1 of 4
Download to read offline
​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

What's hot

Physics Investigatory Project Class 12
Physics Investigatory Project Class 12Physics Investigatory Project Class 12
Physics Investigatory Project Class 12
Self-employed
 
Physics investigatory project
Physics investigatory projectPhysics investigatory project
Physics investigatory project
Mihika Mahandwan
 

What's hot (17)

Adulterants in food stuff 1
Adulterants in food stuff 1Adulterants in food stuff 1
Adulterants in food stuff 1
 
Computer Science Investigatory Project Class XII CBSE(Latest Syllabus)(Python...
Computer Science Investigatory Project Class XII CBSE(Latest Syllabus)(Python...Computer Science Investigatory Project Class XII CBSE(Latest Syllabus)(Python...
Computer Science Investigatory Project Class XII CBSE(Latest Syllabus)(Python...
 
english class 11 project
english class 11 projectenglish class 11 project
english class 11 project
 
Chemistry investigatory project adultration in food stuffs
Chemistry investigatory project adultration in food stuffsChemistry investigatory project adultration in food stuffs
Chemistry investigatory project adultration in food stuffs
 
Physics Investigatory - Electromagnetic Induction. CLASS XII
Physics Investigatory - Electromagnetic Induction.    CLASS XIIPhysics Investigatory - Electromagnetic Induction.    CLASS XII
Physics Investigatory - Electromagnetic Induction. CLASS XII
 
Computer project final for class 12 Students
Computer project final for class 12 StudentsComputer project final for class 12 Students
Computer project final for class 12 Students
 
Study of quantity of caesin present in different samples of milk
Study of quantity of caesin present in different samples of milkStudy of quantity of caesin present in different samples of milk
Study of quantity of caesin present in different samples of milk
 
determination of contents of diffrent brands of cold drinks
determination of contents of diffrent brands of cold drinksdetermination of contents of diffrent brands of cold drinks
determination of contents of diffrent brands of cold drinks
 
Chemistry Investigatory Project 12 CBSE
Chemistry Investigatory Project 12 CBSE Chemistry Investigatory Project 12 CBSE
Chemistry Investigatory Project 12 CBSE
 
Biology project
Biology projectBiology project
Biology project
 
Factors_On_Which_Self_Inductance_Of_Coil (2) (1).docx
Factors_On_Which_Self_Inductance_Of_Coil (2) (1).docxFactors_On_Which_Self_Inductance_Of_Coil (2) (1).docx
Factors_On_Which_Self_Inductance_Of_Coil (2) (1).docx
 
Physics Investigatory Project
Physics Investigatory  ProjectPhysics Investigatory  Project
Physics Investigatory Project
 
Physics Investigatory Project Class 12
Physics Investigatory Project Class 12Physics Investigatory Project Class 12
Physics Investigatory Project Class 12
 
Chemistry Investigatory Project of class 12th CBSE
Chemistry Investigatory Project  of class 12th CBSEChemistry Investigatory Project  of class 12th CBSE
Chemistry Investigatory Project of class 12th CBSE
 
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12
Computer Science(083) Python Pre Board Exam 1 Sample Paper Class 12
 
Preparation of Soyabean Milk - 4 | CBSE Class 12 | Edu Resources
Preparation of Soyabean Milk - 4 | CBSE Class 12 | Edu ResourcesPreparation of Soyabean Milk - 4 | CBSE Class 12 | Edu Resources
Preparation of Soyabean Milk - 4 | CBSE Class 12 | Edu Resources
 
Physics investigatory project
Physics investigatory projectPhysics investigatory project
Physics investigatory project
 

More from chinthala Vijaya Kumar

More from chinthala Vijaya Kumar (10)

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

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 

Recently uploaded (20)

Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 

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