Question

In: Computer Science

What is a heap and what are they used for

What is a heap and what are they used for

Solutions

Expert Solution

Basically Heap is a collection of objects that placed one after the other in general term

Comming to computer science,the definition of heap is:In some progaming languagae heap is a reserved computer storage area where process is stored in a variable.let us say for example when an cpu executing a program it takes many inputs from user during processing .as already it takes some memory from system it is easy to process and manage storage.

In computer science,we also termed Heap as a specilazed Data Structered with parent and child nodes arranged acordingly.Heap can also be used as priority queue.and the most important element is always at the top.priority queues are useful in finding problems like shortest path.Heap can also to for sorting data.

by seeing we can say heap is simple but the implementation of heap is somewhat differrnt and thinkable.

when we deal with heap most of time for algorithm is upheaping and downheaping


Related Solutions

What are the different stages of memory in a heap?
What are the different stages of memory in a heap?
Explain this code: The structure used is max heap using array. C++ (i is the index...
Explain this code: The structure used is max heap using array. C++ (i is the index of the element to be deleted) void del(int i) {    int left,right,temp;    arr[i]=arr[n-1];    n=n-1;    left=2*i+1; /*left child of i*/    right=2*i+2; /* right child of i*/    while(right < n)    {        if( arr[i]>=arr[left] && arr[i]>=arr[right] )            return;        if( arr[right]<=arr[left] )        {            temp=arr[i];            arr[i]=arr[left];   ...
1.Instead of Build-Max-Heap, we could use Heap-Insert-Max to build a tree with heap property. Write a...
1.Instead of Build-Max-Heap, we could use Heap-Insert-Max to build a tree with heap property. Write a pseudocode for that procedure, also evaluate it’s time complexity. 2. How Insertion sort works on the following array [16, 12, 3, 27, 9, 4, 5, 7]]
What is the difference between stack-dynamic and explicit heap-dynamic?  
What is the difference between stack-dynamic and explicit heap-dynamic?  
A max-heap can be used as a max-priority queue, which is an abstract data type having...
A max-heap can be used as a max-priority queue, which is an abstract data type having the operations Insert, Maximum, Extract-Max, and Increase-Key. a. Describe how to implement a FIFO queue with a priority queue, and analyze the time complexity of the implementation (Insert and Delete operations), assuming that a heap is used for the priority queue. b. Describe how to implement a LIFO queue (i.e. a stack) with a priority queue, and analyze the time complexity of the implementation...
Language C++ Implement a Priority Queue with a Binary HEAP. Use a Max Heap. Create a...
Language C++ Implement a Priority Queue with a Binary HEAP. Use a Max Heap. Create a class called Node: Have a Name and Priority.Data set - 10 is the highest priority, 1 is lowest priority. Enqueue and dequeue in the following order. Function  Name, Priority Enqueue  Joe, 3 Enqueue  Fred,1 Enqueue Tuyet,9 Enqueue  Jose, 6 Dequeue Enqueue  Jing, 2 Enqueue  Xi, 5 Enqueue  Moe, 3 DequeueEnqueue  Miko, 7 Enqueue Vlady, 8 Enqueue Frank, 9 Enqueue  Anny, 3 DequeueEnqueue  Xi, 2 Enqueue  Wali, 2 Enqueue  xChe, 6 Enqueue  xVerra, 8 Dequeue Dequeue Dequeue Dequeue...
C++ Heap Tree:  Make a program called "priority_queue" that has the following operations using a heap and...
C++ Heap Tree:  Make a program called "priority_queue" that has the following operations using a heap and simulating a prioritized row of integers with higher priority value. I would appreciate if someone could help me with this code It has to include the following on the code: push Description: Add data to prioritized row Entry: An integer, which you want to add to the prioritized row Exit: Nothing Precondition: n is an integer Postcondition: The prioritized row contains new data. pop...
prove the running time of heap sort.
prove the running time of heap sort.
How are allocated and unallocated segments structured in the heap?
How are allocated and unallocated segments structured in the heap?
This problem requires you to use a heap to store items, but instead of using a key of an item to determine where to store the item in the heap
This problem requires you to use a heap to store items, but instead of using a key of an item to determine where to store the item in the heap, you need to assign a priority (key) to each item that will determine where it is inserted in the heap 7a) Show how to assign priorities to items to implement a first-in, first-out queue with a heap. 7b) Show how to assign priorities to items to implement a first-in, last-out stack with...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT