ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
pgm to find middle element of linklist(in efficent manner)
 Question Submitted By :: Soumyajoy
I also faced this Question!!     Rank Answer Posted By  
 
  Re: pgm to find middle element of linklist(in efficent manner)
Answer
# 1
struct node {
	int data;
	struct node* next;
};

int mid_element ( struct node* _node )
{
	struct node* cur_ptr;
	struct node* cur_next_ptr;

	if ( NULL == _node ) return ( -1 );
	else {
		cur_ptr = _node;
		cur_next_ptr = _node;
		while ( ( NULL != cur_ptr -> next ) 
				&& ( NULL != cur_next_ptr -
> next ) 
				&& ( NULL != cur_next_ptr -
> next -> next ) )
		{
			cur_ptr = cur_ptr -> next;
			cur_next_ptr = cur_next_ptr -> 
next -> next;
		}
	}

	return ( cur_ptr -> data );
}
 
Is This Answer Correct ?    1 Yes 0 No
Abdur Rab
 
  Re: pgm to find middle element of linklist(in efficent manner)
Answer
# 2
NODE display_middle(NODE first)
{
	int count = 0;
	NODE  temp,mid;
	
	for ( temp = mid = first, count=0; temp ; temp = temp ->
link,count++)

	{
		if ( count % 2 )
		{
			mid = mid -> link;
		}
	}
	return mid;
}
 
Is This Answer Correct ?    2 Yes 0 No
Sharan
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
related to rdbms query .  1
which of the function operator cannot be over loaded a) <= b)?: c)== d)* HCL7
a memory of 20 bytes is allocated to a string declared as char *s then the following two statements are executed: s="Etrance" l=strlen(s); what is the value of l ? a.20 b.8 c.9 d.21 TCS4
swap two integer variables without using a third temporary variable?  2
helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.  3
How to implement variable argument functions ? HP1
main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? } NDS15
What are Storage Classes in C ? HP15
implement general tree using link list Wipro1
in C-programming language without using printf statement can we get output r not ? if yes how and if no also how ?  6
True or false: If you continuously increment a variable, it will become negative? 1) True 2) False 3) It depends on the variable type  5
Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 1. Print only the alphabets . If in upper case print in lower case vice versa.  1
what are the languages used in c#? Infosys1
Evaluate the following: int fn(int v) { if(v==1 || v==0) return 1; if(v%2==0) return fn(v/2)+2; else return fn(v-1)+3; } for fn(7); 1) 10 2) 11 3) 1  6
what is the difference between NULL & NUL keywords in C?  3
how to generate sparse matrix in c  1
plssssss help !!....using array.. turbo c.. create a program that will accept number of words to be consored. .a word must not exceed 10 characters long .the text to be entered will be no longer than 200 characters .there will be no 10 words example: enter number of words to be censor: 5 enter words to censor: windows office microsoft bill gates enter text to censor: bill gates founded microsoft and makes office and windows sample output: <consored> <censored> founded <censored> and makes <censored> and <censored>  1
what is the value of 'i'? i=strlen("Blue")+strlen("People")/strlen("Red")-strlen("green") Cadence4
Define function ?Explain about arguments? Geometric-Software2
Given an array of characters, how would you reverse it? How would you reverse it without using indexing in the array?  1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com