Skip to main content
-2 votes
0 answers
48 views

Why does unpacking a 3-element tuple from heapq.heappop fail when using _, _, node = ..., but not with val, i, node? [closed]

I'm working on Merge K Sorted Linked Lists from Leetcode and the optimal solution requires use of a heap. When unpacking the tuple from heapq.heappop(), I figured I would use _, _, node to unpack, as ...
Fast's user avatar
  • 39
1 vote
2 answers
62 views

Why defining string within a function scope allocates it on heap instead of a stack? [duplicate]

According this awesome article there is an interesting case with two given examples: A: B: And there is an explanation for A: Unfortunately you have not taken into account that such Strings will ...
Bartłomiej Semańczyk's user avatar
0 votes
1 answer
32 views

How does a microcontroller keep track of heap free()?

In a microcontroller without any OS, how does the microcontroller keep track of where a malloc will point to in the heap? char *x; char *y; char *z; x=(char*)malloc(10); y=(char*)malloc(10); free(x); ...
hal's user avatar
  • 1
2 votes
4 answers
120 views

How can I efficiently maintain median in a dynamic data stream with support for deletions?

I'm working on a problem where I need to maintain the median of a data stream, but unlike typical implementations that only support insertions, I also need to support deletions of arbitrary values. ...
Aditya Rawat's user avatar
1 vote
1 answer
90 views

EIGEN: Advice needed for memory allocation

I am trying to write an efficient multistep solver in C++ using the Eigen library. To do so, I need a few variables that keep track of the history. One of them is of type Eigen::VectorX<Eigen::...
Fredo's user avatar
  • 47
4 votes
1 answer
87 views

gdb: get references to value returned by the find command

I'm trying to port a program I wrote in windows with syscalls to linux. The program reads the memory of another running process and displays certain values as they change. To get started and figure ...
seenmycorpseanywhere's user avatar
1 vote
1 answer
84 views

Does the call instruction write something onto the stack? For example, things like environment variables?

I am currently running a C++ program in which I have used the heap to simulate the stack and employed assembly language to place relevant information (such as memory addresses) into registers, thereby ...
qingfu liu's user avatar
0 votes
1 answer
52 views

Data streaming - is this the right way to build CSV file using ByteArrayOutputStream?

I do have this code. @RequestMapping("/test") fun getData(): ResponseEntity<ByteArray> { val items = repository.getItems() val outputStream = ByteArrayOutputStream() ...
dzikulisz cezar's user avatar
1 vote
3 answers
92 views

Why is the heap in heapsort "the wrong way"?

In heapsort, the heap is max-heap where each time we extract the maximum element from index 0 and place it at the right side of the array. I'm now wondering why we don't build the max-heap in reverse, ...
Fff's user avatar
  • 80
2 votes
1 answer
102 views

Which option has precendence if I enable and disable FrontEndHeapDebugOptions at the same time?

The undocumented (I can't find a MSDN reference) FrontEndHeapDebugOptions Registry key has two flags: Bit 2 (0x04) for disabling the Segment Heap, thus forcing NT Heap Bit 3 (0x08) for enabling the ...
Thomas Weller's user avatar
1 vote
1 answer
91 views

Min Pairing Heap - How to increase key faster than O(logn)?

I know that a min pairing heap can decrease a key faster than O(logn). However, is there any way to make the increase key operate also faster than decrease key to the top, remove, than insert new ...
user27238111's user avatar
0 votes
1 answer
42 views

Why heapq.heappush is an O(log n) operation?

import heapq minHeap = [4, 7, 2, 8, 1, 3] heapq.heapify(minHeap) # O(n log n) operation print(minHeap) # [1, 4, 2, 8, 7, 3] heapq.heappush(minHeap, 1) # O(log n) operation? print(minHeap) # ...
etang's user avatar
  • 568
1 vote
0 answers
40 views

use a priority queue to do hierarchical clustering without import heapq

I am using priority queue to do the hierarchical clustering(can not import heapq), and want to use the complete-link method, but I don't know what is the problem of my code, the reason is far from ...
吳思覦's user avatar
5 votes
0 answers
107 views

Why does the last element in a range need to fulfill the heap property for pop_heap?

The C++ standard explains how std::pop_heap is supposed to work: Effects: Swaps the value in the location first with the value in the location last - 1 and makes [first, last - 1) into a heap with ...
Tom's user avatar
  • 51
0 votes
1 answer
123 views

How a pointer to pointer pointing to a NULL pointer works in C?

I am trying to understand merging two sorted lists into one sorted output. Got the below code from internet. trav's value will have to be the address of mergedHead but here, trav is holding the value ...
Preethi's user avatar
  • 55

15 30 50 per page
1
2 3 4 5
127