Homework 4

© All Rights Reserved

69 views

Homework 4

© All Rights Reserved

- Syllabus Single Document
- Digital Search Trees & Binary Tries
- Vyom-Freshers-Guide-2007
- Re Cursive List Processing Algorithms in Lisp
- Know Thy Complexities
- Data Structures
- trees quest
- 18_Shanthi - Applying SD-Tree for Object-Oriented Query
- Project 4 Specs
- Data Structures
- bstree
- Data Structure for Text Sequences
- 9 Gramm Slide
- Sorting & Searching.pdf
- Data Struct
- abfug
- Amazon Questions.txt
- JAVA-02a Array Updated
- Sgs
- Aad

You are on page 1of 4

Fall 2016

Homework 4

CHAPTER 7

3. What is the maximum number of nodes that can be stored in a binary tree with 10

levels?

= 2 ^ 10 1

=1024 1

=1023

4. What is the minimum number of levels in a binary tree containing 6023 nodes?

= ceiling [log2(N + 1)]

= ceiling [log2(6023 + 1)]

= ceiling [log2(6024)] 12.5

212 6023 213

4096 6023 8192

So at least 0-13 levels (= 14 levels)

5. What is the maximum number of levels in a tree containing 6023 nodes?

= 6023

6. What is the maximum number of nodes that can be stored in level 16 of a binary tree?

216 = 65,536

8. True or false:

a. The highest level of a complete binary tree contains more nodes than all of the

other levels combined.

False

b. The root node is always at the highest level of the tree.

False

c. Level 9 is the highest level in a 10 level tree.

True

11. Draw the binary search tree resulting from inserting the nodes with the integer key

values: 68, 23, 45, 90, 70, 21, and 55 into the tree. Assume key 68 is inserted first, then

key 23, etc.

6

8

2

3

2

1

9

0

4

5

7

0

5

5

20. Give the output produced by an NLR output scan of the tree shown in Figure 7.3f.

68-23-21-45-55-90-70

CHAPTER 8

4. Give three factors to be considered in selecting a sorting algorithm for a particular

application.

How much speed and memory you have available, the type of data that needs to be

stored, and the programmers capability

6. Give an expression for the minimum number of comparisons required to sort n items.

= O(nlog2n)

10. Under what conditions is the Binary Tree Sort fast?

Fast for random data, which produces a balanced tree

11. Calculate the minimum and maximum number of comparisons required to sort 1,000,000

items using the Binary Tree Sort.

Minimum

= O ((1,000,000) log2(1,000,000))

= 19,931,568.5693

Maximum

= O (1,000,000 ^2)

= 1,000,000,000,000

13. The integers 65, 80, 70, 18, 86, 6, and 37 are to be sorted using the Binary Tree Sort.

Assume the integers are processed by the algorithm in the order given.

a. Show the binary tree that results from sorting.

6

5

8

0

1

8

3

7

8

6

7

0

b. As the integers are placed in the tree, count the number of comparisons made.

What is the total number of comparisons?

10

A binary tree in which (the value of) each parent is greater than both of its

children

31. A 16 element array stores the integers 81, 16, 2, 89, 54, 23, 76, 25, 37, 107, 1, 74, 45,

16, 31, and 58 in elements 0 through 15, respectively. They are to be sorted using the

merge sort.

a. How many passes will be performed to complete the sort?

4

b. Show the contents of the array at the beginning of the sort and after each pass.

81, 16 2, 89 54, 23 76, 25 37, 107

1, 74 45, 16 31, 58

16, 81 2, 89

1, 74

16, 45 31, 58

1, 2, 16, 16, 23, 25, 31, 37, 45, 54, 58, 74, 76, 81, 89, 107

c. Count the number of comparisons that were made to sort the 16 items.

13

d. Count the number of swaps made to complete the sort of the 16 items.

47

e. Compare your answers in parts (c) and (d) of this question to results obtained

when the formulas presented in Table 8.6 are used.

SE (0.75n) log2n

= (0.75(16)) log2(16)

= 48

PMS = log2n

= log2(16)

=4

CAms = [(n/2) + (n-1)]/2

= [(16/2) + (16-1)]/2

= [(8) + (15)]/2

= [(8) + (15)]/2

=23/2

= 11.5

SEMS = PMS * CAms

= 4 * 11.5

=46

total swaps = 2nlog2n

= 128

=(2*SEMS)/0.75

= (2 * 46) /0.75

=122.67

32. What characteristic of a data set makes the Quicksort slow?

It does not perform quickly when input is sorted in reverse or nearly sorted in

reverse

- Syllabus Single DocumentUploaded byMarquise Rosier
- Digital Search Trees & Binary TriesUploaded bymanishbhardwaj8131
- Vyom-Freshers-Guide-2007Uploaded byapi-3777212
- Re Cursive List Processing Algorithms in LispUploaded byUsman Ahmad
- Know Thy ComplexitiesUploaded bybhuvangates
- Data StructuresUploaded byDilip Kumar
- trees questUploaded byligoryantony1987
- 18_Shanthi - Applying SD-Tree for Object-Oriented QueryUploaded byAnkita Thakur
- Project 4 SpecsUploaded bylantea1
- Data StructuresUploaded byNuha Noor
- bstreeUploaded byado_ado
- Data Structure for Text SequencesUploaded byTuo Chen Peng
- 9 Gramm SlideUploaded byPankaj Chawla
- Sorting & Searching.pdfUploaded byJune Ng
- Data StructUploaded byParveen Swami
- abfugUploaded byoldphilou
- Amazon Questions.txtUploaded byRajesh Thennan
- JAVA-02a Array UpdatedUploaded byIhsan Abdullah
- SgsUploaded byanto
- AadUploaded byanto
- qrfsd.txtUploaded byanto
- Algorithms - GeeksforGeeksUploaded byRaJu SinGh
- Homework 2 SolutionUploaded byEdward Lee
- Kth Smallest Number AlgoUploaded byShadabSalam
- DATA STRUCTURE Www-matterhere-com NRRUploaded byNavanit Kumar
- NewDivConquer.pdfUploaded byyashbhardwaj
- Data Structure TestUploaded bySunil
- DAAQBI-VUploaded bydgk84_id
- Big-O Algorithm Complexity Cheat SheetUploaded bykaushik5295
- How to Use Authority Checks in Business Object Processing FrameworkUploaded bySurendra Nath Paluru

- IndexingUploaded byStephen Efange
- User's Manual ET-8LSDUploaded byRoberto Pasic
- Examples of Data Flow Diagrams PDFUploaded byKaren
- Ise v Database Management Systems [10cs54] SolutionUploaded bysscr27
- PGDA_WP_94Uploaded bylingushillo
- TRAMP - An Interpretive Associative Processor with Deductive CapabilitiesUploaded byTRAC_fan
- Performance Evaluation of MANET Protocols for Different Data Traffics Using OPNET SimulatorUploaded byInternational Journal for Scientific Research and Development - IJSRD
- The Newest Western Digital Hard Drive Repair DoctorUploaded byEdison Hsiun
- EMS20SD20MMC20FRAM20v320Manual_eng.pdfUploaded byHamdan Hasian Ritonga
- Secure Fine grains Updates in Cloud using Public AuditingUploaded byInnovative Research Publications
- Traditional Databases vs NOSQLUploaded byEditor IJTSRD
- Automation Anywhere - IQ BOTUploaded byRamanathan S
- aidx-RPUploaded bychakri.unguturu2543
- Tcpip Application Note for Wcdma Solution v2.0 0Uploaded bymetalshock
- Windows 2003 Group PolicyUploaded bybhanumurthybeeraka
- outcome 5c metadatarecordcreationgroupreportUploaded byapi-351049371
- ch2-sharc-1Uploaded byPhani Anusha
- CLM_DISTRB (2).xlsxUploaded bygopi143
- Udp Hole PunchingUploaded byVivek Chugh
- Live Office User GuideUploaded bykamalksofteng
- Datacomm McqUploaded byMamboo
- JCL - Job Control LanguageUploaded byMFkar
- Data Access GuideUploaded byarylessence
- docu82501_VMAX3-Family-with-HYPERMAX-OS-5977-Operating-Environment-ReadMe-for-HYPERMAX-OS-Service-Packs-Release-Level-5977.952.892.pdfUploaded byJorge Alberto Largaespada Gonzalez
- Trucchi Htaccess Per HackerUploaded byRunelore Rune Celtiche
- Archive Data 1 HanaUploaded byivan
- Ascii Table for Cyrillic Charset (CP855) - Ascii-CodesUploaded byMarija Milosavljevic-Ljubic
- Computer-Abbreviations-PDF-Download-for-Competitive-Exams-by-EntranceGeek.pdfUploaded byAftab Mir
- Qi Gong Kuji in 1 35Uploaded bykrodha
- FtpUploaded byJuan Alvares Torres

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.