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

Define about the structure - container, Define about the Structure - Contai...

Define about the Structure - Container - Some containers hold elements in some sort of structure, and some don't. Containers with no structure include bags and sets. Containe

Operations on sequential files, Insertion: Records has to be inserted at t...

Insertion: Records has to be inserted at the place dictated by the sequence of keys. As is obvious, direct insertions into the main data file would lead to frequent rebuilding of

Which is the most suitable data type, Problem 1. You are asked to store...

Problem 1. You are asked to store Names of all 100 students of class A in your Learning Centre. Which data type will you use? What is its syntax? Explaining the data typ

Space-complexity of the algorithm, The space-complexity of the algorithm is...

The space-complexity of the algorithm is a constant. It just needs space of three integers m, n and t. Thus, the space complexity is O(1). The time complexity based on the loop

Asymptotic analysis, Asymptotic Analysis Asymptotic analysis is dependi...

Asymptotic Analysis Asymptotic analysis is depending on the idea that as the problem size grows, the complexity can be defined as a simple proportionality to some known functio

A full binary tree with 2n+1 nodes, A full binary tree with 2n+1 nodes have...

A full binary tree with 2n+1 nodes have n non-leaf nodes

Write a program to create a heap file, Write a program to create a heap fil...

Write a program to create a heap file that holds the records in the file " data_2013 " The source records are variablelength.However, the heap file should hold fixed-length reco

Explain the term heuristics searching, (a) Discuss the role played by Busin...

(a) Discuss the role played by Business Intelligence Systems in giving companies strategic advantage. (b) Explain the term heuristics searching . (c) With the use of an appr

Explain about hubs, Hubs - In reality a multiport repeater - Connect...

Hubs - In reality a multiport repeater - Connects stations in a physical star topology - As well may create multiple levels of hierarchy to remove length limitation of 10

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