Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider the following elements:5, 12, 3, 15,... Start Learning for Free
Consider the following elements:
5, 12, 3, 15, 4, 6, 10
These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.
    Correct answer is '2'. Can you explain this answer?
    Most Upvoted Answer
    Consider the following elements:5, 12, 3, 15, 4, 6, 10These elements a...
    Answer:

    Explanation:

    The given elements are: 5, 12, 3, 15, 4, 6, 10

    Method 1: Inserting elements one by one into the heap and maintaining the heap property at every step.

    Step 1: Insert 5 into the heap.
    Heap: 5

    Step 2: Insert 12 into the heap and maintain the heap property.
    Heap: 12, 5

    Step 3: Insert 3 into the heap and maintain the heap property.
    Heap: 12, 5, 3

    Step 4: Insert 15 into the heap and maintain the heap property.
    Heap: 15, 12, 3, 5

    Step 5: Insert 4 into the heap and maintain the heap property.
    Heap: 15, 12, 3, 5, 4

    Step 6: Insert 6 into the heap and maintain the heap property.
    Heap: 15, 12, 6, 5, 4, 3

    Step 7: Insert 10 into the heap and maintain the heap property.
    Heap: 15, 12, 10, 5, 4, 3, 6

    Method 2: Store elements into an almost complete binary tree and then execute the max-heapify function on it.

    The almost complete binary tree for the given elements is:

    15
    / \
    12 3
    / \ /
    5 4 6
    /
    10

    Now, applying the max-heapify function on this tree will result in the following heap:

    Heap: 15, 12, 6, 5, 4, 3, 10

    Comparing the two heaps:

    The elements that have different index positions in the two heaps are:

    - Element 6 has index position 2 in Method 1 heap and index position 3 in Method 2 heap.
    - Element 10 has index position 7 in Method 1 heap and index position 1 in Method 2 heap.

    Therefore, the number of elements that have different index positions in the two heaps is 2.
    Free Test
    Community Answer
    Consider the following elements:5, 12, 3, 15, 4, 6, 10These elements a...
    Given,
    Elements are:
    5, 12, 3, 15, 4, 6, 10
    Using method 1, the tree is:
    Using method 2, the tree is:
    Thus, the index of 3 and 6 differ.
    So, 2 elements have different indexes.
    Hence, the correct answer is 2.
    Explore Courses for Computer Science Engineering (CSE) exam

    Similar Computer Science Engineering (CSE) Doubts

    Top Courses for Computer Science Engineering (CSE)

    Consider the following elements:5, 12, 3, 15, 4, 6, 10These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.Correct answer is '2'. Can you explain this answer?
    Question Description
    Consider the following elements:5, 12, 3, 15, 4, 6, 10These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.Correct answer is '2'. 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 the following elements:5, 12, 3, 15, 4, 6, 10These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.Correct answer is '2'. 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 the following elements:5, 12, 3, 15, 4, 6, 10These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.Correct answer is '2'. Can you explain this answer?.
    Solutions for Consider the following elements:5, 12, 3, 15, 4, 6, 10These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.Correct answer is '2'. 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 the following elements:5, 12, 3, 15, 4, 6, 10These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.Correct answer is '2'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the following elements:5, 12, 3, 15, 4, 6, 10These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.Correct answer is '2'. Can you explain this answer?, a detailed solution for Consider the following elements:5, 12, 3, 15, 4, 6, 10These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.Correct answer is '2'. Can you explain this answer? has been provided alongside types of Consider the following elements:5, 12, 3, 15, 4, 6, 10These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.Correct answer is '2'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the following elements:5, 12, 3, 15, 4, 6, 10These elements are inserted into the max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first, these elements are stored into an almost complete binary tree and then the max-heapify function is executed on it. Now find the number of elements that have different index positions into two heaps generated from given two methods _________.Correct answer is '2'. 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