ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 24 May 2017 My Price 8.00

change this license header, choose License Headers in Project Properties

Need help. Can someone walk me through a program I have that is already written? Its a java program. I am suppose to build my implementation of  priority queue without the predefined java collection library. Need some one to walk me through a program I have. I need to ask questions like "What does this mean?" and"What if I write it this way?" I attached the program below. I will explain more in detail when I get a tutor. 

 

/** To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/import java.util.PriorityQueue;import java.util.Random;public class MyPriorityQueue {int arr[];int capacity;int count;public MyPriorityQueue(int capacity) {this.capacity = capacity;this.arr=new int[capacity];count=0;}//this method will insert a new integer into queuepublic void insert(int n){if(count==capacity){System.out.println("Queue is full");}else{arr[count]=Integer.MIN_VALUE;increaseKey(count,n);count++;}}void increaseKey(int i,int n){arr[i]=n;while(i>=0&&arr[i/2]<arr[i]){int temp=arr[i/2];arr[i/2]=arr[i];arr[i]=temp;i=i/2;}}void maxHeapify(int i){int left = 2 * i + 1;int right = 2 * i + 2;int largest = i;if( left < capacity && arr[ left ] > arr[ largest ] )largest = left;if( right < capacity && arr[ right ] > arr[ largest ] )largest = right;if( largest != i ){int temp = arr[ i ];arr[ i ] = arr[ largest ];arr[ largest ] = temp;

Answers

(11)
Status NEW Posted 24 May 2017 09:05 AM My Price 8.00

-----------

Not Rated(0)