5.7K views

Uploaded by Junaid khan

save

- DD
- arry
- Algorithms and Complexity I
- Unit-1 Introduction to Computer Problem-Solving
- Array Exercise VI
- GUIA DE APRENDIZAJE Nº02
- Lab Session
- Introduction to Perl
- lect-3-4
- cug
- DS-UNIT-5
- 2010 State of the Data Center
- Sorting
- New Microsoft Word Document
- Linear Binary Search Seminar
- c02 hardware
- Dvp5990k 55 Fur Eng
- Kamus Excel
- adv.programming + programming
- MATLAB Contents
- FORMULA.xls
- Flowchart Symbols Defined
- Teori-excel Lengkap Dan Familiar-complete
- System Units
- 1-s2.0-S0305048309000723-main
- Kamus Excel
- lecture1-m-Introduction.ppt
- Task IT
- Binary Search das
- How to Control Access to NLS
- Transition Graph
- Prospector Expert System
- Error Handler
- Error Handler
- Turing Machine
- Difference Bw Databas and Expert System
- Difference Between Oop & Strctr Prgmng
- Machine Learning
- Non Regular Languages 2
- Neural Network
- kleen theorem
- Puff Expert System
- Symbol Table
- Prospector Expert System
- MYCIN Expert System
- index file Organization
- Binary search
- Macsyma Expert System
- Dendral Expert System
- Junaid (Quick Sort)
- Java 2
- Graph Terminology
- Fundamental File Structure Concepts
- Pre Order Traversal
- Raid
- Data Base Models
- Bubble sort
- FDDI
- Inline Function

You are on page 1of 13

By Junaid Ali Siddiqui

Searching

Computer systems are often used to store large amounts of data from which individual records are retrieved according to some searching criteria. The process of finding the location of a specific data item or record with a given key value or finding the locations of all records which satisfy one or more conditions in a list is called “Searching”. If the item exists in the given list then search is said to be successful otherwise if the element is not found in the given list then search is said to be unsuccessful. Searching a telephone number in a telephone directory is an example of searching.

**MAIN TYPES OF SEARCHING
**

Internal Search

The search in which the whole list resides in the main memory is called internal search.

External search

The search in which most of the list resides in the secondary memory is called external search.

SOME IMPORTANT POINTS

In Data structures when we use the word searching ,we actually refer to internal searching. The complexity of any searching method is determined from the number of comparisons performed among the elements of the list in order to find the element. The time required for a search operation depends on the complexity of the searching algorithm.

**Basically we have to consider three cases when we search for a particular element in the list.
**

Best case

The best case is that in which the element is found during the first comparison.

Worst case

The worst case is that in which the element is found only at the end i.e. in the last comparison.

Average case

The average case is that in which the element is found in comparisons more than best case but less than worst case.

**Types of searching algorithms
**

There are two types of searching algorithm which are listed below. Sequential search Binary search

Sequential Search

It is also called linear search. It is the simplest way for finding an element in a list. It searches the element sequentially in a list, no matter whether list is sorted or unsorted. In case of sorted list in ascending order, the search is started from 1st element and continued until the desired element is found or the element whose value is greater than the value being searched. In case of sorted list in descending order, the search is started from 1st element and continued until the desired element is found or the element whose value is smaller than the value being searched. If the list is unsorted searching started from 1st location and continued until the element is found or the end of the list is reached.

SOME DRAWBACKS

It is a very slow process. It is used only for small amount of data. It is a very time consuming method.

**Algorithm sequential search
**

This algorithm is used for linear searching. ITEM is to be searched in a linear array DATA having N elements. LOC is variable which store the location in case of successful search and in case of unsuccessful search LOC will contain 0.

**LINEAR SEARCH ALGORITHM
**

Step 1: [Insert ITEM at the end of DATA] SetDATA[N+1]:=ITEM Step 2:[Initialize counter] Set LOC:=1 Step 3:[Search for ITEM] Repeat while DATA[LOC] !=ITEM Set LOC:=LOC+1. [End of loop] Step 4:[Successful?] if LOC=N+1,then Set LOC:=0 Step 5:Exit [Finish].

**Complexity Of Linear search algorithm
**

Linear search provide complexity for finding an element in an array because linear search is a step-by-step process, in which specific element is compared with each element of array. In linear search complexity is due to two cases. It is possible that required element occurs at the end of the array. So linear search consumes more time. It is also possible that required element is not present in the given array, this is the worst case. In this case the algorithm requires f(n)=n+1 comparisons. If the element is at first position in array then only one comparison will be needed.

Suppose pk is the probability that ITEM appears in DATA[K] and suppose q is the probability that ITEM does not appear in DATA. (Then p1+p2+………+pn+q=1.) Since the algorithm uses k comparisons when ITEM appears in DATA[K], the average number of comparisons is given by f(n)=1xp1+2xp2+………+nxpn+(n+1)xq. In particular, suppose q is very small and ITEM appears with equal probability in each element of DATA. Then q is approximately equal to 0 and each pi =1/n. Accordingly, f(n)=1x1/n+2x1/n+……..+nx1/n+(n+1)x0=(1+2+…. +n)x1/n =n(n+1)/2x1/n=(n+1)/2 That is, in this special case, the average number of comparisons required to find the location of ITEM is approximately equal to half the number of elements in the array.

**Message from presenter:
**

“Try to hide bad qualities of others Allah will hide yours in the day of judgment....”

THANK YOU!

- DDUploaded byprasunnatasha
- arryUploaded byParas Joshi
- Algorithms and Complexity IUploaded bySly2518
- Unit-1 Introduction to Computer Problem-SolvingUploaded byVivekananda Ganjigunta Narayana
- Array Exercise VIUploaded bySbo
- GUIA DE APRENDIZAJE Nº02Uploaded byErica Gonzalez
- Lab SessionUploaded byUshanth Ganatheeswaran
- Introduction to PerlUploaded byamit_s_725
- lect-3-4Uploaded byHumera Gull
- cugUploaded bygoutam4321
- DS-UNIT-5Uploaded bySreehari E
- 2010 State of the Data CenterUploaded bybenjezus
- SortingUploaded byDilip Kumar
- New Microsoft Word DocumentUploaded byfresher_shruti
- Linear Binary Search SeminarUploaded bypassionflare
- c02 hardwareUploaded byapi-276092706
- Dvp5990k 55 Fur EngUploaded byancarsil
- Kamus ExcelUploaded byHusen Hidayatullah
- adv.programming + programmingUploaded byFara Honey
- MATLAB ContentsUploaded byJoseph John
- FORMULA.xlsUploaded byIgp Yoga
- Flowchart Symbols DefinedUploaded byApril Oliveros
- Teori-excel Lengkap Dan Familiar-completeUploaded byCalvinders
- System UnitsUploaded byAsjad Jamshed
- 1-s2.0-S0305048309000723-mainUploaded byMohamed Mansour
- Kamus ExcelUploaded bySuga Ahmadi
- lecture1-m-Introduction.pptUploaded byedwardntambi
- Task ITUploaded bySkefadiuto
- Binary Search dasUploaded byAndrei Bzk
- How to Control Access to NLSUploaded bymana

- Transition GraphUploaded byJunaid khan
- Prospector Expert SystemUploaded byJunaid khan
- Error HandlerUploaded byJunaid khan
- Error HandlerUploaded byJunaid khan
- Turing MachineUploaded byJunaid khan
- Difference Bw Databas and Expert SystemUploaded byJunaid khan
- Difference Between Oop & Strctr PrgmngUploaded byJunaid khan
- Machine LearningUploaded byJunaid khan
- Non Regular Languages 2Uploaded byJunaid khan
- Neural NetworkUploaded byJunaid khan
- kleen theoremUploaded byJunaid khan
- Puff Expert SystemUploaded byJunaid khan
- Symbol TableUploaded byJunaid khan
- Prospector Expert SystemUploaded byJunaid khan
- MYCIN Expert SystemUploaded byJunaid khan
- index file OrganizationUploaded byJunaid khan
- Binary searchUploaded byJunaid khan
- Macsyma Expert SystemUploaded byJunaid khan
- Dendral Expert SystemUploaded byJunaid khan
- Junaid (Quick Sort)Uploaded byJunaid khan
- Java 2Uploaded byJunaid khan
- Graph TerminologyUploaded byJunaid khan
- Fundamental File Structure ConceptsUploaded byJunaid khan
- Pre Order TraversalUploaded byJunaid khan
- RaidUploaded byJunaid khan
- Data Base ModelsUploaded byJunaid khan
- Bubble sortUploaded byJunaid khan
- FDDIUploaded byJunaid khan
- Inline FunctionUploaded byJunaid khan