tailieunhanh - Data Structures & Algorithms in Java PHẦN 9

Applet sẽ nhận ra rằng cây kéo dài tối thiểu bao gồm các cạnh AD, AB, BE, EC, và CF, trọng lượng cạnh tổng cộng 28. Thứ tự của các cạnh được quy định cụ thể là không quan trọng. Nếu bạn bắt đầu một đỉnh khác nhau, bạn sẽ tạo ra một cây với các cạnh tương tự, nhưng theo một thứ tự khác nhau. | for int m 0 m currentSize m if heapArray m null heapArray m .iData else -- heap format int nBlanks 32 int itemsPerRow 1 int column 0 int j 0 current item String dots . dots dots dotted top line while currentSize 0 for each heap item if column 0 first item in row for int k 0 k nBlanks k preceding blanks display item heapArray j .iData if j currentSize done break if column itemsPerRow end of row nBlanks 2 half the blanks itemsPerRow 2 twice the items column 0 start over on new row else next item on row for int k 0 k nBlanks 2-2 k interim blanks end for n dots dots dotted bottom line end displayHeap -------------------------------------------------------------- - end class Heap class HeapApp public static void main String args throws IOException int value value2 Heap theHeap new Heap 31 make a Heap max size 31 boolean success - 425 - 70 insert 10 items 40 50 20 60 100 80 30 10 90 while true until Ctrl - C putText Enter first letter of putText show insert remove change int choice getChar switch choice case s show break case i insert putText Enter value to insert value getInt success value if success putText Can t insert heap is full n break case r remove if else putText Can t remove heap is empty n break case c change putText Enter index of item value getInt putText Enter new priority value2 getInt success value value2 if success putText Can t change invalid index n break default putText Invalid entry n end switch end while end main -------------------------------------------------------------- - 426 - public static void putText String s s .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.