码迷,mamicode.com
首页 > 其他好文 > 详细

Data Structures and Algorithms

时间:2019-04-05 19:40:12      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:ref   repr   专业   this   EAP   team   data   ora   ica   


Lab 7
Data Structures and Algorithms
Problem 1: Heap
1. (3 points) Create a new class Heap This class must implement the following two methods:
(a) heapify which takes an array of integers as input and converts it into a max heap.
(b) heapsort which takes an array and sorts it (ascending order)
For heapsort you should call heapify method internally.
2. (3 points) Create another class HeapTest for testing. You must follow the following steps:
(a) Create an array arr containing the following elements:
5, 18, 3, 25, 27, 45, 97, 88, 26, 16, 49, 67
(b) Call heapify(arr)
(c) Print elements in arr
(d) Create another array arr2 containing the following elements:
15, 99, 3, 77, 27, 45, 7, 88, 26, 5
(e) call heapsort(arr2)
(f) Print elements in arr2
Note: For getting full credits for part 1, your part 2 must work correctly.
Problem 2: Radix Sort
Radix Sort is typically implemented to support only a radix that is a power of two. This allows for a direct
conversion from the radix to some number of bits in an integer key value. For example, if the radix is 16, then
a 32-bit key will be processed in 8 steps of 4 bits each. Re-implement (in Java) the Radix Sort implementation
of the lecture (textbook) to use bit shifting in place of division. Use at least 5 test cases to compare the running
time of the old and new Radix Sort implementations. Submit the Java code and your findings in a separate text
file.

Data Structures作业代写、代做Java课程设计作业、Java编程作业调试、代写Algorithms留学生作业
Note: Bitshifting operator >> (<<) is used in Java to shift right (left) the binary representation of a number.
So 16 >> 1 is 8 because 1610 = 100002 and 10000 >> 1 = 10002 = 810.
Submission
Create a zip file [YourNetID]_Lab7.zip containing your source code for Problem 1 and 2 and a README file.
Submit this file at the appropriate location on the Blackboard system. The README file should state your and
your team member’s name and any other pertinent information. You should include the following Java files:
Heap.java
HeapTest.java
RadixSort.java
Lab 7 (Heaps) Page 1 / 2
Grading (10 pts)
Problem 1: 6 pts
Problem 2: 4 pts
Lab 7 (Heaps) Page 2 / 2

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:99515681@qq.com 

微信:codinghelp

Data Structures and Algorithms

标签:ref   repr   专业   this   EAP   team   data   ora   ica   

原文地址:https://www.cnblogs.com/mamyaoa/p/10659565.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!