Chapter 4 Lists, Stacks and Queues

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/18

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

19 Terms

1
New cards

Lists

A finite, ordered sequence of data items.

Notation:

2
New cards

List elements have a

position

3
New cards

Array-Based Lists

•Insertion and deletion are Q(n).

•Prev and direct access are Q(1).

•Array must be allocated in advance.

•No overhead if all array positions are full.

4
New cards

Linked Lists

•Insertion and deletion are Q(1).

•Prev and direct access are Q(n).

•Space grows with number of elements.

•Every element requires overhead.

5
New cards

Array-based List space

D*E

D = Maximum number of elements in an array.

E = Space for data value.

6
New cards

Linked List space

n(P + E)

n = length of list

P = Space for pointer

E = Space for data value.

7
New cards

break-even point (BEP)

n = DE/(P+E)

D = Maximum number of elements in an array.

E = Space for data value.

n = length of list

P = Space for pointer

8
New cards

Java does not use

does not use delete explicitly to allow programmable control of memory management

9
New cards

System new and garbage collection

are slow

10
New cards

Add freelist class

support to the Link class

11
New cards

Freelists

freelist holds those list nodes that are not currently being used.

12
New cards

Stacks

Last-in-first-out (LIFO) data structure

13
New cards

Stack Notation

Insert: PUSH

Remove: POP

The accessible element is called TOP.

14
New cards

Queues

A First In First Out (FIFO) Data Structure.

15
New cards

Queue Notation

Insert: Enqueue

Delete: Dequeue

First element: Front

Last element: Rear

16
New cards

push

insert element to be the top of the stack

17
New cards

pop

Remove top element from the stack

18
New cards

enqueue

To add an item to the rear of a queue.

19
New cards

dequeue

To remove an item from the front of a queue.