Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

ADT Sorted List - Data Structures - Lecture Slides, Slides of Data Structures and Algorithms

In the subject of the Data Structures, the key concept and the main points, which are very important in the context of the data structures are listed below:Adt Sorted List, Brainstorming, Filtering, Scenarios, Responsibility Algorithms, Four Stages, Decomposition Process, Group Problem, Spontaneous Contribution, Furiously First

Typology: Slides

2012/2013

Uploaded on 04/23/2013

saratey
saratey 🇮🇳

4.3

(10)

87 documents

1 / 57

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 4
ADT Sorted List
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39

Partial preview of the text

Download ADT Sorted List - Data Structures - Lecture Slides and more Slides Data Structures and Algorithms in PDF only on Docsity!

Chapter 4

ADT Sorted List

  • Lecture

Brainstorming

• A group problem-solving technique that

involves the spontaneous contribution of ideas

from all members of the group

• All ideas are potential good ideas

• Think fast and furiously first, and ponder later

• A little humor can be a powerful force

• Brainstorming is designed to produce a list of

candidate classes

Brainstorming

• Step 1 : review brainstorming principles at the beginning

of the meeting

  • remind everyone that this is a group activity and personal style

should be put aside.

• Step 2 : state specific session objectives

  • such as: “Today we want to come up with a list of candidate

classes for the sorted ADT or grocery store checkout system .”

• Step 3 : use a round-robin technique to allow the group

to proceed at an even tempo but give people enough

time to think.

  • Each person should contribute a possible object class to the list.
  • A facilitator should keep the discussion on target, and a scribe

should take notes.

Scenarios

• a sequence of steps that describes an

interaction between a client/user and an

application/program

• Simulate class interactions

• to Assign responsibilities to each class

• Ask “What if?” questions

• There are two types of responsibilities

• What a class must know about itself

( knowledge)

• What a class must be able to do ( behavior) 7

Responsibility Algorithms

• The algorithms must be written for the

responsibilities

• Knowledge responsibilities usually just

return the contents of one of an object’s

variables

• Action responsibilities are a little more

complicated, often involving calculations

Computer Example

• First pass at a list of

classes

Computer Example

• Filtered list

Responsibility Algorithms

Object-oriented vs. Top Down

• Object-oriented design

• focuses on the data objects that are to be

transformed

• resulting in a hierarchy of objects

• nouns are the primary focus

• nouns in objects; verbs become operations

• Top-down design

• focus on the process of transforming the input

into the output,

• resulting in a hierarchy of tasks

• verbs are the primary focus Docsity.com 14

Member functions

Which member function specifications

and implementations must change to

ensure that any instance of the Sorted

List ADT remains sorted at all times?

• PutItem

• DeleteItem

InsertItem algorithm for SortedList ADT

• Find proper location for the new

element in the sorted list.

• Create space for the new element by

moving down all the list elements that

will follow it.

• Put the new element in the list.

• Increment length.

void SortedType :: PutItem ( ItemType item )

{ bool moreToSearch; int location = 0; // find proper location for new element moreToSearch = ( location < length ); while ( moreToSearch ) { switch ( item.ComparedTo( info[location] ) ) { case LESS : moreToSearch = false; break; case GREATER : location++; moreToSearch = ( location < length ); break; } } // make room for new element in sorted list for ( int index = length ; index > location ; index-- ) info [ index ] = info [ index - 1 ]; info [ location ] = item; length++;

}

DeleteItem algorithm for

SortedList ADT

• Find the location of the element to

be deleted from the sorted list.

• Eliminate space occupied by the

item by moving up all the list

elements that follow it.

• Decrement length.