Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Tutorial 12th Feb 2015 Binary Heaps The Heap data structure is an array object that can be viewed as a complete and balanced binary tree. Min (Max)-Heap has a property that for every node other than the root, the value of the node is at least (at most) the value of its parent. Thus, the smallest (largest) element in a heap is stored at the root, and the sub-trees rooted at a node contain larger (smaller) values than does the node itself. A Min-heap viewed as a binary tree and an array. Heaps can be used as an array. For any element at array position I, left child is at ( 2i ), right child is at ( 2i+1 ) and parent is at (int) (i / 2). Heap size is stored at index 0. Basic operations of a heap are: 1. Insert – Insert an element. 2. Delete minimum – Delete and return the smallest item in the heap. Write a program to implement a min heap of 10 elements entered by the user Using Delete min retrieve the first five minimum elements of the array. Priority Queue Priority queue is an abstract data type which is like a regular queue or stack data structure, but where additionally each element has a “priority” associated with it. In a priority queue, an element with high priority is served before an element with low priority. If two elements have the same priority, they are served according to their order in the queue. WAP that implements the priority queue.Use the following function definition. void create{ // initializes the queue} void insert_by_priority(int data) {// queue insertion on priority basis goes here} void delete_by_priority(int data) {// queue deletion goes here} void display{//display your queue here} Stack WAP to reverse a elements using a data structure :stack Do not use any other/additional data structure. Hint: Use recursion Linked List WAP to rotate a linked list-Clockwise/anticlockwise