Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider a max heap, represented by the array... Start Learning for Free
Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap is
  • a)
    40, 30, 20, 10, 15, 16, 17, 8, 4, 35
  • b)
    40, 35, 20, 10, 30, 16, 17, 8, 4, 15
  • c)
    40, 30, 20, 10, 35, 16, 17, 8, 4, 15
  • d)
    40, 35, 20, 10, 15, 16, 17, 8, 4, 30
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16,...
The array 40, 30, 20, 10, 15, 16, 17, 8, 4 represents following heap
After insertion of 35, we get
After swapping 35 with 15 and swapping 35 again with 30, we get
View all questions of this test
Most Upvoted Answer
Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16,...
Explanation:


The given heap is a max heap (i.e., the largest element is at the root), and the array representation of the heap is as follows:


40, 30, 20, 10, 15, 16, 17, 8, 4


Now, we need to insert the value 35 into this heap.


Step 1: Insert the value at the end of the heap, i.e., after the last element (i.e., 4). The heap now becomes:


40, 30, 20, 10, 15, 16, 17, 8, 4, 35


Step 2: Since the value inserted is greater than its parent (i.e., 10), we need to swap the values. The heap now becomes:


40, 30, 20, 35, 15, 16, 17, 8, 4, 10


Step 3: Since the value inserted is greater than its parent (i.e., 20), we need to swap the values. The heap now becomes:


40, 35, 20, 30, 15, 16, 17, 8, 4, 10


Step 4: Since the value inserted is greater than its parent (i.e., 40), we need to swap the values. The heap now becomes:


40, 35, 20, 30, 15, 16, 17, 8, 4, 10


The new heap after the insertion of the value 35 is option 'B' (40, 35, 20, 10, 30, 16, 17, 8, 4, 15).
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap isa)40, 30, 20, 10, 15, 16, 17, 8, 4, 35b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30Correct answer is option 'B'. Can you explain this answer?
Question Description
Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap isa)40, 30, 20, 10, 15, 16, 17, 8, 4, 35b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30Correct answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap isa)40, 30, 20, 10, 15, 16, 17, 8, 4, 35b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30Correct answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap isa)40, 30, 20, 10, 15, 16, 17, 8, 4, 35b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30Correct answer is option 'B'. Can you explain this answer?.
Solutions for Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap isa)40, 30, 20, 10, 15, 16, 17, 8, 4, 35b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30Correct answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap isa)40, 30, 20, 10, 15, 16, 17, 8, 4, 35b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap isa)40, 30, 20, 10, 15, 16, 17, 8, 4, 35b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30Correct answer is option 'B'. Can you explain this answer?, a detailed solution for Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap isa)40, 30, 20, 10, 15, 16, 17, 8, 4, 35b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap isa)40, 30, 20, 10, 15, 16, 17, 8, 4, 35b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap isa)40, 30, 20, 10, 15, 16, 17, 8, 4, 35b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30Correct answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev