Data Structures and Algorithms
Posted mamyaoa
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Data Structures and Algorithms相关的知识,希望对你有一定的参考价值。
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
因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected]
微信:codinghelp
以上是关于Data Structures and Algorithms的主要内容,如果未能解决你的问题,请参考以下文章
SE2205: Algorithms and Data Structures
CSI 403 Data Structures and Algorithms
CN5102 Module title Data Structures and Algorithms
IA-32 System-Level Registers and Data Structures
Journey CodeForces - 1336F[data structures divide and conquer graphs trees]
SE2205: Algorithms and Data Structures for Object-Oriented Design