link list
-
hi is there any shortcut to find the mid of the link list without iteration by paul
-
hi is there any shortcut to find the mid of the link list without iteration by paul
Which kind of linked list ?
Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++ -
Which kind of linked list ?
Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++hi It is single linked list by paul
-
hi It is single linked list by paul
Ok but is it your own class or are you using an existing class ? Anyway, there's no support for that by default in a linked list, but you could maybe add it yourself if you wrote the code. For example after adding two elements, you can increase your 'middle' pointer by one (so, make it point to the next element). It becomes more complex when you want to remove elements, in which case I think you will have to recompute it (retrieve the nr of elements in the list and move the middle pointer by half of this number).
Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++ -
Ok but is it your own class or are you using an existing class ? Anyway, there's no support for that by default in a linked list, but you could maybe add it yourself if you wrote the code. For example after adding two elements, you can increase your 'middle' pointer by one (so, make it point to the next element). It becomes more complex when you want to remove elements, in which case I think you will have to recompute it (retrieve the nr of elements in the list and move the middle pointer by half of this number).
Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++hi i have another same question that finding 4th element from the single linked list from last node without iterating list. but i know only the first node address. Is it possible or not . Condition is that i should not change the content of linked list for any reference. by paul
-
hi i have another same question that finding 4th element from the single linked list from last node without iterating list. but i know only the first node address. Is it possible or not . Condition is that i should not change the content of linked list for any reference. by paul
Is this an interview question?
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]
-
Is this an interview question?
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]
YES :(
-
YES :(
So, I presume you did not do the interview well. Then why not read up on linked list and learn, rather than insisting on having someone else answer the "same exact question" for you? BTW, Good luck for your next interview.
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]
-
So, I presume you did not do the interview well. Then why not read up on linked list and learn, rather than insisting on having someone else answer the "same exact question" for you? BTW, Good luck for your next interview.
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]
I am assuming that you voted me 1. But my opinion still stands the same. You'll have to do your stuff. People might answer an interview question here, but that kinda defeats the purpose; your thought process will stop there. If you don't learn things properly and experiment enough on them, you'll never be able to master it. And without mastering it, you won't be able to answer a tricky question. Thanks for the 1 vote, I am not the loser here; I couldn't care less. :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]
-
hi is there any shortcut to find the mid of the link list without iteration by paul
Anything is possible, especially if you are the author of said list (i.e., your linked list object can keep track of what it perceives as the middle node). While it's common to hold a pointer to the front and back nodes of the list, by their nature, however, a linked list implies iteration.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne