100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Class notes SCO204 Data Structures and Algorithms $4.99   Add to cart

Class notes

Class notes SCO204 Data Structures and Algorithms

 9 views  0 purchase

These document contains of 144 pages

Preview 4 out of 165  pages

  • July 22, 2024
  • 165
  • 2023/2024
  • Class notes
  • Martinezz
  • All classes
book image

Book Title:

Author(s):

  • Edition:
  • ISBN:
  • Edition:
All documents for this subject (1)
avatar-seller
TGUARD
C ontents
1 INTRODUCTION 1
What Are Data Structures and Algorithms?....................................................................1
Structure of the Book.......................................................................................................3
The Ruby Programming Language..................................................................................3
Review Questions............................................................................................................3
Exercises..........................................................................................................................4
Review Question Answers...............................................................................................4

2 BUILT-IN TYPES 5
Simple and Structured Types...........................................................................................5
Types in Ruby..................................................................................................................5
Symbol: A Simple Type in Ruby.....................................................................................5
Review Questions............................................................................................................9
Exercises..........................................................................................................................9
Review Question Answers...............................................................................................9

3 ARRAYS 10
Introduction....................................................................................................................10
Varieties of Arrays.........................................................................................................10
Arrays in Ruby...............................................................................................................11
Review Questions..........................................................................................................12
Exercises........................................................................................................................12
Review Question Answers.............................................................................................13

4 ASSERTIONS 14
Introduction....................................................................................................................14
Types of Assertions.......................................................................................................14
Assertions and Abstract Data Types..............................................................................15
Using Assertions............................................................................................................15
Assertions in Ruby.........................................................................................................16
Review Questions..........................................................................................................17
Exercises........................................................................................................................17
Review Question Answers.............................................................................................19

5 CONTAINERS 20
Introduction....................................................................................................................20
Varieties of Containers..................................................................................................20
A Container Taxonomy.................................................................................................20

, Interfaces in Ruby..........................................................................................................21
Exercises........................................................................................................................22
Review Question Answers.............................................................................................23

6 STACKS 24
Introduction....................................................................................................................24
The Stack ADT..............................................................................................................24
The Stack Interface........................................................................................................25
Using Stacks—An Example..........................................................................................25
Contiguous Implementation of the Stack ADT.............................................................26
Linked Implementation of the Stack ADT.....................................................................27
Summary and Conclusion..............................................................................................28
Review Questions..........................................................................................................28
Exercises........................................................................................................................29
Review Question Answers.............................................................................................29

7 QUEUES 31
Introduction....................................................................................................................31
The Queue ADT.............................................................................................................31
The Queue Interface.......................................................................................................31
Using Queues—An Example.........................................................................................32
Contiguous Implementation of the Queue ADT............................................................32
Linked Implementation of the Queue ADT...................................................................34
Summary and Conclusion..............................................................................................35
Review Questions..........................................................................................................35
Exercises........................................................................................................................35
Review Question Answers.............................................................................................36

8 STACKS AND RECURSION 37
Introduction....................................................................................................................37
Balanced Brackets..........................................................................................................38
Infix, Prefix, and Postfix Expressions...........................................................................39
Tail Recursive Algorithms.............................................................................................44
Summary and Conclusion..............................................................................................44
Review Questions..........................................................................................................45
Exercises........................................................................................................................45
Review Question Answers.............................................................................................45

9 COLLECTIONS 47
Introduction....................................................................................................................47
Iteration Design Alternatives.........................................................................................47
The Iterator Design Pattern............................................................................................48
Iteration in Ruby............................................................................................................49

, Collections, Iterators, and Containers............................................................................50
Summary and Conclusion..............................................................................................51
Review Questions..........................................................................................................52
Exercises........................................................................................................................52
Review Question Answers.............................................................................................52

10 LISTS 54
Introduction....................................................................................................................54
The List ADT.................................................................................................................54
The List Interface...........................................................................................................55
Using Lists—An Example.............................................................................................55
Contiguous Implementation of the List ADT................................................................56
Linked Implementation of the List ADT.......................................................................56
Implementing Lists in Ruby..........................................................................................58
Summary and Conclusion..............................................................................................58
Review Questions..........................................................................................................58
Exercises........................................................................................................................58
Review Question Answers.............................................................................................59

11 ANALYZING ALGORITHMS 61
Introduction....................................................................................................................61
Measuring the Amount of Work Done..........................................................................61
Which Operations to Count...........................................................................................62
Best, Worst, and Average Case Complexity..................................................................63
Review Questions..........................................................................................................65
Exercises........................................................................................................................66
Review Question Answers.............................................................................................66

12 FUNCTION GROWTH RATES 68
Introduction....................................................................................................................68
Definitions and Notation................................................................................................68
Establishing the Order of Growth of a Function............................................................69
Applying Orders of Growth...........................................................................................70
Summary and Conclusion..............................................................................................70
Review Questions..........................................................................................................70
Exercises........................................................................................................................70
Review Question Answers.............................................................................................71

13 BASIC SORTING ALGORITHMS 72
Introduction....................................................................................................................72
Bubble Sort....................................................................................................................72
Selection Sort.................................................................................................................73

, Insertion Sort..................................................................................................................74
Shell Sort........................................................................................................................76
Summary and Conclusion..............................................................................................77
Review Questions..........................................................................................................78
Exercises........................................................................................................................78
Review Question Answers.............................................................................................78

14 RECURRENCES 80
Introduction....................................................................................................................80
Setting Up Recurrences..................................................................................................80
Review Questions..........................................................................................................83
Exercises........................................................................................................................83
Review Question Answers.............................................................................................84

15: MERGE SORT AND QUICKSORT 85
Introduction....................................................................................................................85
Merge Sort.....................................................................................................................85
Quicksort........................................................................................................................87
Summary and Conclusion..............................................................................................91
Review Questions..........................................................................................................91
Exercises........................................................................................................................91
Review Question Answers.............................................................................................92

16 TREES, HEAPS, AND HEAPSORT 93
Introduction....................................................................................................................93
Basic Terminology.........................................................................................................93
Binary Trees...................................................................................................................94
Heaps.............................................................................................................................94
Heapsort.........................................................................................................................95
Summary and Conclusion..............................................................................................97
Review Questions..........................................................................................................97

Exercises........................................................................................................................97
Review Question Answers.............................................................................................98

17 BINARY TREES 99
Introduction....................................................................................................................99
The Binary Tree ADT....................................................................................................99
The Binary Tree Class.................................................................................................100
Contiguous Implementation of Binary Trees...............................................................102
Linked Implementation of Binary Trees......................................................................102
Summary and Conclusion............................................................................................103
Review Questions........................................................................................................103

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller TGUARD. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $4.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

83100 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$4.99
  • (0)
  Add to cart