CSCI 103
AlgorithmsandProblem
Solving
Spring2013
Graphs
Graphs
In a tree we are allowed multiple links from a node,
but not to a node.
If we allow multiple links to a node as well as from a
node, the resulting data structure is called a graph.
This is

CSCI103 Algorithm and Problem Solving
Lecture Exercises 4
Lecture Exercises 4
Sorting and Searching
Question 1: Selection Sort
Trace the sort for every pass until the list of numbers is sorted in ascending order.
For each pass, indicate clearly the values

CSCI103 Algorithm and Problem Solving
Lecture Exercises 9
Lecture Exercises 9
Algorithmic Strategies and Analysis
Question 1:
The figure below shows a 4x4 maze. X indicates that there is no
path; O indicates that it is a path; C indicates the location of

CSCI103 Algorithm and Problem Solving
Lecture Exercises 7
Lecture Exercises 7
Recursion
Question 1
Study the recursive algorithm Unknown given below:
1
2
3
4
5
6
7
BEGIN Unknown(a)
IF (a EQUALS 1) THEN
REUTRN 1
ELSE
RETURN (a * a) + Unknown (a-1)
ENDIF
EN

CSCI103 Algorithm and Problem Solving
Lecture Exercises 8
Lecture Exercises 8
Trees
Question 1: Tree Terminology
For the tree given below, answer the following questions:
a)
b)
c)
d)
e)
f)
g)
h)
What is the root?
What are the indegree, outdegree and degre

CSCI 103 Algorithms and Problem Solving
Tutorial Exercise 1
October - December 2015
Introduction to Problem Solving
Pseudocode and Flowcharts
Tutorial Exercise 1
Objectives
After the completion of these exercises, the students should be able to:
Understa

CSCI 103 Algorithms and Problem Solving
Tutorial Exercises 3
October December 2015
Linked Lists
Stacks and Queues
Tutorial Exercises 3
Objectives
After the completion of these exercises, the student should be able to:
Traverse, search and delete nodes

October December 2015
CSCI 103 Algorithms and Problem Solving
Tutorial Exercises 4
Tutorial Exercises 4
Recursion / Trees
Objectives
After the completion of these exercises, the student should be able to:
Understand how recursion works
Trace the executi

CSCI 103 Algorithms and Problem Solving
Tutorial Exercises 2
Tutorial Exercises 2
October December 2015
More on Problem Solving
Sorting and Searching
Objectives
After the completion of these exercises, the student should be able to:
Understand the conce

CSCI 103 Algorithms and Problem Solving
Lecture Exercises 1
Lecture Exercises 1
Introduction to Problem Solving
Question 1
Identify the start state, goal state, operators and constraints

CSCI103 Algorithm and Problem Solving
Lecture Exercises 3
Lecture Exercises 3
More on Problem Solving
Question 1
Peter and his three young children (Andrew, John and Matthew) want to
cross to the other side of the river. His boat can carry at most two per

CSCI103 Algorithm and Problem Solving
Lecture Exercises 6
Lecture Exercises 6
Stacks and Queues
Question 1: Stacks
(a) The figure below shows a stack S implemented using a linked list.
Stack S
2
S24
count
80
top
Draw a diagram to show the stack S after th

Lecture 4
Sorting and Searching
CSCI 103 Algorithms & Problem Solving
April June 2015
Topics
"
"
"
"
"
Intuitive Sort
Selection Sort
Insertion Sort
Bubble Sort
Elementary Searching
CSCI 103
2
Elementary Sorting Algorithms
One of the fundamental pro

Lecture 2
Pseudocode and Flowcharts
CSCI 103 Algorithms & Problem Solving
April June 2015
Topics
"
"
"
"
"
"
Flowchart
Pseudocode
Using Flowchart and Pseudocode
Basic Data Types
Basic Data Structures
Modularisation
CSCI 103
2
Recall: Algorithm
A

Lecture 6
Stacks and Queues
CSCI 103 Algorithms & Problem Solving
April June 2015
Topics
"
"
"
"
Stack
Stack Implementation
Stack Applications
Queue
CSCI 103
2
Stack
3
What is a Stack ?
. 1
A stack is a linear list in which all additions and
d

Lecture 7
Recursion
CSCI 103 Algorithms & Problem Solving
April June 2015
Topics
"
"
"
"
"
What is Recursion ?
Examples of Recursive Problems
Solving Problems Using Recursion
How does recursion work ?
Classic Recursive Problem: Tower of Hanoi
CSCI 103
2
W

Lecture 8a
Trees Part 1
CSCI 103 Algorithms & Problem Solving
April June 2015
Topics
"
"
"
"
Basic Tree Concept
Binary Tree
Binary Tree Traversal
Expression Tree (An application of Binary Tree)
CSCI 103
2
Basic Tree Concept
3
Basic Concepts
Data

Lecture 1
Introduction to Problem Solving
CSCI 103 Algorithms & Problem Solving
April June 2015
Topics
"
"
"
"
"
Problem Representation
Problem Classification
Problem Solving Strategies
Problem Solving Steps
Algorithms in Computer Science
CSCI 103
2
Probl

Lecture 8b
Trees Part 2
CSCI 103 Algorithms & Problem Solving
April June 2015
Topics
Huffman Code
Binary Search Tree
Binary Search Tree Operations
#
#
#
CSCI 103
Traversal
Insertion
Deletion
2
Huffman Code
(Application of Binary Tr

CSCI103 Algorithm and Problem Solving
Lecture Exercises 2
Lecture Exercises 2
Pseudocode and Flowchart
Question 1
For each of the following problems, draw a flowchart to represent the algorithm to solve
the problem.
a) Alice would like to write a progr

www.it-ebooks.info
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
www.it-ebooks.info
Contents at a Glance
About the Authors xxi
About the Te