D.4 Advanced Program Development

studied byStudied by 1 person
0.0(0)
Get a hint
Hint

Recursion

1 / 11

12 Terms

1

Recursion

  • A method where the solution to a problem depends on the solutions to smaller instances of the same problem. It calls itself.

New cards
2

Applications of Recursion

  • Not really used in practice. They are difficult for humans to follow in order to understand and maintain code

  • Only used when they can provide an elegant solution

    • Fibonacci given a number

    • Factorial or power of a given number

    • Print a binary tree

    • Reverse a string

New cards
3

Object Refrence

  • A reference to an object in memory

  • Used in java by the dot notation to access the fields and methods

    • Person p = new Person();

    • p.setName(“Fred”)

  • p = object reference

New cards
4

Features of the ADT List

  • A list is a data structure that can grow in size at runtime as memory is allocated dynamically

  • A list is a generic ADT (abstract data type) and usually has a few basic methods

  • They can be indexed to allow the program to add and remove elements from specified positions

New cards
5

Generic ADT Methods

  • Add

  • Size

  • Get

  • isEmpty

  • Remove

New cards
6

Stacks

  • First element added to the stack sits on the bottom

  • Last one added is the first one removed

  • LIFO

  • The add method is a push and the remove a pop

New cards
7

Queues

  • Elements are added to the end of the queue and removed from the front

  • FIFO

  • Add method is an enqueue and remove is dequeue

New cards
8

Methods and Algorithms for Manipulating Lists and Object References

  • add (to front and back)

  • insert (in order)

  • delete

  • list (print)

  • isEmpty

  • isFull

New cards
9

When are stacks used in operating systems?

  • To keep track of instructions and which to execute next

    • Hence stackOverFlow error

  • Also used to keep track of events in the software so the undo button can be used

New cards
10

Binary trees

  • Ordered list of elements where elements of a lower number or letter are stored to the left of the node and elements of a higher number or letter are stored to the right of the node

  • Have a root at the top - search start point

  • Recursion used to print them

  • Can traverse in pre-order, post-order, and in-order

New cards
11

Code Naming Conventions

  • Start class names with a capital letter

  • Objects with a lowercase letter

  • Use meaningful names for the fields and variables

  • Indent the code

  • Inline annotaitons

New cards
12

Why are naming conventions important?

  • Code is read more often than written

    • If all code is written the same it is easy to read

  • Cuts down time on maintenance and reduces the chance of error through misinterpretation

  • Saves time, money, and effort

  • Makes it easy to read and update

New cards

Explore top notes

note Note
studied byStudied by 30 people
... ago
5.0(1)
note Note
studied byStudied by 23 people
... ago
5.0(1)
note Note
studied byStudied by 87 people
... ago
4.0(1)
note Note
studied byStudied by 13 people
... ago
5.0(1)
note Note
studied byStudied by 10 people
... ago
5.0(1)
note Note
studied byStudied by 28 people
... ago
5.0(1)
note Note
studied byStudied by 35 people
... ago
5.0(1)
note Note
studied byStudied by 712 people
... ago
5.0(5)

Explore top flashcards

flashcards Flashcard (83)
studied byStudied by 14 people
... ago
5.0(1)
flashcards Flashcard (70)
studied byStudied by 3 people
... ago
5.0(1)
flashcards Flashcard (175)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (54)
studied byStudied by 5 people
... ago
5.0(1)
flashcards Flashcard (50)
studied byStudied by 97 people
... ago
5.0(3)
flashcards Flashcard (40)
studied byStudied by 19 people
... ago
5.0(1)
flashcards Flashcard (91)
studied byStudied by 458 people
... ago
5.0(4)
flashcards Flashcard (193)
studied byStudied by 78 people
... ago
5.0(5)
robot