Part1 Overview+and+Review Rasha
Part1 Overview+and+Review Rasha
(in JAVA)
Course objectives
❑ Text Book:
▪ Data Structures & Algorithms in JAVA (5th Edition), by M. Goodrich & R.
Tamassia, John Wiley & Sons, inc., 2010.
❑ Additional Readings:
▪ Data Structures and Problem Solving with JAVA (3rd Edition), by Mark
Allen Weiss, Addison Wesley, 2006.
▪ Lecture slides and handouts
What is data?
❑ Data
▪ A collection of facts from which conclusion may be
drawn
▪ e.g. Data: Temperature 35°C; Conclusion: It is hot.
❑ Types of data
▪ Textual: For example, your name (Muhammad)
▪ Numeric: For example, your ID (090254)
▪ Audio: For example, your voice
▪ Video: For example, your voice and picture
▪ (...)
What is data structure?
❑ A particular way of storing and organizing data
in a computer so that it can be used efficiently and
effectively.
❑Data Structures are the programmatic way of
storing data so that data can be used efficiently.
❑Data structure is the logical or mathematical model
of a particular organization of data.
❑ A group of data elements grouped together under
one name.
▪ For example, an array of integers
• Data Structure
is a way of collecting and organizing data in such a way that we
can perform operations on these data in an effective way.
• Data Structures
is about rendering data elements in terms of some relationship,
for better organization and storage.
For example, we have some data which has,
player's name "Virat" and age 26. Here "Virat" is
of String data type and 26 is of integer data type.
• We can organize this data as a record like Player record, which
will have both player's name and age in it.
• Now we can collect and store player's records in a file or
database as a data structure. For example: "Dhoni" 30,
"Gambhir" 31, "Sehwag" 33
Types of data structures
1-D Array
Linked List
Queue Stack
Tree
❑ Design Issue:
▪ select and design appropriate data types
(This is the main motivation to learn and understand data
structures)
Data Structure Operations
(Demonstrate using class room example!)
❑ Traversing
▪ Accessing each data element exactly once so that
certain items in the data may be processed
❑ Searching
▪ Finding the location of the data element (key) in the
structure
❑ Insertion
▪ Adding a new data element to the structure
Data Structure Operations (cont.)
❑ Deletion
▪ Removing a data element from the structure
❑ Sorting
▪ Arrange the data elements in a logical order
(ascending/descending)
❑ Merging
▪ Combining data elements from two or more data
structures into one
What is algorithm?
❑ A finite set of instructions which accomplish a
particular task
❑ A method or process to solve a problem
❑ Transforms input of a problem to output
Algorithm = Input + Process + Output
Begin
Input: num
Output: numbers between 10 and 20
Process:
Start
if (num<10) Then
print “Smaller !”
elseif (num >20)
print “Bigger !”
End if
End
What are the values of the variables A, B and C after execution of the
following instructions?
Begin
A←3
B ← 10
C←A+B
B←A+B
A←C
End
Write an algorithm to swap the value the 2 variables A and B.
Solution:
Begin
WRITE “Enter a number”
READ num
IF num> 0 THEN
WRITE “The number is positive”
ELSE IF num = 0 THEN
WRITE “The number is zero”
ELSE
WRITE “The number is negative”
ENDIF
ENDIF
End