Answered step by step
Verified Expert Solution
Question
1 Approved Answer
P3: Remove Duplicates from a Sorted Doubly Linked List (15 points) Problem Description: You are given a sorted doubly linked list. Your task is to
P3: Remove Duplicates from a Sorted Doubly Linked List (15 points) Problem Description: You are given a sorted doubly linked list. Your task is to implement a function removeDuplicates that removes all duplicate elements from the list, leaving only distinct elements. Input: Sorted Doubly Linked List: 1 2234445 Output: Doubly Linked List after Removing Duplicates: 1 2345 Explanation: The provided input is a sorted doubly linked list with some duplicate elements. The removeDuplicates function is applied to remove duplicate elements, leaving only distinct values in the list. The duplicates are removed as follows: The second occurrence of 2 is removed. Two of the three occurrences of 4 is removed. The resulting doubly linked list contains only distinct values in ascending order: 1 2 3 4 P4: Max heap sort (15 points) Write functions for max heap sort you learned in class in your main cpp. The functions are made up by maxHeapify(vector& vec, int n, int root) and maxHeapSort(vector& vec, int n). Input a positive integer k and print the top k largest numbers in ascending order. Can you stop sorting before all the numbers in your vector are sorted? We only need top k largest numbers instead of all. Here is an example: Input length, lower bound and upper bound 10 1 10 Original vector1: 9 2 9 7 2 4 5 4 9 8 Input K for top K largest: 3 The top 3 largest numbers : 9 9 9
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started