The Gateway to Computer Science Excellence
For all GATE CSE Questions
Toggle navigation
GATE Overflow
Facebook Login
or
Email or Username
Password
Remember
Login
Register

I forgot my password
Activity
Questions
Unanswered
Tags
Subjects
Users
Ask
Prev
Blogs
New Blog
Exams
First time here? Checkout the
FAQ
!
x
×
Close
Use the google search bar on side panel. It searches through all previous GATE/other questions. For hardcopy of previous year questions please see
here
Deleting a random node from Heap
+1
vote
76
views
What is the time complexity of 'deleting any random node from a max or min heap'?
heap
binaryheap
timecomplexity
datastructure
asked
Dec 21, 2018
in
DS
by
Avijit Shaw
(
139
points)

76
views
Facebook
Google+
Twitter
answer
comment
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
+2
votes
Best answer
The deletion of a random node would take $O(n+log(n))$ as first we will find where the random element is in the heap which will take $O(n)$ and then delete it which will further take $O(log(n))$
answered
Dec 21, 2018
by
Shobhit Joshi
Active
(
4.6k
points)
selected
Dec 21, 2018
by
Avijit Shaw
comment
0
Thanks
+1
Find the node which has to be delete, decrease the key to INF (in case of min heap), now your element is at root position, Now apply Extract MIN operation.
∴ O(n) + O(log n) + O(log n) = O(n)
0
I think it's O( log n)
To finding a element in a min heap : O ( logn)
Then apply deletion takes : O ( log n)
0
@Magma
how can you find an element with in O(log n) time in HEAP ?
0
True, searching takes O ( n) time in heap .
0
O sorry
bad mistake
Please
log in
or
register
to add a comment.
← Prev. Qn. in Sub.
Next Qn. in Sub. →
← Prev.
Next →
Related questions
0
votes
0
answers
1
Finding the minimum element in a Heap
I was going through the heap concept and one question came into my mind what will be the best case time complexity of finding the minimum element in a max heap? Thank you:)
asked
4 days
ago
in
DS
by
Nandkishor3939
Junior
(
791
points)

86
views
heap
binaryheap
timecomplexity
0
votes
0
answers
2
Heap Sorting
Consider a binary tree, where left and right subtreealready heapified. But we havenot done heapificationfor root yet. Then what is time complexity to convert it in a full heap tree? $A)O(\log n)$ or $o(n)$ $B)\Omega (\log n)$ or $\omega(n)$ $C)\Theta (\log n)$ or $\theta (n)$ $D)\text{None of these}$
asked
Aug 18, 2018
in
DS
by
srestha
Veteran
(
106k
points)

133
views
algorithms
sorting
heap
binaryheap
timecomplexity
+6
votes
2
answers
3
7th smallest element in a MinHeap
In a minheap with n elements 1). The 7th smallest element can be found in time, if duplicates are allowed ? 2). The 7th distinct smallest element can be found in time, If duplicates are allowed ?
asked
Sep 4, 2016
in
Algorithms
by
Kapil
Veteran
(
50.6k
points)

1.2k
views
algorithms
heap
binaryheap
sorting
timecomplexity
0
votes
0
answers
4
Max heap when stored in an array is always in sorted order
This question is in CLRS,if we have a max heap it is always in sorted order(descending) order.And by extension if we have min heap the array is sorted in ascending order.Is this true? I have a counter example for ... it an heapified representation or not? If we heapify after deletion and store max deleted element then we get sorted array.
asked
Nov 15, 2018
in
DS
by
sripo
Active
(
1.3k
points)

105
views
sorting
binaryheap
arrays
heap
datastructure
algorithms
0
votes
0
answers
5
#DS Inserting elements into Min Heap?
The number of distinct min heap are possible with keys 1, 2, 3, 4, 5 are ________. I know, there are variance of this question for Max heap and even for Min heap, the answer won't change, but I just wanna know if my technique is right or not. ===== ... any value. > Lastly the right sub tree => 1C1 = 1 Totally  1*4C3*1*2*1 = 8. Is this approach correct?
asked
Jun 24, 2018
in
DS
by
iarnav
Loyal
(
9.4k
points)

94
views
algorithms
binaryheap
heap
datastructure
+1
vote
0
answers
6
Number of Max Heap
How many maxheaps can be formed with the following elements? $\{1,1,1,2,2,2,3,3,3,4,4,4\}$
asked
Jun 4, 2018
in
DS
by
Balaji Jegan
Active
(
4.6k
points)

265
views
datastructure
permutationsandcombinations
binaryheap
heap
+1
vote
2
answers
7
Max Heap
The number of ways in which the numbers 1, 2, 3, 4, 5 can be inserted into binary heap. Such that resulted binary heap is max heap ________.
asked
Nov 7, 2017
in
DS
by
shivangi5
Active
(
1.4k
points)

373
views
heap
binaryheap
datastructure
Quick search syntax
tags
tag:apple
author
user:martin
title
title:apple
content
content:apple
exclude
tag:apple
force match
+apple
views
views:100
score
score:10
answers
answers:2
is accepted
isaccepted:true
is closed
isclosed:true
Recent Posts
PSU's
Decidability Slides
AAI JE IT results out! Adv no 02/2018
Graph Theory Slides for GATECSE
Generating Function Useful Link
All categories
General Aptitude
1.5k
Engineering Mathematics
7k
Digital Logic
2.7k
Programming & DS
4.8k
Programming
3.5k
DS
1.3k
Algorithms
4.2k
Theory of Computation
5.2k
Compiler Design
2k
Operating System
3.9k
Databases
3.9k
CO & Architecture
3.5k
Computer Networks
4k
Non GATE
1.4k
Others
1.5k
Admissions
516
Exam Queries
526
Tier 1 Placement Questions
23
Job Queries
67
Projects
18
Follow @csegate
Gatecse
Recent Blog Comments
Thank you, lots of things got clear!
Guys this is getting out of hand now. You see...
47,005
questions
51,326
answers
177,509
comments
66,668
users