Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-01-2011
Member
 
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.
Reply With Quote
  #2  
Old 04-01-2011
Member
 
Join Date: Apr 2009
Posts: 484
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.
Reply With Quote
  #3  
Old 04-01-2011
Member
 
Join Date: May 2009
Posts: 503
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
Reply With Quote
  #4  
Old 04-01-2011
Member
 
Join Date: May 2009
Posts: 532
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( ) ;
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 09:18 AM.