GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
86 views

asked in DS by Boss (8.3k points)   | 86 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 (1.3k points)  
selected by
Top Users Jan 2017
  1. Debashish Deka

    7172 Points

  2. Habibkhan

    4696 Points

  3. Vijay Thakur

    4308 Points

  4. sudsho

    4090 Points

  5. saurabh rai

    4024 Points

  6. Arjun

    3292 Points

  7. santhoshdevulapally

    3066 Points

  8. GateSet

    3016 Points

  9. Bikram

    3014 Points

  10. Sushant Gokhale

    2892 Points

Monthly Topper: Rs. 500 gift card

18,838 questions
23,808 answers
51,588 comments
20,148 users