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

asked in DS by Boss (8.6k points)   | 105 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

Related questions

0 votes
1 answer
1
0 votes
0 answers
2
Top Users Feb 2017
  1. Arjun

    5396 Points

  2. Bikram

    4230 Points

  3. Habibkhan

    3952 Points

  4. Aboveallplayer

    3086 Points

  5. Debashish Deka

    2564 Points

  6. sriv_shubham

    2318 Points

  7. Smriti012

    2240 Points

  8. Arnabi

    2008 Points

  9. mcjoshi

    1696 Points

  10. sh!va

    1684 Points

Monthly Topper: Rs. 500 gift card

20,863 questions
26,023 answers
59,698 comments
22,136 users