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

asked in DS by Boss (8.7k points)   | 167 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.2k points)  
selected by


Top Users Jun 2017
  1. Bikram

    3704 Points

  2. Arnab Bhadra

    1502 Points

  3. Hemant Parihar

    1502 Points

  4. Niraj Singh 2

    1481 Points

  5. junaid ahmad

    1432 Points

  6. Debashish Deka

    1384 Points

  7. Rupendra Choudhary

    1220 Points

  8. rahul sharma 5

    1220 Points

  9. Arjun

    1158 Points

  10. srestha

    1006 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 Jun 26 - Jul 02
  1. Arjun

    198 Points

  2. akankshadewangan24

    152 Points

  3. Debashish Deka

    138 Points

  4. Hira Thakur

    130 Points

  5. Soumya29

    104 Points


23,399 questions
30,111 answers
67,489 comments
28,424 users