This document describes the linear search algorithm.
Linear search sequentially checks each element of a data structure one-by-one to find a target item. It works by traversing the list from the first element until either the target is found or all elements are checked. The worst-case complexity is O(n) as it may need to traverse the entire list. An example linear search on an array is provided to demonstrate how it checks each element sequentially until the target item is found or not.
linear search and binary search, Class lecture of Data Structure and Algorithms and Python.
Stack, Queue, Tree, Python, Python Code, Computer Science, Data, Data Analysis, Machine Learning, Artificial Intellegence, Deep Learning, Programming, Information Technology, Psuedocide, Tree, pseudocode, Binary Tree, Binary Search Tree, implementation, Binary search, linear search, Binary search operation, real-life example of binary search, linear search operation, real-life example of linear search, example bubble sort, sorting, insertion sort example, stack implementation, queue implementation, binary tree implementation, priority queue, binary heap, binary heap implementation, object-oriented programming, def, in BST, Binary search tree, Red-Black tree, Splay Tree, Problem-solving using Binary tree, problem-solving using BST, inorder, preorder, postorder
1 Create Python Lists
2 Mutable Lists
3 Traverse a List
4 Slice a List
5 Insert Into a List
6 Append to a List
7 Sort a List
8 Reverse a List
9 Index of an element
10 Delete an Element
11 Aggregate Functions
12 Compare Lists
13 Math Operations On Lists
14 Lists and Strings
15 Join a List
16 Aliasing
linear search and binary search, Class lecture of Data Structure and Algorithms and Python.
Stack, Queue, Tree, Python, Python Code, Computer Science, Data, Data Analysis, Machine Learning, Artificial Intellegence, Deep Learning, Programming, Information Technology, Psuedocide, Tree, pseudocode, Binary Tree, Binary Search Tree, implementation, Binary search, linear search, Binary search operation, real-life example of binary search, linear search operation, real-life example of linear search, example bubble sort, sorting, insertion sort example, stack implementation, queue implementation, binary tree implementation, priority queue, binary heap, binary heap implementation, object-oriented programming, def, in BST, Binary search tree, Red-Black tree, Splay Tree, Problem-solving using Binary tree, problem-solving using BST, inorder, preorder, postorder
1 Create Python Lists
2 Mutable Lists
3 Traverse a List
4 Slice a List
5 Insert Into a List
6 Append to a List
7 Sort a List
8 Reverse a List
9 Index of an element
10 Delete an Element
11 Aggregate Functions
12 Compare Lists
13 Math Operations On Lists
14 Lists and Strings
15 Join a List
16 Aliasing
It is a presentation on some Searching and Sorting Techniques for Computer Science.
It consists of the following techniques:
Sequential Search
Binary Search
Selection Sort
Bubble Sort
Insertion Sort
Searching in data structure refers to the process of finding the required information from a collection of items stored as elements in the computer memory. These sets of items are in different forms, such as an array, linked list, graph, or tree. Searching means locating a particular element in a collection of elements. Search result determines whether that particular element is present in the collection or not. If it is present, we can also find out the position of that element in the given collection. Searching is an important technique in computer science.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
2. Searching: Finding the location of item or
printing some message when item is not
found.
SEARCH
LINEAR BINARY
3. • Linear search: Traversing data sequentially to
locate item is called linear search.
• Ex: Searching an item for operation in array.
• Binary search: Data in array which is sorted in
increasing numerical order or alphabetically.
• Ex: Searching name in telephone directory,
searching words in dictionary.
4. LINEAR SEARCH
• It test whether the ITEM in DATA is present or
not.
• It test the data in sequential manner.
• It searches the data one by one fully and
returns the ITEM as the result.
• Otherwise, it returns the value 0.
• We see this by ALGORITHM.
6. STEPS:
1. [Insert ITEM at the end] Set DATA[N+1]:=ITEM.
2. [Initialize counter] Set LOC:=1.
3. [Search for ITEM]
Repeat while DATA[LOC]= ITEM:
Set LOC:=LOC+1.
[End if loop]
4. [Successful?]If LOC:=N+1, then ;
Set LOC:=0
5. Exit
8. • To find the item we are first inserting the item
to the end of the list.
• Step 1: DATA[N+1]=ITEM.
Exp:
N=6
DATA[6]=F
DATA[6+1]=G
• So the item is added at LOC[7]
A B C D E F G
1 2 3 4 5 6 7
9. • Step 2:
Initializing the counter to start the search.
Therefore, LOC=1.
It starts the search from LOC=1{i.e. from
DATA[1]=A}
• Step 3:
WHILE loop is executed till DATA[LOC]=ITEM
From the step 2, LOC=1
10. A B C D E F G
A B C D E F G
A B C D E F G
A B C D E F G
S
E
A
R
C
H
I
N
G
DATA[LOC] =ITEM
LOC=LOC+1
DATA[LOC] =ITEM, LOC=LOC+1
DATA[LOC] =ITEM
LOC=LOC+1
LOC=1
LOC=2
LOC=3
11. A B C D E F G
DATA[LOC] =ITEM,
LOC=LOC+1
S
E
A
R
C
H
I
N
G
A B C D E F G
DATA[LOC] =ITEM,
LOC=LOC+1
A B C D E F G
DATA[LOC]
=ITEM,
LOC=LOC+1
LOC=4
LOC=5
LOC=6
12. Here the item is found
The item ‘G’ is located
So the loop executes until this condition
A B C D E F G
DATA[LOC] =ITEM
LOC=7
13. • STEP 4:
Originally the location is 6. We added the
item at the end.
So the item is located in 7.
LOC=N+1
We reached the condition then
LOC=0
• STEP 5:
Searching is finished and the algorithm exits.
14. COMPLEXITY
• Worst Case: The maximum value to search.
• Complexity is measured by f(n).f(n)=n+1
• The average case is measured by probability.
• Here,
• pk – probability that ITEM appears in DATA[K].
• q – probability that ITEM does not appears in
DATA[K].
• Algorithm uses k comparisons when ITEM
appears in DATA[K].
15. • f(n)=1 . p1 + 2 . p2 + … +n . pn + (n+1) . q
• Suppose, q is very small and ITEm appears in
equal probability, then
q=o and pi=1/n
f(n)=1 . 1/n + 2 . 1/n + … +n . 1/n + (n+1).0
=(1+2+…+n) .1/n
=n(n+1)/2.(1/n)
f(n)=(n+1)/2