Linear search, Data Structure & Algorithms

Assignment Help:

Linear search is not the most efficient way to search an item within a collection of items. Though, it is extremely simple to implement. Furthermore, if the array elements are arranged into random order, it is the merely a reasonable way to search. Additionally, efficiency becomes significant only in large arrays; if the array is small, there aren't various elements to search and the amount of time it takes is not even noticed by the user. Therefore, for several conditions, linear search is a perfectly valid approach.

Before learning Linear Search, let us described some terms associated to search.

A file is a set of records and a record is in turn a collection of fields. A field, that is utilized to differentiate among several records, is known as a 'key'.

For instance, the telephone directory that we discussed in earlier section can be assumed as a file, where each record contains two fields: name of the person & phone number of the person.

Now, it depends on the application whose field will be the 'key'. It can be the name of person (usual case) and it can also be phone number. We will situate any particular record by matching the input argument 'a' with the key value.

The simplest of all the searching techniques is Linear or Sequential Search. As the name suggests, all the records in a file are searched sequentially, one by one, for the matching of key value, till a match occurs.

The Linear Search is applicable to a table which it should be organised in an array. Let us assume that a file contains 'n' records and a record has 'a' fields but only one key. The values of key are organised in an array say 'm'. As the file has 'n' records, the size of array will be 'n' and value at position R(i) will be the key of record at position i. Also, let us assume that 'el' is the value for which search has to be made or it is the search argument.


Related Discussions:- Linear search

Two sparce matrices multipilcation algorithm, Write an algorithm for multi...

Write an algorithm for multiplication of two sparse matrices using Linked Lists.

What is binary space partition, Binary Space Partition A binary space-p...

Binary Space Partition A binary space-partitioning (BSP) tree is an efficient method for determining object visibility by painting surfaces onto the screen from back to front,

Applications in file systems of avl trees, 1. In computer science, a classi...

1. In computer science, a classic problem is how to dynamically store information so as to let for quick look up. This searching problem arises frequently in dictionaries, symbol t

Methods of collision resolution, Methods of Collision Resolution 1)  Co...

Methods of Collision Resolution 1)  Collision Resolution by separate chaining  2)  Collision Resolution by open addressing

Rotations in binary tree, H o w can you r ot a t e a B i n a r y...

H o w can you r ot a t e a B i n a r y Tr e e? E x pl a i n r i g h t a n d l eft r ot a tion s by taking an e x a mpl e.   If after

Just a quick couple questions, I was wanting to know where this web site wa...

I was wanting to know where this web site was created. My second question is,,, are the online tuters accredited teachers? If they are, are they only working for the website or ma

Data Structure, Ask consider the file name cars.text each line in the file ...

Ask consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is repr

Show that towers of hanoi is o (2n), Question 1 Discuss the advantages of ...

Question 1 Discuss the advantages of implementation checks preconditions Question 2 Write a ‘C' program to search for an item using binary search Question 3 Show that To

What is string, What is String Carrier set of the String ADT is the s...

What is String Carrier set of the String ADT is the set of all finite sequences of characters from some alphabet, including empty sequence (the empty string). Operations on s

Queue, what''s queue ?

what''s queue ?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd