Linked Lists -- Can you tell me how to check whether a linked list is circular?

1 Answer

Answer :

Create two pointers, and set both to the start of the list. Update each as follows:

while (pointer1) {
pointer1 = pointer1->next;
pointer2 = pointer2->next;  
if (pointer2) pointer2=pointer2->next;
if (pointer1 == pointer2) {
print ("circular");
}
}
If a list is circular, at some point pointer2 will wrap around and be either at the  item just before pointer1, or the item before that. Either way, its either 1 or 2  jumps until they meet.

Related questions

Description : Tell how to check whether a linked list is circular.

Last Answer : Create two pointers, each set to the start of the list. Update each as follows: while (pointer1) { pointer1 = pointer1->next; pointer2 = pointer2->next; if (pointer2) pointer2=pointer2->next; if (pointer1 == pointer2) { print (\"circular\n\"); }

Description : String Processing --- Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba.

Last Answer : void PrintPermu (char *sBegin, char* sRest) { int iLoop; char cTmp; char cFLetter[1]; char *sNewBegin; char *sCur; int iLen; static int iCount; iLen = strlen(sRest); if (iLen == 2) { iCount++; ... printf("\nEnter a string:"); scanf("%s%*c",sIn); memset(s,0,255); PrintPermu(s, sIn); }

Description : "union" Data Type What is the output of the following program? Why?

Last Answer : #include main() { typedef union { int a; char b[10]; float c; } Union; Union x,y = {100}; x.a = 50; strcpy(x.b,"hello"); x.c = 21.50; printf("Union x : %d %s %f n",x.a,x.b,x.c); printf("Union y : %d %s %f n",y.a,y.b,y.c); }

Last Answer : Size of the final executable can be reduced using dynamic linking for libraries.

Description : printf() Function- What is the difference between "printf(...)" and "sprintf(...)"?

Last Answer : sprintf(...) writes data to the character array whereas printf(...) writes data to the standard output device.

Description : malloc() Function- What is the difference between "calloc(...)" and "malloc(...)"?

Last Answer : 1. calloc(...) allocates a block of memory for an array of elements of a certain size. By default the block is initialized to 0. The total number of memory allocated will be (number_of_elements * ... calls malloc(...) in order to use the C+ + _set_new_mode function to set the new handler mode.

Description : What is the output of printf("%d")?

Last Answer : 1. When we write printf("%d",x); this means compiler will print the value of x. But as here, there is nothing after ï ½%dï ½ so compiler will show in output window garbage value. 2. When we ... an error without the proper number and type of arguments for things like printf(...) and scanf(...).

Description : What is C language?

Last Answer : The C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to ... language for writing system software, though it is also used for writing applications. ...

Description : Which of the following statement is true? i) Using singly linked lists and circular list, it is not possible to traverse the list backwards. ii) To find the predecessor, it is required to traverse the list from the first ... linked list. A) i-only B) ii-only C) Both i and ii D) None of both

Last Answer : C) Both i and ii

Description : Suppose you want to delete the name that occurs before “Vivek” in an alphabetical listing. Which of the following data structures shall be most efficient for this operation? (A) Circular linked list (B) Doubly linked list (C) Linked list (D) Dequeue

Last Answer :  (B) Doubly linked list 

Description : The advantage of …………….. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists. A) Lists B) Linked Lists C) Trees D) Queues

Last Answer : B) Linked Lists

Description : Which one is the incorrect statement with regard to the importance of pedigree analysis? (a) It confirms that DNA is the carrier of genetic information. (b) It helps to understand whether the trait in ... linked to one of the autosome. (d) It helps to trace the inheritance of a specific trait.

Last Answer : (a) It confirms that DNA is the carrier of genetic information.

Description : A test cross is carried out to (a) determine the genotype of a plant at F2 (b) predict whether two traits are linked (c) assess the number of alleles of a gene (d) determine whether two species or varieties will breed successfully.

Last Answer : (a) determine the genotype of a plant at F2

Description : When using access lists, what does a Cisco router check first? * To see if the packet is routable or bridgeable * The destination address * The source address * The packet contents

Last Answer : Correct answer: A The first thing checked is to see if the packet is routable or bridgeable. If it is not, the packet will be dropped.

Description : Has anybody ever heard of someone being informed over the phone that a bad check has been linked to them by their Social Security Number?

Last Answer : answer:Sounds like a phishing scam. I would forget about it. Edit: Apparently, the FCC takes reports of phishing calls: http://esupport.fcc.gov/complaints.htm

Description : Explain whether there is acceleration of a rotating object at a balanced speed in a circular motion ?

Last Answer : : In a circular path, there is no acceleration of the rotating object at a balanced speed The rate of change of unequal velocity is called acceleration. So if the velocity is balanced , there will be no acceleration Be it in a circular way or in a straight way.

Description : If you're a list-maker, what do you make lists of, and what do you do with them? (a revived question)

Last Answer : I’m a Virgo and lists are made. Shopping, Christmas gifts, places to go on vacation…. meals to make next week.

Description : If you're a list-maker, what do you make lists of, and what do you do with them?

Last Answer : answer:What to do when I am out and about. There is also the sublist of what to buy at my various stops. I then usually lose them (lists) after I am in the car but before I arrive at the ... in my wood-burning stove. My usual chores are post office, country store, gas, cash, food, library, pharmacy

Description : Match List I (Forms of power Sharing) with List Il forms of government) and select the correct answer using the codes given below in the lists: -SST 10th

Last Answer : The correct option is (C) The following table shows the correct matches: LIST I LIST II 1Power shared among different organs of government B. Separation of power 2 Power shared ... different social groupsA. Community Government 4Power shared by two or more political parties C. Coalition government

Description : Match List (Forms of power Sharing) with List II (forms of government) and select the correct answer using the codes given below in the lists: -SST 10th

Last Answer : The correct option is (C) The following table shows the correct matches: List I List II 1. Power shared among different organs of government B. Separation of power 2. Power ... social groups A. Community Government 4. Power shared by two or more political parties C. Coalition government

Description : Match List I with List Il and select the correct answer using the codes given below the lists: -SST 10th

Last Answer : Correct answers of the above given list are: This list is matching with the Power of Attorney in specific Area. Union of India : Prime Minister State : Governor Municipal Corporation : Mayor Gram Panchayat : Sarpanch Hence, option (c) is correct

Description : Match List I with List Il and select the correct answer using the codes given below the lists: -SST 10th

Last Answer : B - Correct match for the above given list is as follows: A person who believes in equal rights and opportunities for women and men: Feminist A person who says that religion is the principal ... does not discriminate others on the basis of religious beliefs: Secularist Hence, option (b) is correct

Description : Match List (organisations and struggles) with List Il and select the correct answer using the codes given below the lists: -SST 10th

Last Answer : solutions : - B

Description : Match List I with List Il and select the correct answer using the codes given below the lists : -SST 10th

Last Answer : Correct match of the above list is as follows: Pressure group: Fertilizer dealers' association Long-term Movement: Women's Movement Single issue movement: Narmada Bachao Andolan Political party: Asom Gana Parishad Therefore, option (a) is correct

Description : Match List (organizations and struggles) with List Il and select the correct answer using the codes given below the lists: -SST 10th

Last Answer : The correct match for the above given list are as follows: Congress Party: United Progressive Alliance Bharatiya Janata Party : National Democratic Alliance Communist Party of India (Marxist) : Left Front Telugu Desam Party: State party Therefore, option (c) is correct

Description : Which of the following tag is used to make a list that lists the items with numbers? -Technology

Last Answer : (c) is the ordered list that starts with a number like 1, A, a, i and I etc.

Description : Python : Why list of lists/sets updates reflected across sublists/sets -Web-Development

Last Answer : answer:

Description : Python: How to sort a list/set of lists by a specific index of the inner lists -Web-Development

Last Answer : answer:

Description : Match List I with List II and select the correct answer using the code given below the lists `:` `{:("List-1",,,"List"-II),((a)"Argentite",,,"(1)Halid

Last Answer : Match List I with List II and select the correct answer using the code given below the lists `:` `{:("List-1",,,"List" ... . `{:(a,b,c,d),(3,4,1,2):}`

Description : Match List I with List II and select the correct answer by using the codes gives below the lists: List-I (Climatic conditions) List-II (Resons) A. Chennai is warmer than Kolkata 1. North-East Monsoon B. Snowfall in Himalayas 2. Altitude C. ... (a) 1 2 4 5 (b) 4 5 1 3 (c) 5 2 4 3 (d) 5 1 3 4

Last Answer : Ans: (c)

Description : Match the spice in List I with the plant part in List II and select the correct answer from the codes given below the lists. List I - (Spice) List II - (Plant part used) A. Cinnamon 1. Fruit B. Pepper 2. Flower bud C. Clove 3. Stem D. ... A B C D (a) 4 1 2 3 (b) 3 2 1 4 (c) 2 1 4 3 (d) 4 3 2 1

Last Answer : Ans:(a)

Description : What are the 'residuary powers'? (1) Powers which are enumerated in the State List (2) Powers which are included in the Union List (3) Powers which are enumerated in the Concurrent List (4) Powers which are not mentioned in any of the lists

Last Answer : - (4) Powers which are not mentioned in any of the lists Explanation:Article 248 of the Constitution deals with residuary powers. Parliament has exclusive power to make any law with respect to any ... shall include the power of making any law imposing a tax not mentioned in either of those Lists.

Description : Education is included in which of the following lists? (1) Central list (2) State list (3) Concurrent list (4) Local list

Last Answer : (3) Concurrent list Explanation: Concurrent list consists of 52 items (previously 47 items). Marriage and divorce, transfer of property other than agricultural land, education, contracts, bankruptcy and insolvency, etc, come under this list.

Description : Andrew has joined as the Project Manager of a project. One of the project documents available to Andrew lists down all the risks in a hierarchical fashion. What is this document called? a. Risk Management Plan. b. List of risks. c. Monte Carlo diagram. d. Risk Breakdown Structure.

Last Answer : d. Risk Breakdown Structure.

Description : Andrew has joined as the Project Manager of a project. One of the project documents  available to Andrew lists down all the risks in a hierarchical fashion. What is this document  called? a. Risk Management Plan. b. List of risks. c. Monte Carlo diagram. d. Risk Breakdown Structure.

Last Answer : d. Risk Breakdown Structure.

Description : Match List -I (Bearings) with List-II (Applications) and select the using the codes given below the lists: [IAS-1998] List -I List-II A. Journal bearing 1. Electric motors B. Thrust bearing 2. Watches C. Conical pivot bearing 3. Marine ... D (a) 3 4 1 2 (b) 4 2 1 3 (c) 3 4 2 1 (d) 4 2 3 1

Last Answer : (c) 3 4 2 1

Description : Match List-I (Type of Anti-friction bearing) with List-II (Specific Use) and select the using the code given below the Lists: [IES-2006] List-I List -II A. Self-aligning ball bearing 1. For pure axial load B. Taper roller bearing 2. For ... C D (a) 2 1 3 4 (b) 3 4 2 1 (c) 2 4 3 1 (d) 3 1 2 4

Last Answer : (c) 2 4 3 1

Description : Match List- I and List -II and select the correct answer using code given below lists List-I  a) Facts as effect of fact in issue 1) Section9 b) Facts forming part of same transaction 2) Section 8 c) Fact which constitute preparation for any ... d) A) 1 2 3 4 B) 4 3 2 1 C) 3 4 2 1 D) 2 3 1 4

Last Answer : c) Fact which constitute preparation for any fact in issue

Description : Economic planning is a subject defined in which of the following lists – (i) In the state list (ii) In the Union list (iii) In the concurrent list (iv) Unspecified in any special list

Last Answer : (iii) In the concurrent list

Description : Mark the correct option a) The due mail and sorting list for PO and mail offices in communication with offices in more than one RMS Dn are prepared and supplied by the Head of the circle b) ... are prepared and supplied to Head, Sub and Branch office by Sub divisional Inspectors. d) All the above

Last Answer : d) All the above

Description : The.... of software contains list lists of commands and options. 1) Menu bar 2) Title bar 3) Formula bar 4) Tool bar

Last Answer : 1) Menu bar

Description : What type of data is: a=[(1,1),(2,4),(3,9)]? a) Array of tuples b) List of tuples c) Tuples of lists d) Invalid type

Last Answer : b) List of tuples

Description : Match the two lists given below: List-I a. London b. Vatican City c. Moscow d. New York List-II (i) St. Peter's Square (ii) Times Square (iii) Trafalgar Square (iv) Red Square (1) a-(ii), b-(iv), c-(iii), d- ... ) a-(iv), b-(ii), c-(i), d-(iii) (4) a-(i), b-(iii), c-(ii), d-(iv)

Last Answer : a-(iii), b-(i), c-(iv), d-(ii)

Description : Tell Me Do You Have Regular Visibility Into Excess And Obsolete Stock, And Is It Linked To Targeted Action Plans To Sell Off Or Reduce This Inventory?

Last Answer : Typically, excess and obsolete stock stems from ineffective sales forecasting, planning or using a business model that fails to factor in product complexity and life cycles correctly. Inventory leaders establish ... fear of the write-off has led to a large buildup over time of obsolete inventory.

Description : Is there any application which can help me to check whether my weight is normal for my age and height?

Last Answer : Lucky for you there are apps that can help you check your weight and even your progress if you're gaining or losing. Here's some of them: aktiBMI Monitor Your Weight Loseit Fat Secret Mi Fit Smart Scale Happy Scale

Description : Are the amount of chemicals in the food you eat (or don't eat) an issue to you (for example the McDonald's McRib Sandwich ingredient list, articles linked here)?

Last Answer : No. And the photo is just what meat looks like when it's flash frozen. Any meat will look like that. The fact that it's been chopped and pressed into that shape isn't particularly appealing to ... we do it with hamburgers too. Past too. Wendy's presses their hamburger into squares or they used to.

Description : Is it possible to return an entire linked list object from a method in C++ without running the destructor?

Last Answer : Your description in the problem doesn't really describe what you want it to do that you would call right, nor does it explain how it uses its linked list. If you haven't figured out exactly what you want ... want to do that you can describe clearly, then yes, there will be a right way to do it.

Description : Which is/are correctly linked here? `{:(,"List I",,"List II"),((a),E_(1)Cb,(a),"Carbanion formation"),((b),E_(2),(b),"Stereo specific"),((c),S_(N^(1))

Last Answer : Which is/are correctly linked here? `{:(,"List I",,"List II"),((a),E_(1)Cb,(a),"Carbanion formation" ... "),((d),E_(1),(d),"Carbocation formation"):}`

Description : A system wherein items are added from one and removed from the other end. a) Stack b) Queue c) Linked List d) Array

Last Answer : Answer: b Explanation: In a queue, the items are inserted from the rear end and deleted from the front end

Description : Define what is linked list?

Last Answer : A linked list is composed of nodes that are connected with another. In C programming, linked lists are created using pointers. Using linked lists is one efficient way of utilizing memory for storage.