Results 1 to 4 of 4

Thread: What is linear search in data structure?

  1. #1
    Join Date
    Dec 2010
    Posts
    12

    What is linear search in data structure?

    Hey friends, I want to know the basic topics of data structure you can say the starting topic of data structure. I am thinking to learn data structure but before that I want to know the basics of data structure. If I could know some of the basic topics of data structure then I could have some basic knowledge about it. So, if anybody having any data regarding this topic then please let me know.

  2. #2
    Join Date
    Apr 2009
    Posts
    488

    Re: What is linear search in data structure?

    This is simplest method of searching. In this method, the element to be found is sequentially searched in the list. This method can be applied to a sorted list or unsorted list. Searching in case of Sorted list starts from 0th elements and continues until the element is found or an element whose value is greater than the value being searched is reached. You might find this searching method as the simplest as it is the first topic of data structure and it is quite easy to understand.

  3. #3
    Join Date
    May 2009
    Posts
    511

    Re: What is linear search in data structure?

    Code:
     Declare array AA
      store elements in to array AA
             take nmber to be searched from user and store in num
     repeat for i=o to l(ength of AA)-1   
               check       if AA[i]==num
                          come out of loop
         repeat step  6 to 7
       check  if i== 1o
                            print: num not found
                    else
                         print : num found at location i
        end of loop

  4. #4
    Join Date
    May 2009
    Posts
    539

    Re: What is linear search in data structure?

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    void main( )
    {
    int arr[10] = { 11, 2, 9, 13, 57, 25, 17, 1,   
                                                   90, 3 } ;
               int i, num ;
              clrscr( ) ;
              printf ( "Enter number to search: " ) ;
              scanf ( "%d", &num ) ;
    	for ( i = 0 ; i <= 9 ; i++ )
    	{
    		if ( arr[i] == num )
    			break ;
    	}	
    
    if ( i == 10 )
    printf ( "Number is not present in the 
                                                      array." ) ;
    	else
    		printf ( "The number is at position %d in the array.", i ) ;
    
    	getch( ) ;
    }

Similar Threads

  1. What is the use of insertion sort in data structure?
    By Venugopala in forum Software Development
    Replies: 3
    Last Post: 04-01-2011, 02:41 AM
  2. What do you mean by stacks in Data structure
    By Shiva$m in forum Software Development
    Replies: 3
    Last Post: 04-01-2011, 12:20 AM
  3. What is the binary search in data structure
    By Alibamu in forum Software Development
    Replies: 3
    Last Post: 03-01-2011, 08:42 AM
  4. Variables and data structure in Perl
    By Monty1 in forum Tips & Tweaks
    Replies: 2
    Last Post: 28-09-2010, 07:53 PM
  5. Choice of data structure
    By Hashim in forum Software Development
    Replies: 5
    Last Post: 02-11-2009, 07:27 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,158,374.52271 seconds with 16 queries