First time here? Checkout the FAQ!
+2 votes

asked in DS by Boss (8.7k points)   | 242 views
option B is true but the question asking which is false so ans is C,but what is option A ,if list is empty , function crashes ...??
yes, because when head is NULL, head->next throws invalid memory access error.
@Arjun Sir, when we try to access an invalid memory do we get an error or it works considering that memory and gives garbage value.

For example : PRINT(*(4615)) Does it print bit pattern stored at location 4615 or error?

Another example : int *a = 62; Does it point to memory 62( which is garbage value) or error.?

1 Answer

+2 votes
Best answer

The only option false in the above question is (C)


Reasons To back my Answer:

1. It is always required to chek the underflow and overflow conditions. It will throw an error : Invalid memory access error.

2. It is obvious from the the diagram below.


3. If we move the head then the previous data will be lost , so it is always advisable to use another pointer "p" to navgate in a link list.

answered by Active (2.3k points)  
selected by

Top Users Aug 2017

    4660 Points

  2. Bikram

    4366 Points

  3. akash.dinkar12

    3258 Points

  4. rahul sharma 5

    3042 Points

  5. manu00x

    2682 Points

  6. makhdoom ghaya

    2410 Points

  7. just_bhavana

    2100 Points

  8. Tesla!

    1918 Points

  9. stblue

    1682 Points

  10. joshi_nitish

    1608 Points

24,928 questions
32,024 answers
30,113 users