Hi,
I wanted to know if does exist a safe way to, given a heap, move an
arbitrary element to the first position of the heap.
Something like:
>>heap = [0,3,6,8,10] heapq.move_to_first_position(heap, 4) heap = [10, 0,3,6,8]
--- Giampaolo http://code.google.com/p/pyftpdlib/ 3 1211
I'm not sure what you expect as an answer, but if you mean the heap as
in the data structure, you can not just arbitrarily move one key where
you want as it will destroy the heap property.
Giampaolo Rodola' wrote:
Hi,
I wanted to know if does exist a safe way to, given a heap, move an
arbitrary element to the first position of the heap.
Something like:
>>heap = [0,3,6,8,10]
>>heapq.move_to_first_position(heap, 4)
>>heap = [10, 0,3,6,8]
--- Giampaolo http://code.google.com/p/pyftpdlib/
-- http://mail.python.org/mailman/listinfo/python-list
On 4 Set, 13:49, Alexandru Palade <alexandru.pal...@sellerengine.com>
wrote:
I'm not sure what you expect as an answer, but if you mean the heap as
in the data structure, you can not just arbitrarily move one key where
you want as it will destroy the heap property.
Giampaolo Rodola' wrote:
Hi,
I wanted to know if does exist a safe way to, given a heap, move an
arbitrary element to the first position of the heap.
Something like:
*>>heap = [0,3,6,8,10]
*>>heapq.move_to_first_position(heap, 4)
*>>heap = [10, 0,3,6,8]
--- Giampaolo http://code.google.com/p/pyftpdlib/
-- http://mail.python.org/mailman/listinfo/python-list- Nascondi testo citato
- Mostra testo citato -
Could I be able to do that if every element I want to move will have
the value of 0 which is the smallest value I can have into my heap?
What I'm trying to do is implementing a timeout: sometimes I want a
given event which was scheduled to happen within X seconds to happen
immediately.
--- Giampaolo http://code.google.com/p/pyftpdlib/
On Sep 4, 6:57*am, "Giampaolo Rodola'" <gne...@gmail.comwrote:
On 4 Set, 13:49, Alexandru Palade <alexandru.pal...@sellerengine.com>
wrote:
I'm not sure what you expect as an answer, but if you mean the heap as
in the data structure, you can not just arbitrarily move one key where
you want as it will destroy the heap property.
Giampaolo Rodola' wrote:
Hi,
I wanted to know if does exist a safe way to, given a heap, move an
arbitrary element to the first position of the heap.
Something like:
*>>heap = [0,3,6,8,10]
*>>heapq.move_to_first_position(heap, 4)
*>>heap = [10, 0,3,6,8]
--- Giampaolo
>http://code.google.com/p/pyftpdlib/
--
>http://mail.python.org/mailman/listi...-list-Nascondi testo citato
- Mostra testo citato -
Could I be able to do that if every element I want to move will have
the value of 0 which is the smallest value I can have into my heap?
What I'm trying to do is implementing a timeout: sometimes I want a
given event which was scheduled to happen within X seconds to happen
immediately.
--- Giampaolohttp://code.google.com/p/pyftpdlib/
Change its timeout to -1 and reheapify. Or maintain 'zeroes' in a
separate structure. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Richard Thompson |
last post by:
I've got a memory overwrite problem, and it looks as if a vector has
been moved, even though I haven't inserted or deleted any elements in
it. Is this possible? In other words, are there any...
|
by: Samuel Barber |
last post by:
Consider a struct that resembles this:
struct mystruct
{
byte myarray;
// ...other stuff...
}
i.e. a struct that contains at least one reference/pointer.
|
by: Mike Spertus |
last post by:
Is there a way to get an approximate stackpointer into an int in C#?
The following works, but is unsafe and adds a new variable to the
stackframe:
int i = (int)(&i);
It seems like it should...
|
by: viki |
last post by:
I have vector 'vec' of integers which was made into valid heap using
std::make_heap().
Then we change value of a single element vec, like: vec =
new_value;
Now this makes vec not a valid...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |