
1D Array: Linear Search and Bubble Sort Concepts
Explore the fundamentals of linear search and bubble sort techniques using 1D arrays. Learn about searching and sorting methodologies, array syntax, initialization, reading, writing, and pseudo code examples for linear search. Gain insights into finding data items and arranging elements in a particular order through linear search and bubble sort. Enhance your understanding of arrays and algorithms for effective data manipulation.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Use of 1D Array: Linear Search and Bubble Sort
Objectives To learn and appreciate the following concepts Searching Technique Linear Search 4/3/2025 CSE 1001 Department of CSE 2
Arrays A recap 1D Array: Syntax: type array_name[size]; Initialization: type array-name [size]={list of values} Read: Write: for(i=0;i<n;i++) for(i=0;i<n;i++) scanf( %d ,&a[i]); printf( %d ,a[i]); 4/3/2025 CSE 1001 Department of CSE 3
Searching Finding whether a data item is present in a set of items linear search / sequential search 4/3/2025 CSE 1001 Department of CSE 4
Linear search- illustration 1 4/3/2025 CSE 1001 Department of CSE 5
Linear search- illustration 2 4/3/2025 CSE 1001 Department of CSE 6
Pseudo code for linear search /*search procedure*/ for(i=0; i<n; i++) { int found=0; //setting flag Print Print "enter no of numbers"; if(a[ i ]==key) // comparison { Input Input n; found=1; for(i=0;i<n;i++){ pos=i+1; Print Print enter number\n"; break; } } Input Input a[i]; // entered data items if(found==1) } Print data_found_in ,pos, Print Print enter the element to be "position"; otherwise searched"; Print data is not found ; Input Input key; // data to be searched 4/3/2025 CSE 1001 Department of CSE 7
Sorting Techniques L17-L18 4/3/2025 CSE 1001 Department of CSE 8
Objectives To learn and appreciate the following concepts Sorting Technique Bubble Sort 4/3/2025 CSE 1001 Department of CSE 9
Sorting Arrangement of data elements in a particular order Bubble sorting 4/3/2025 CSE 1001 Department of CSE 10
Bubble Sort- Illustration 4/3/2025 CSE 1001 Department of CSE 11
Bubble Sort- Illustration 4/3/2025 CSE 1001 Department of CSE 12
Pseudo code for Bubble Sort procedure for(i=0;i<n;i++) Example : Input a[i]; // entered elements a[ ]={16, 12, 11, 67} for(i=0;i<n-1;i++) //pass Array after sorting (ascending) a[ ]={11, 12, 16, 67} { for(j=0;j<n-i-1;j++) { if(a[j]>a[j+1]) // comparison { // interchange temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } 4/3/2025 CSE 1001 Department of CSE 13