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

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

时间: 2024-11-08 22:48:57

Data Structures and Algorithms的相关文章

Data Structures and Algorithms with JavaScript

Book Description As an experienced JavaScript developer moving to server-side programming, you need to implement classic data structures and algorithms associated with conventional object-oriented languages like C# and Java. This practical guide show

CN5102 Module title Data Structures and Algorithms

SCHOOL OF ARCHITECTURE, COMPUTING &ENGINEERINGSubmission instructions Cover sheet to be attached to the front of the assignment when submitted Question paper to be attached to assignment when submitted All pages to be numbered sequentially All work h

Lock-Free Data Structures

By Andrei Alexandrescu, October 01, 2004 Post a Comment Lock-free data structures guarantee the progress of at least one thread when executing mutlithreaded procedures, thereby helping you avoid deadlock. Andrei Alexandrescu is a graduate student in

代写二叉查找树程序作业、代写BST 作业、代写Data Structures

代写二叉查找树程序作业.代写BST 作业.代写Data StructuresKIT205 Data Structures and AlgorithmsAssignment 1: Data StructuresDue: 27th April, 11:55pmIntroductionYou work for an education company that develops and runs Massive Open Online Courses(MOOCs). You have been ask

SE2205: Algorithms and Data Structures for Object-Oriented Design

SE2205: Algorithms and Data Structures for Object-Oriented DesignLab Assignment 1Assigned: Jan 16, 2019; Due: Feb 13, 2019 @ 10:00 a.m.If you are working in a group of two, then indicate the associated student IDsand numbers in the Test.java file as

SE2205: Algorithms and Data Structures

SE2205: Algorithms and Data Structures for Object-Oriented DesignLab Assignment 3Assigned: Mar 20, 2019; Due: April 8, 2019 @ 10:00 a.m.If you are working in a group of two, then indicate the associated student IDsand numbers in the Assignment3.java

Choose Concurrency-Friendly Data Structures

What is a high-performance data structure? To answer that question, we're used to applying normal considerations like Big-Oh complexity, and memory overhead, locality, and traversal order. All of those apply to both sequential and concurrent software

Persistent Data Structures

转自http://www.cnblogs.com/tedzhao Persistent Data Structures 可持久化的数据结构 Contents 内容 Introduction                          介绍 Persistent Singly Linked Lists   可持久化单向链表 Persistent Binary Trees           可持久化二叉树 Random Access Lists              随机存取列表 Imm

2017 UESTC Training for Data Structures

2017 UESTC Training for Data Structures A    水,找区间极差,RMQ怼上去. #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define rep(i,a,b) for (int i=a;i<=b;i++) #define per(i,b,a) for (int i=b;i&