Re: [algogeeks] Suggested the Data Structure to implement the solution in O(1)
Hi, Use hashing, but with perfect hashing which does all these operations in O(1). Refer to Introduction to Algorithms by CLRS to learn about perfect hashing. --
Re: [algogeeks] Suggested the Data Structure to implement the solution in O(1)
no i am using C for this implementation , can you suggest me algo for this On Tue, Jan 8, 2013 at 5:55 PM, Sachin Maheshwari < sachin.maheshw...@gmail.com> wrote: > If you are using Java, you can go with LinkedHashMap. > > > > > On Sat, Jan 5, 2013 at 6:40 PM, Nishant Pandey < > nishant.bits.me...@gmail.com> wrote: > >> Give a Data structure to store Name-value pair like name-age >> "abc",12 >> "xyz",34... >> such than insert(name,value), value = search(name), name = nthentry(n), >> delete(name); all can be perfomed in O(1). >> Note:- after deletion order should be maintained.Ex. >> "ds",12 >> "df",78 >> "teu",54 >> "etr",12 >> If delete("df") is called then nthentry(2) should return "teu" >> >> >> Please suggest the solution .. >> >> -- >> >> >> > > > > -- > Regards, > Sachin Maheshwari > Cell phone: +91.7259917298 > > "If we admit that human life can be ruled by reason; the possibility of > life is destroyed." - Alexander Supertramp > > -- > > > --
Re: [algogeeks] Suggested the Data Structure to implement the solution in O(1)
If you are using Java, you can go with LinkedHashMap. On Sat, Jan 5, 2013 at 6:40 PM, Nishant Pandey wrote: > Give a Data structure to store Name-value pair like name-age > "abc",12 > "xyz",34... > such than insert(name,value), value = search(name), name = nthentry(n), > delete(name); all can be perfomed in O(1). > Note:- after deletion order should be maintained.Ex. > "ds",12 > "df",78 > "teu",54 > "etr",12 > If delete("df") is called then nthentry(2) should return "teu" > > > Please suggest the solution .. > > -- > > > -- Regards, Sachin Maheshwari Cell phone: +91.7259917298 "If we admit that human life can be ruled by reason; the possibility of life is destroyed." - Alexander Supertramp --
[algogeeks] Suggested the Data Structure to implement the solution in O(1)
Give a Data structure to store Name-value pair like name-age "abc",12 "xyz",34... such than insert(name,value), value = search(name), name = nthentry(n), delete(name); all can be perfomed in O(1). Note:- after deletion order should be maintained.Ex. "ds",12 "df",78 "teu",54 "etr",12 If delete("df") is called then nthentry(2) should return "teu" Please suggest the solution .. --